--Exportar excel cotizacion, fix autorizaciones por sucursal
This commit is contained in:
@@ -420,11 +420,15 @@
|
||||
<li>
|
||||
<asp:LinkButton ID="LnkEnvioDeCorreoFactura" runat="server" CausesValidation="False" OnClick="LnkEnvioDeCorreoFactura_Click" Visible="false"> <i class="fa fa-envelope-o" aria-hidden="true"></i> Envio De Correo</asp:LinkButton>
|
||||
</li>
|
||||
<li>
|
||||
<asp:LinkButton ID="LnkExportarExcelCot" runat="server" CausesValidation="False" OnClick="LnkExportarExcelCot_Click" Visible="false"> <i class="fa fa-file-excel-o" aria-hidden="true"></i> Exportar a Excel</asp:LinkButton>
|
||||
</li>
|
||||
</ContentTemplate>
|
||||
<Triggers>
|
||||
<asp:AsyncPostBackTrigger ControlID="LnkImprimir" EventName="Click" />
|
||||
<asp:PostBackTrigger ControlID="LnkImprimirFormatoCicovisa" />
|
||||
<asp:PostBackTrigger ControlID="LnkImprimirFormatoTelcel" />
|
||||
<asp:PostBackTrigger ControlID="LnkExportarExcelCot" />
|
||||
</Triggers>
|
||||
</asp:UpdatePanel>
|
||||
</asp:Content>
|
||||
@@ -1284,7 +1288,7 @@
|
||||
</table>
|
||||
|
||||
<asp:GridView ID="GvPS" GridLines="None" runat="server" data-tableheader="#tbps" ShowHeader="true" AutoGenerateColumns="False"
|
||||
DataKeyNames="Consec,CvePS,Total, IEPS, CveClasificacion,Clasificacion,CveUM,UM,CveProyecto,CveSubProyecto,TipoDocto,PS,Obs,Cantidad,PU,Descuento,IVA,ImporteIVA,CantidadInventario,CantidadFacturadaRem,CveVentaDetalle,CvePromocionDetalle,CvePrecioLista"
|
||||
DataKeyNames="Consec,CvePS,Total, IEPS, CveClasificacion,Clasificacion,CveUM,UM,CveProyecto,CveSubProyecto,TipoDocto,PS,Obs,Cantidad,PU,Descuento,IVA,ImporteIVA,CantidadInventario,CantidadFacturadaRem,CveVentaDetalle,CvePromocionDetalle,CvePrecioLista,Codigo,NumeroParte,TotalImporte"
|
||||
CssClass="table table-striped table-advance table-hover Widthall Sortable mysmallbtn ScrollAD" Style="min-width: 980px;">
|
||||
<Columns>
|
||||
<%--0--%>
|
||||
|
||||
@@ -14,6 +14,7 @@ Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Imports Modelos
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Imports GemBox.Spreadsheet
|
||||
|
||||
Partial Class Ventas
|
||||
Inherits ClsPaginas
|
||||
@@ -2922,6 +2923,7 @@ Partial Class Ventas
|
||||
TmpDT.Columns.Add("NumeroPedimento", GetType(String))
|
||||
TmpDT.Columns.Add("CodigoAlterno", GetType(String))
|
||||
TmpDT.Columns.Add("PSAlterno", GetType(String))
|
||||
TmpDT.Columns.Add("NumeroParte", GetType(String))
|
||||
TmpDT.Columns.Add("Costo", GetType(Decimal))
|
||||
TmpDT.Columns("Costo").DefaultValue = 0D
|
||||
GvPS.DataSource = ObjVentas.DtResultados
|
||||
@@ -6385,6 +6387,18 @@ Partial Class Ventas
|
||||
Next
|
||||
End If
|
||||
|
||||
Dim PuedeVerCosto As Boolean = UsuarioActual.TienePermisoProceso(385)
|
||||
|
||||
If PuedeVerCosto AndAlso DbRowVenta("TipoDocto").ToString() = "Cot" Then
|
||||
GvPS.Columns(10).Visible = True
|
||||
thCosto.Visible = True
|
||||
thCosto2.Visible = True
|
||||
LnkExportarExcelCot.Visible = True
|
||||
|
||||
UpnTools.Update()
|
||||
UpPS.Update()
|
||||
End If
|
||||
|
||||
End If
|
||||
End Using
|
||||
End If
|
||||
@@ -7798,7 +7812,7 @@ Partial Class Ventas
|
||||
|
||||
Dim ValorAutorizacion As String = UsuarioActual.Empresa.Funcionalidad(595)
|
||||
'solo para bdh, que se generen NC
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlSolCreditoTipoDocto.Items.Add(New ListItem("Nota de crédito", "Egs"))
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlSolCreditoTipoDocto.Items.FindByValue("Egs") Is Nothing Then DdlSolCreditoTipoDocto.Items.Add(New ListItem("Nota de crédito", "Egs"))
|
||||
Me.Bloqueada = False
|
||||
'OBLIGAR PAGO DE CONTADO SI EL CLIENTE NO PERMITE CREDITO
|
||||
If Not EsFilial AndAlso (Not UsuarioActual.Empresa.Funcionalidad(702).Contiene("1")) AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then
|
||||
@@ -8389,15 +8403,19 @@ Partial Class Ventas
|
||||
If Not CBool(ObjClie.DtResultados.FiltroPrimeroValor("InformacionCompleta")) Then
|
||||
Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón: <br> <br> {0}", "Información incompleta")
|
||||
Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
|
||||
|
||||
BtnEmitirImprimir.Visible = False
|
||||
BtnsFacturar.Visible = False
|
||||
BtnGenerarRemision.Visible = False
|
||||
|
||||
TieneBloqueoPorCreditoVencimiento = 1
|
||||
End If
|
||||
End If
|
||||
ObjClie.Dispose()
|
||||
|
||||
If TieneBloqueoPorCreditoVencimiento = 1 Then
|
||||
BtnEmitirImprimir.Visible = False
|
||||
BtnsFacturar.Visible = False
|
||||
BtnGenerarRemision.Visible = False
|
||||
|
||||
UpFacturar.Update()
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
@@ -9142,10 +9160,10 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
If CveVenta <= 0 Then
|
||||
Dim PuedeVerCosto As Boolean = UsuarioActual.TienePermisoProceso(201) OrElse UsuarioActual.TienePermisoProceso(385)
|
||||
Dim PuedeVerCosto As Boolean = UsuarioActual.TienePermisoProceso(385)
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso PuedeVerCosto Then
|
||||
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso PuedeVerCosto Then
|
||||
If CveVenta <= 0 Then
|
||||
If e.Row.DBCampo("PU").ToDecimal() > 0 Then
|
||||
e.Row.FCLabel("LblCosto").Text = String.Format("{0:N2}", e.Row.DBCampo("Costo").ToDecimal())
|
||||
e.Row.FCLabel("LblCostoPorcentaje").Text = String.Format("{0:N2} %", ((e.Row.DBCampo("PU").ToDecimal() - e.Row.DBCampo("Costo").ToDecimal()) / e.Row.DBCampo("PU").ToDecimal()) * 100D)
|
||||
@@ -9153,6 +9171,14 @@ Partial Class Ventas
|
||||
e.Row.FCLabel("LblCosto").Text = ""
|
||||
e.Row.FCLabel("LblCostoPorcentaje").Text = ""
|
||||
End If
|
||||
ElseIf CveVenta > 0 Then
|
||||
If e.Row.DBCampo("PU").ToDecimal() > 0 Then
|
||||
e.Row.FCLabel("LblCosto").Text = String.Format("{0:N2}", e.Row.DBCampo("UltimoCosto").ToDecimal())
|
||||
e.Row.FCLabel("LblCostoPorcentaje").Text = String.Format("{0:N2} %", ((e.Row.DBCampo("PU").ToDecimal() - e.Row.DBCampo("UltimoCosto").ToDecimal()) / e.Row.DBCampo("PU").ToDecimal()) * 100D)
|
||||
Else
|
||||
e.Row.FCLabel("LblCosto").Text = ""
|
||||
e.Row.FCLabel("LblCostoPorcentaje").Text = ""
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -18939,7 +18965,7 @@ Partial Class Ventas
|
||||
|
||||
If UsuarioActual.CveEmpresa = 189 Then
|
||||
AgregarPSAutomaticamente = False
|
||||
Dim PuedeVerCosto As Boolean = UsuarioActual.TienePermisoProceso(201) OrElse UsuarioActual.TienePermisoProceso(385)
|
||||
Dim PuedeVerCosto As Boolean = UsuarioActual.TienePermisoProceso(385)
|
||||
|
||||
Dim Costo As Decimal = 0
|
||||
|
||||
@@ -22596,9 +22622,9 @@ Partial Class Ventas
|
||||
' HlAgregarExcel.Visible = True
|
||||
End If
|
||||
|
||||
Dim PuedeVerCosto As Boolean = UsuarioActual.TienePermisoProceso(201) OrElse UsuarioActual.TienePermisoProceso(385)
|
||||
Dim PuedeVerCosto As Boolean = UsuarioActual.TienePermisoProceso(385)
|
||||
|
||||
If (CveVenta <= 0 OrElse EsCreaApartirDe) AndAlso UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso PuedeVerCosto Then
|
||||
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso PuedeVerCosto Then
|
||||
GvPS.Columns(10).Visible = True
|
||||
thCosto.Visible = True
|
||||
thCosto2.Visible = True
|
||||
@@ -38490,6 +38516,22 @@ Partial Class Ventas
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
'SI ESTA BLOQUEADO Y NO ES POR INFO INCOMPLETA, DEJAR MANDAR SOLICITUD DE AUTORIZACION
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
||||
Dim InformacionCompleta As Boolean = False
|
||||
Dim ObjClie As New ClsClientes
|
||||
If ObjClie.GetClienteInformacionCompleta(CveCliente, UsuarioActual.CveEmpresa) Then
|
||||
InformacionCompleta = CBool(ObjClie.DtResultados.FiltroPrimeroValor("InformacionCompleta"))
|
||||
End If
|
||||
ObjClie.Dispose()
|
||||
|
||||
If InformacionCompleta AndAlso TieneBloqueoPorCreditoVencimiento = 1 Then
|
||||
If DdlSolCreditoTipoDocto.Items.FindByValue("Ing") Is Nothing Then
|
||||
DdlSolCreditoTipoDocto.Items.Insert(0, New ListItem("Ingreso", "Ing"))
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
TxtImporteSolicitud.Text = ""
|
||||
DdlSolCreditoTipoDocto_SelectedIndexChanged(Nothing, EventArgs.Empty)
|
||||
RegistraScript("$('#DivModalSolicitarCredito').modal('show')")
|
||||
@@ -41734,5 +41776,71 @@ Partial Class Ventas
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub LnkExportarExcelCot_Click(sender As Object, e As EventArgs)
|
||||
Dim DtExcel As DataTable = (From row As GridViewRow In GvPS.Rows.Cast(Of GridViewRow)
|
||||
Where row.RowType = DataControlRowType.DataRow
|
||||
Select New With
|
||||
{
|
||||
.Codigo = row.DataKey("Codigo").Trim(),
|
||||
.NumeroParte = row.DataKey("NumeroParte").Trim(),
|
||||
.Descripcion = row.DataKey("PS").Trim(),
|
||||
.Medida = row.DataKey("UM").Trim(),
|
||||
.Cantidad = row.FCLiteral("LtlCantidad").Text.Trim().ToDecimal(),
|
||||
.Precio = row.FCLiteral("LtlPU").Text.Trim().ToDecimal(),
|
||||
.SubImporte = row.DataKey("TotalImporte").ToDecimal(),
|
||||
.MargenUtilidad = row.FCLabel("LblCostoPorcentaje").Text.Replace("%", "").Replace(" ", "").Trim().ToDecimal(),
|
||||
.UltimoCosto = row.FCLabel("LblCosto").Text.Trim().ToDecimal()
|
||||
}).QueryToDataTable(True)
|
||||
If DtExcel.Rows.Count < 1 Then
|
||||
Alert("No hay resultados en la busqueda.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim folio = LblSerie.Text + "-" + TxtFolio.Text
|
||||
|
||||
|
||||
DtExcel.TableName = folio
|
||||
|
||||
|
||||
DtExcel.Columns("Codigo").ColumnName = "Código"
|
||||
DtExcel.Columns("Descripcion").ColumnName = "Descripción"
|
||||
DtExcel.Columns("NumeroParte").ColumnName = "Número de parte"
|
||||
DtExcel.Columns("SubImporte").ColumnName = "Sub-Importe"
|
||||
DtExcel.Columns("MargenUtilidad").ColumnName = "Margen de utilidad"
|
||||
DtExcel.Columns("UltimoCosto").ColumnName = "Último costo"
|
||||
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
|
||||
Dim FileExcel As New ExcelFile()
|
||||
|
||||
Dim worksheet As ExcelWorksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
||||
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
||||
{
|
||||
.ColumnHeaders = True,
|
||||
.StartRow = 0,
|
||||
.StartColumn = 0
|
||||
})
|
||||
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255))
|
||||
worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255)
|
||||
|
||||
'CANTIDAD
|
||||
worksheet.Columns(4).Style.NumberFormat = "#,##0.00"
|
||||
'PRECIO
|
||||
worksheet.Columns(5).Style.NumberFormat = "$#,##0.00_);($#,##0.00)"
|
||||
'IMPORTE
|
||||
worksheet.Columns(6).Style.NumberFormat = "$#,##0.00_);($#,##0.00)"
|
||||
'UTILIDAD
|
||||
worksheet.Columns(7).Style.NumberFormat = "#,##0.00"
|
||||
'ULTIMO COSTO
|
||||
worksheet.Columns(8).Style.NumberFormat = "$#,##0.00_);($#,##0.00)"
|
||||
|
||||
Dim columnCount As Integer = worksheet.CalculateMaxUsedColumns()
|
||||
For i As Integer = 0 To columnCount
|
||||
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||
Next
|
||||
|
||||
FileExcel.Save(Response, $"{folio}.xlsx", SaveOptions.XlsxDefault)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user