reporte Sabana de Venta, generacion de los excel
This commit is contained in:
@@ -11,7 +11,10 @@
|
|||||||
<asp:UpdatePanel ID="UpAcciones" runat="server" UpdateMode="Conditional">
|
<asp:UpdatePanel ID="UpAcciones" runat="server" UpdateMode="Conditional">
|
||||||
<ContentTemplate>
|
<ContentTemplate>
|
||||||
<li>
|
<li>
|
||||||
<asp:LinkButton runat="server" ID="BtnImprimir" OnClick="BtnImprimir_Click" data-toggle="tooltip" data-placement="left" title="Agregar un Defecto" Text="<i class='fa fa-file-pdf-o'></i>Imprimir"></asp:LinkButton>
|
<asp:LinkButton runat="server" ID="BtnDescargaSabana" OnClick="BtnDescargaSabana_Click" data-toggle="tooltip" data-placement="left" title="Descargar Sabana de Venta" Text="<i class='fa fa-download'></i> Descargar Sabana de Venta"></asp:LinkButton>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<asp:LinkButton runat="server" ID="BtnImprimir" OnClick="BtnImprimir_Click" data-toggle="tooltip" data-placement="left" title="Agregar un Defecto" Text="<i class='fa fa-file-pdf-o'></i> Imprimir"></asp:LinkButton>
|
||||||
</li>
|
</li>
|
||||||
</ContentTemplate>
|
</ContentTemplate>
|
||||||
<Triggers>
|
<Triggers>
|
||||||
@@ -97,6 +100,87 @@
|
|||||||
</asp:UpdatePanel>
|
</asp:UpdatePanel>
|
||||||
</ContentTemplate>
|
</ContentTemplate>
|
||||||
</asp:UpdatePanel>
|
</asp:UpdatePanel>
|
||||||
|
|
||||||
|
<div id="DivModalSabana" class="modal ADS fade" role="dialog">
|
||||||
|
<asp:UpdatePanel class="modal-dialog" runat="server" ID="UpdatePanel2" UpdateMode="Conditional" RenderMode="Inline" style="width:50%">
|
||||||
|
<ContentTemplate>
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header ">
|
||||||
|
<h4 class="modal-title">
|
||||||
|
<asp:Literal ID="Literal1" Text="Sabana de venta" runat="server"> </asp:Literal></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="row" style="width:100%">
|
||||||
|
<div style="width:98%;margin-left:1.5%;margin-right:1.5%">
|
||||||
|
<asp:UpdatePanel ID="UpProductoCaducidad" runat="server" UpdateMode="Conditional" RenderMode="Inline">
|
||||||
|
<ContentTemplate>
|
||||||
|
<div runat="server" id="DivImprimir" class="row" visible="True">
|
||||||
|
<div class="col-md-4" style="text-align:center">
|
||||||
|
<label>Opcion:</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4" style="text-align:center">
|
||||||
|
<label>MES:</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4" style="text-align:center">
|
||||||
|
<label>AÑO:</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div runat="server" id="Div1" class="row" visible="True">
|
||||||
|
<div class="col-md-4" style="text-align:center">
|
||||||
|
<asp:DropDownList ID="DdlOpcion" runat="server" Width="150px" Height="28px">
|
||||||
|
<asp:ListItem Text="General" Value="1"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Por centro servicio" Value="2"></asp:ListItem>
|
||||||
|
</asp:DropDownList>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4" style="text-align:center">
|
||||||
|
<asp:DropDownList ID="DdlMes" runat="server" Width="100px" Height="28px">
|
||||||
|
<asp:ListItem Text="Enero" Value="1"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Febrero" Value="2"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Marzo" Value="3"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Abril" Value="4"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Mayo" Value="5"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Junio" Value="6"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Julio" Value="7"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Agosto" Value="8"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Septiembre" Value="9"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Octubre" Value="10"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Noviembre" Value="11"></asp:ListItem>
|
||||||
|
<asp:ListItem Text="Diciembre" Value="12"></asp:ListItem>
|
||||||
|
</asp:DropDownList>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4" style="text-align:center">
|
||||||
|
<asp:DropDownList ID="DdlAño" runat="server" Width="100px" Height="28px" DataTextField="Año" DataValueField="Año">
|
||||||
|
</asp:DropDownList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</ContentTemplate>
|
||||||
|
</asp:UpdatePanel>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<div runat="server" id="Div2" class="row" visible="True">
|
||||||
|
<div class="col-md-6" style="text-align: center">
|
||||||
|
<asp:UpdatePanel ID="UpDescargar" runat="server" UpdateMode="Conditional">
|
||||||
|
<ContentTemplate>
|
||||||
|
<asp:Button ID="BtnDescargarSabana" runat="server" CssClass="btn btn-primary" Text="Descargar" />
|
||||||
|
</ContentTemplate>
|
||||||
|
<Triggers>
|
||||||
|
<asp:PostBackTrigger ControlID="BtnDescargarSabana" />
|
||||||
|
</Triggers>
|
||||||
|
</asp:UpdatePanel>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6" style="text-align: center">
|
||||||
|
<button type="button" class="btn btn-light" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ContentTemplate>
|
||||||
|
</asp:UpdatePanel>
|
||||||
|
</div>
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
|
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
Imports System.Data
|
Imports System.Data
|
||||||
Imports Extensiones
|
Imports Extensiones
|
||||||
Imports Microsoft.Reporting.WebForms
|
Imports Microsoft.Reporting.WebForms
|
||||||
|
Imports GemBox.Spreadsheet
|
||||||
|
Imports System.IO
|
||||||
|
|
||||||
Partial Class Acumuladores_RepEntradasUsados
|
Partial Class Acumuladores_RepEntradasUsados
|
||||||
Inherits ClsPaginas
|
Inherits ClsPaginas
|
||||||
@@ -22,6 +24,9 @@ Partial Class Acumuladores_RepEntradasUsados
|
|||||||
txtFechaI.Text = Today.AddDays((-1) * (Today.Day - 1))
|
txtFechaI.Text = Today.AddDays((-1) * (Today.Day - 1))
|
||||||
txtFechaF.Text = Today
|
txtFechaF.Text = Today
|
||||||
CargarDatos()
|
CargarDatos()
|
||||||
|
CargarCombos()
|
||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -30,6 +35,18 @@ Partial Class Acumuladores_RepEntradasUsados
|
|||||||
DdlAlmacenes.DataBind()
|
DdlAlmacenes.DataBind()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Protected Sub CargarCombos()
|
||||||
|
Dim ObjAcum As New ClsAcumuladores
|
||||||
|
Dim fecha As Date = Date.Now.AddMonths(-1)
|
||||||
|
ObjAcum.GetAñosVentas(UsuarioActual.CveEmpresa)
|
||||||
|
DdlAño.DataSource = ObjAcum.DtResultados
|
||||||
|
DdlAño.DataBind()
|
||||||
|
DdlAño.SelectedValue = fecha.Year.ToEntero
|
||||||
|
ObjAcum.Dispose()
|
||||||
|
|
||||||
|
DdlMes.SelectedValue = fecha.Month.ToEntero
|
||||||
|
End Sub
|
||||||
|
|
||||||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||||||
Dim ObjAcum As New ClsAcumuladores
|
Dim ObjAcum As New ClsAcumuladores
|
||||||
|
|
||||||
@@ -63,5 +80,77 @@ Partial Class Acumuladores_RepEntradasUsados
|
|||||||
|
|
||||||
ImprimirPDF(String.Format("Empresas/{0}/Formatos/RepEntradasUsados.rdlc", UsuarioActual.CveEmpresa), DatosEntradasUsados, params, "Reporte entrada usados", "PDF")
|
ImprimirPDF(String.Format("Empresas/{0}/Formatos/RepEntradasUsados.rdlc", UsuarioActual.CveEmpresa), DatosEntradasUsados, params, "Reporte entrada usados", "PDF")
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Protected Sub BtnDescargaSabana_Click(sender As Object, e As EventArgs) Handles BtnDescargaSabana.Click
|
||||||
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivModalSabana"))
|
||||||
|
|
||||||
|
'RegistraScript("$('#DModalEditarFecha').modal('hide')")
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Protected Sub BtnDescargarSabana_Click(sender As Object, e As EventArgs) Handles BtnDescargarSabana.Click
|
||||||
|
Dim Retorno As New IO.MemoryStream()
|
||||||
|
Dim ObjAcum As New ClsAcumuladores
|
||||||
|
Dim Mes As String = DdlMes.SelectedValue.ToString
|
||||||
|
Dim Año As String = DdlAño.SelectedValue.ToString
|
||||||
|
Dim Fecha As Date = (String.Format("01/{0}/{1}", Mes, Año)).ToDate
|
||||||
|
Dim dt As DataTable
|
||||||
|
Dim NombreArchivo As String
|
||||||
|
Try
|
||||||
|
If DdlOpcion.SelectedValue = 1 Then
|
||||||
|
ObjAcum.GetSabanaVenta(Fecha, 1, UsuarioActual.CveEmpresa)
|
||||||
|
|
||||||
|
ElseIf DdlOpcion.SelectedValue = 2 Then
|
||||||
|
ObjAcum.GetSabanaVenta(Fecha, 2, UsuarioActual.CveEmpresa)
|
||||||
|
|
||||||
|
End If
|
||||||
|
dt = ObjAcum.DtResultados
|
||||||
|
|
||||||
|
If dt IsNot Nothing And dt.Rows.Count > 0 Then
|
||||||
|
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||||
|
Dim workbook As New ExcelFile()
|
||||||
|
|
||||||
|
Dim worksheet = workbook.Worksheets.Add("Sabana de ventas")
|
||||||
|
worksheet.InsertDataTable(dt, 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)
|
||||||
|
|
||||||
|
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
||||||
|
For i = 0 To columnCount
|
||||||
|
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||||
|
Next
|
||||||
|
|
||||||
|
Año = Strings.Right(Año, 2)
|
||||||
|
If Mes.ToEntero < 10 Then
|
||||||
|
Mes = String.Format("0{0}", Mes)
|
||||||
|
End If
|
||||||
|
If DdlOpcion.SelectedValue = 1 Then
|
||||||
|
NombreArchivo = String.Format("700415-{0}{1}-GE", Mes, Año)
|
||||||
|
workbook.Save(Response, $"{NombreArchivo}.xlsx", SaveOptions.XlsxDefault)
|
||||||
|
|
||||||
|
|
||||||
|
ElseIf DdlOpcion.SelectedValue = 2 Then
|
||||||
|
NombreArchivo = String.Format("700415-{0}{1}-CS", Mes, Año)
|
||||||
|
workbook.Save(Response, $"{NombreArchivo}.xlsx", SaveOptions.XlsxDefault)
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
GuardaLog(String.Format("Ocurrio un error al generar el excel {0}", ex.Message))
|
||||||
|
|
||||||
|
End Try
|
||||||
|
|
||||||
|
ObjAcum.Dispose()
|
||||||
|
RegistraScript("$('#DModalEditarFecha').modal('hide')")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@@ -1173,6 +1173,42 @@ Public Class ClsAcumuladores
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
Public Function GetSabanaVenta(Fecha As Date, CveOpcion As Integer, CveEmpresa As Integer) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
|
||||||
|
SqlDataAdapter("PA_Acum_SabanaVentaGet")
|
||||||
|
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@Fecha", SqlDbType.Date).Value = Fecha
|
||||||
|
.Add("@Opcion", SqlDbType.Int).Value = CveOpcion
|
||||||
|
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||||
|
|
||||||
|
End With
|
||||||
|
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As SqlException
|
||||||
|
OnError("Ocurrió un error al consultar los movimientos. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function GetAñosVentas(CveEmprea As Integer) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
SqlDataAdapter(String.Format("select year(Fecha) as Año from Ventas where CveEmpresa = {0} group by year(Fecha) Order by year(Fecha)", CveEmprea.ToString), CommandType.Text)
|
||||||
|
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError(String.Format("Ocurrió un error al consultar los año de venta"), ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
Return Retorno
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
#Region " IDisposable Support "
|
#Region " IDisposable Support "
|
||||||
' IDisposable
|
' IDisposable
|
||||||
|
|||||||
Reference in New Issue
Block a user