Ajustes Contratos, excel

This commit is contained in:
Rakcsle Supertramp
2020-11-07 14:01:42 -07:00
parent befcdb34aa
commit 97aa459125
5 changed files with 471 additions and 83 deletions

View File

@@ -658,7 +658,7 @@
<div class="modal-footer">
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Button ID="BtnGuardarFaturas" runat="server" ClientIDMode="Static" Text="Guardar" CssClass="btn btn-primary" />
<asp:Button ID="BtnGuardarFaturas" runat="server" ClientIDMode="Static" Text="Aceptar" CssClass="btn btn-primary" />
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
</ContentTemplate>
</asp:UpdatePanel>

View File

@@ -1208,7 +1208,7 @@ Partial Class Compras_eFacturas
DtNoRecibidas.ReadXml(Ruta)
Dim conta As Integer = 1
Str.Append("Se encontraron las siguientes facturas con problema:<br/> <table width='900px'><tr class='Titulos'><td>Serie</td><td>Folio</td><td>Fecha</td><td>Proveedor</td><td>Importe</td><td>Motivo</td><td>Correo</td><td>F. Recepción</td></tr>")
Str.Append("Se procesó la información con la siguiente información:<br/> <table width='900px'><tr class='Titulos'><td>Serie</td><td>Folio</td><td>Fecha</td><td>Proveedor</td><td>Importe</td><td>Motivo</td><td>Correo</td><td>F. Recepción</td></tr>")
For Each dr As DataRow In DtNoRecibidas.FiltraParametros("", "Fecha DESC").Rows

View File

@@ -257,7 +257,7 @@
<label class="col-md-1 truncate">Contrato:</label>
<div class="col-md-6 col-lg-4">
<div class="ddls">
<asp:DropDownList ID="DDlContratosEstimaciones" runat="server" AutoPostBack="true" DataTextField="ContratoCompleto" DataValueField="CveContrato" Class=" form-control input-inline select2me" Width="100%">
<asp:DropDownList ID="DDlContratosEstimaciones" runat="server" AutoPostBack="true" DataTextField="NumeroContrato" DataValueField="CveContrato" Class=" form-control input-inline select2me" Width="100%">
</asp:DropDownList>
</div>
</div>
@@ -303,59 +303,7 @@
</ItemTemplate>
</asp:TemplateField>
<%-- <asp:TemplateField HeaderText="Cantidad">
<ItemTemplate>
<asp:TextBox ID="TxtCantidad" Text="" CssClass="txtcant" onkeyup="ValidateCant(this)" type="number" step="any" data-cantidad='<%# Eval("CantidadMax")%>' data-pu='<%# Eval("PU")%>' data-cve='<%# Eval("CveContratoDetalle") %>' Width="90" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Importe">
<ItemTemplate>
<asp:TextBox ID="TxtImporte" Text="" data-cve='<%# Eval("CveContratoDetalle") %>' CssClass="txtimporte" type="number" step="any" Width="90" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=" ">
<ItemTemplate>
<asp:LinkButton ID="LnkAnexo" runat="server" OnClick="GetAnexos" AlternateText="Agregar Anexo" CssClass="btn btn-circle btn-sm btn-success anexo" Text="<i class='fa fa-folder'></i>" />
<asp:LinkButton runat="server" CssClass="btn btn-circle btn-sm btn-success" ID="LnkModalDropzone" Visible="false"> <i class='fa fa-plus'></i></asp:LinkButton>
<div runat="server" id="ModalAnexoEvidencia" class="modal ADS fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header ">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Cargar Evidencia</h4>
</div>
<div class="modal-body">
<div style="text-align:left">
<asp:TextBox ID="TXTAnexo" CssClass="ADSdropzone hidden" data-maxFile="10" Text="" runat="server"></asp:TextBox>
</div>
</div>
<div class="modal-footer">
<asp:UpdatePanel runat="server">
<ContentTemplate>
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>--%>
</Columns>
@@ -370,12 +318,16 @@
<div class="text-center">
<asp:Button id="BtnGuardarEstimacion" CssClass="btn btn-primary" runat="server" Text="Generar Estimacion" Visible="false"/>
<asp:Button id="BtnDescargarGenerado" CssClass="btn btn-primary" runat="server" Text="Descarga Generador" Visible="false"/>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="BtnDescargarGenerado" />
</Triggers>
</asp:UpdatePanel>

View File

@@ -5,9 +5,10 @@ Imports Extensiones
Imports System.IO
Imports System.Data
Imports Newtonsoft.Json
Imports ClosedXML.Excel
Partial Class Contratos_ContratoAvance
Inherits ClsPaginas
Inherits ClsPaginas
#Region "Propiedades"
Private Property DtDatos As DataTable
Get
@@ -63,6 +64,34 @@ Partial Class Contratos_ContratoAvance
End Set
End Property
Property CveEstimacionNueva As Integer
Get
If ViewState("CveEstimacionNueva") Is Nothing Then
Return -1
Else
Return ViewState("CveEstimacionNueva").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveEstimacionNueva") = value
End Set
End Property
Property NuemeroEstimacionNuevo As Integer
Get
If ViewState("NuemeroEstimacionNuevo") Is Nothing Then
Return -1
Else
Return ViewState("NuemeroEstimacionNuevo").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("NuemeroEstimacionNuevo") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
@@ -74,15 +103,15 @@ Partial Class Contratos_ContratoAvance
End If
End Sub
End Sub
#Region "Filtros"
Private Sub CargaContrato()
DdlContratos.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (4,30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
DdlContratos.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
DdlContratos.DataBind()
DDlContratosEstimaciones.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (4,30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
DDlContratosEstimaciones.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
DDlContratosEstimaciones.DataBind()
@@ -96,21 +125,21 @@ Partial Class Contratos_ContratoAvance
DdlAvances.Items.Clear()
Dim ObjContratos As New ClsContratos()
If ObjContratos.GetContratosAvanceFecha(DdlContratos.SelectedValue.ToEntero, 2) Then
DdlAvances.DataSource = ObjContratos.DtResultados
DdlAvances.DataSource = ObjContratos.DtResultados
End If
ObjContratos.Dispose()
DdlAvances.DataBind()
DdlAvances.Items.Insert(0, New ListItem(" ---- ", "-1"))
End Sub
End Sub
#End Region
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
CveContrato = DdlContratos.SelectedValue.ToEntero
CargaDatosAvance()
End Sub
Private Sub CargaDatosAvance()
GvAnexos.Visible = False
GvAnexos.Visible = False
Dim ObjContratos As New ClsContratos()
If DdlAvances.SelectedValue = "-1" Then
If ObjContratos.GetContratosAvanceTodos(CveContrato, 2) Then
@@ -121,7 +150,7 @@ Partial Class Contratos_ContratoAvance
btnanexogral.Visible = True
End If
End If
Else
Else
If ObjContratos.GetContratosAvanceHistoricos(CveContrato, 2, DdlAvances.SelectedValue) Then
fecha = DdlAvances.SelectedValue
DtDatos = ObjContratos.DtResultados
@@ -131,8 +160,8 @@ Partial Class Contratos_ContratoAvance
End If
ObjContratos.Dispose()
CargaGrid()
End Sub
End Sub
#Region "GV"
Private Sub CargaGrid()
If DtDatos IsNot Nothing Then
@@ -380,16 +409,19 @@ Partial Class Contratos_ContratoAvance
Private Sub BtnGuardarEstimacion_Click(sender As Object, e As EventArgs) Handles BtnGuardarEstimacion.Click
CveEstimacionNueva = -1
NuemeroEstimacionNuevo = -1
Dim ObjContratos As New ClsContratos()
Dim ErrorProceso As Boolean = False
Dim NuemeroEstimacion As Integer = -1
ObjContratos.IniciaTransacSQL()
If ObjContratos.AddContratosAvanceEstimacion(CveContratoEstimacion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
NuemeroEstimacion = ObjContratos.NumeroEstimacionNueva
CveEstimacionNueva = ObjContratos.CveEstimacionNueva
NuemeroEstimacionNuevo = ObjContratos.NumeroEstimacionNueva
For Each GvRow As GridViewRow In GvEstimaciones.Rows
@@ -412,15 +444,303 @@ Partial Class Contratos_ContratoAvance
If Not ErrorProceso Then
ObjContratos.Commit()
Alert($"Estimación {NuemeroEstimacion} agregada correctamente.")
Alert($"Estimación {NuemeroEstimacionNuevo} agregada correctamente.")
BtnGuardarEstimacion.Visible = False
BtnDescargarGenerado.Visible = True
Else
ObjContratos.RollBack()
End If
ObjContratos.Dispose()
UpEstimaciones.Update()
End Sub
Private Sub BtnDescargarGenerado_Click(sender As Object, e As EventArgs) Handles BtnDescargarGenerado.Click
GeneraAnexo(CveEstimacionNueva, NuemeroEstimacionNuevo, Now, DDlContratosEstimaciones.SelectedItem.Text)
End Sub
Private Sub GeneraAnexo(CveEstimacion As Integer, NumeroEstimacion As Integer, FechaEstimacion As Date, NumeroContrato As String)
Dim PlantillaAnexo As String = $"{UsuarioActual.Empresa.Ruta}\Formatos\Anexo.xlsx"
If Not System.IO.File.Exists(PlantillaAnexo) Then
Alert("No se encuentra la platilla de anexos.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim DtControl As New DataTable
Dim ObjContratos As New ClsContratos
If ObjContratos.GetContratosObraAvancesControlAcumulativo(CveContrato, CveEstimacion, UsuarioActual.CveEmpresa) Then
DtControl = ObjContratos.DtResultados
End If
ObjContratos.Dispose()
If DtControl.Rows.Count > 0 Then
Dim WBAnexo = New ClosedXML.Excel.XLWorkbook(PlantillaAnexo)
Dim WBAnexoSalvar = New ClosedXML.Excel.XLWorkbook
Dim WSControl = WBAnexo.Worksheet(1)
Dim WSDetalle = WBAnexo.Worksheet(2)
Dim CuerrentRow As Integer = 28
WSControl.Cell(17, 2).Value = NumeroEstimacion 'Estimacion
WSControl.Cell(20, 9).Value = FechaEstimacion.ToString("dd/MM/yyyy") 'Fecha estimacion
WSControl.Cell(19, 8).Value = "$ " & DtControl.SUM("Importe").ToString("###,###,###.00") 'Total
WSControl.Cell(19, 8).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
WSControl.Cell(20, 6).Value = NumeroContrato
WSControl.Cell(18, 2).Value = "" 'Lugar
WSControl.Cell(17, 6).Value = "" 'Periodo Fecha Inicial
WSControl.Cell(17, 7).Value = "" 'Periuodo Fecha Final
WSControl.Cell(20, 2).Value = "" 'Obra
WSControl.Cell(22, 7).Value = "" 'Presupuesto segun contrato
WSControl.Cell(19, 5).Value = "" 'Contrtatista
Dim RowCountControl As Integer = 1
For Each Drow As DataRow In DtControl.Rows
WSControl.Cell(CuerrentRow, 1).Value = Drow("Codigo").ToString
WSControl.Cell(CuerrentRow, 2).Value = Drow("PS").ToString
WSControl.Cell(CuerrentRow, 3).Value = Drow("Abreviatura").ToString
WSControl.Cell(CuerrentRow, 4).Value = Drow("Cantidad").ToString.ToDecimal
WSControl.Cell(CuerrentRow, 5).Value = Drow("AcumuladoTotal").ToString.ToDecimal
WSControl.Cell(CuerrentRow, 6).Value = Drow("AcumuladoAnterior").ToString.ToDecimal
WSControl.Cell(CuerrentRow, 7).Value = Drow("CantidadActual").ToString.ToDecimal
WSControl.Cell(CuerrentRow, 8).Value = Drow("PU").ToString.ToDecimal
WSControl.Cell(CuerrentRow, 9).Value = Drow("Total").ToString.ToDecimal
WSControl.Cell(CuerrentRow, 9).Style.NumberFormat.Format = "$ ###,###,###.00"
WSControl.Cell(CuerrentRow, 1).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 2).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 3).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 4).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 5).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 6).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 7).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 8).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 9).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 1).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 2).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 3).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 4).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 5).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 6).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 7).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 8).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 9).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
'ultimo Row
If DtControl.Rows.Count = RowCountControl Then
WSControl.Cell(CuerrentRow + 1, 1).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 2).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 3).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 4).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 5).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 6).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 7).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 8).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 9).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 1).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 2).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 3).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 4).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 5).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 6).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 7).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 8).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 9).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
WSControl.Cell(CuerrentRow + 1, 8).Value = "Total:"
WSControl.Cell(CuerrentRow + 1, 8).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
WSControl.Cell(CuerrentRow + 1, 8).Style.Font.Bold = True
WSControl.Cell(CuerrentRow + 1, 9).Value = DtControl.SUM("Total")
WSControl.Cell(CuerrentRow + 1, 9).Style.Font.Bold = True
WSControl.Cell(CuerrentRow + 1, 9).Style.NumberFormat.Format = "$ ###,###,###.00"
Dim range = WSControl.Range($"A{CuerrentRow + 3}:D{CuerrentRow + 3}")
range.Merge()
range.Style.Border.TopBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range = WSControl.Range($"E{CuerrentRow + 3}:I{CuerrentRow + 3}")
range.Merge()
range.Style.Border.TopBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range = WSControl.Range($"A{CuerrentRow + 4}:D{CuerrentRow + 4}")
range.Merge()
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range.Value = "ING. WALTER ROBERTO VILLEGAS LARES"
range = WSControl.Range($"E{CuerrentRow + 4}:I{CuerrentRow + 4}")
range.Merge()
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range.Value = "C. SALVADOR SUAREZ"
range = WSControl.Range($"A{CuerrentRow + 5}:D{CuerrentRow + 5}")
range.Merge()
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range.Value = "SERVICIOS ELECTRICOS Y CONTROL DE HERMOSILLO S.A. DE C.V."
range.Style.Font.Bold = True
range = WSControl.Range($"E{CuerrentRow + 5}:I{CuerrentRow + 5}")
range.Merge()
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range.Value = "GASERVICIO MATAMOROS SA DE CV"
range.Style.Font.Bold = True
End If
CuerrentRow = CuerrentRow + 1
RowCountControl = RowCountControl + 1
Next
WBAnexo.Worksheet(1).CopyTo(WBAnexoSalvar, "CONTROL")
For Each Drow As DataRow In DtControl.Rows
If Drow("CantidadActual").ToString.ToDecimal > 0 Then
WSDetalle.Cell(3, 6).Value = NumeroContrato
WSDetalle.Cell(4, 9).Value = "" 'Fecha de
WSDetalle.Cell(4, 10).Value = "" 'Fecha a
WSDetalle.Cell(4, 11).Value = NumeroEstimacion
'WSDetalle.Picture("Logo").Name = $"Logo{Drow("CveContratoDetalle").ToString}"
'WSDetalle.Picture("Firma").Name = $"Firma{Drow("CveContratoDetalle").ToString}"
WSDetalle.Cell(14, 2).Value = Drow("Codigo").ToString
WSDetalle.Cell(14, 3).Value = Drow("PS").ToString
WSDetalle.Cell(14, 4).Value = Drow("Abreviatura").ToString
WSDetalle.Cell(12, 3).Value = "" 'Concepto
WSDetalle.Cell(14, 10).Value = Drow("CantidadActual").ToString.ToDecimal
WSDetalle.Cell(14, 11).Value = Drow("CantidadActual").ToString.ToDecimal
'WSDetalle.Cell(61, 6).Value = "" 'Empresario
WSDetalle.Cell(61, 9).Value = Drow("Nombre").ToString 'Cliente
Dim objContrato As New ClsContratos
Dim DTArchivos As New DataTable
If objContrato.GetContratosAvanceAnexos(Drow("CveContratoDetalle").ToString.ToEntero, Drow("Fecha").ToString, UsuarioActual.CveUsuario, CveEstimacion:=CveEstimacion) Then
DTArchivos = objContrato.DtResultados
End If
objContrato.Dispose()
Dim Imagenes As New List(Of ClosedXML.Excel.Drawings.IXLPicture)
Dim CurrectRowImg As Integer = 19 'Row 19 primera imggen
Dim RowH As Double = WSDetalle.Row(19).Height
For Each drowArchivos As DataRow In DTArchivos.Rows
Dim Archivo As String = ""
Archivo = drowArchivos("Archivo").ToString
Dim RutaArchivo As String = $"{UsuarioActual.Empresa.Ruta}\Contrato\{CveContrato}\Anexos\{Archivo}"
If File.Exists(RutaArchivo) Then
Dim Imagen = WSDetalle.AddPicture(RutaArchivo).MoveTo(WSDetalle.Cell(CurrectRowImg, 3))
Imagen.Scale(WSDetalle.Column(3).Width / (Imagen.OriginalWidth * 0.145D))
Dim ImgWidth As Double = Imagen.Height
Dim nRowmas As Integer = (ImgWidth / RowH).ToEntero
CurrectRowImg = CurrectRowImg + nRowmas
Imagenes.Add(Imagen)
End If
Next
WBAnexo.Worksheet(2).CopyTo(WBAnexoSalvar, If(Drow("Codigo").ToString.Trim.Length > 0, Drow("Codigo").ToString, Drow("CvePS").ToString))
For Each img As ClosedXML.Excel.Drawings.IXLPicture In Imagenes
img.Delete()
Next
End If
Next
Dim msB = New MemoryStream()
WBAnexoSalvar.SaveAs(msB)
Dim BB As Byte() = msB.ToArray
msB.Dispose()
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition", "attachment; filename=Anexo_Estimacion" & NumeroEstimacion & ".xlsx")
Response.ContentType = "application/vnd.ms-excel"
Response.BinaryWrite(BB)
Response.End()
Else
Alert("No se encontraron datos des control", TipoMensaje.MsgAdvertencia)
End If
End Sub
#End Region

View File

@@ -1,6 +1,7 @@
Imports Extensiones
Imports System.Data
Imports System.IO
Imports ClosedXML.Excel
Partial Class RepContratosObraAvancesDetalle
Inherits ClsPaginas
@@ -152,7 +153,8 @@ Partial Class RepContratosObraAvancesDetalle
WSControl.Cell(17, 2).Value = NumeroEstimacion 'Estimacion
WSControl.Cell(20, 9).Value = FechaEstimacion.ToString("dd/MM/yyyy") 'Fecha estimacion
WSControl.Cell(19, 8).Value = "$ " & DtControl.SUM("Total").ToString("###,###,###.00") 'Total
WSControl.Cell(19, 8).Value = "$ " & DtControl.SUM("Importe").ToString("###,###,###.00") 'Total
WSControl.Cell(19, 8).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
WSControl.Cell(20, 6).Value = NumeroContrato
@@ -163,7 +165,7 @@ Partial Class RepContratosObraAvancesDetalle
WSControl.Cell(22, 7).Value = "" 'Presupuesto segun contrato
WSControl.Cell(19, 5).Value = "" 'Contrtatista
Dim RowCountControl As Integer = 1
For Each Drow As DataRow In DtControl.Rows
@@ -177,7 +179,121 @@ Partial Class RepContratosObraAvancesDetalle
WSControl.Cell(CuerrentRow, 8).Value = Drow("PU").ToString.ToDecimal
WSControl.Cell(CuerrentRow, 9).Value = Drow("Total").ToString.ToDecimal
WSControl.Cell(CuerrentRow, 9).Style.NumberFormat.Format = "$ ###,###,###.00"
WSControl.Cell(CuerrentRow, 1).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 2).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 3).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 4).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 5).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 6).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 7).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 8).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 9).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 1).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 2).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 3).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 4).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 5).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 6).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 7).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 8).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow, 9).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
'ultimo Row
If DtControl.Rows.Count = RowCountControl Then
WSControl.Cell(CuerrentRow + 1, 1).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 2).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 3).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 4).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 5).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 6).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 7).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 8).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 9).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 1).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 2).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 3).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 4).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 5).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 6).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 7).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 8).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
WSControl.Cell(CuerrentRow + 1, 9).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
WSControl.Cell(CuerrentRow + 1, 8).Value = "Total:"
WSControl.Cell(CuerrentRow + 1, 8).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
WSControl.Cell(CuerrentRow + 1, 8).Style.Font.Bold = True
WSControl.Cell(CuerrentRow + 1, 9).Value = DtControl.SUM("Total")
WSControl.Cell(CuerrentRow + 1, 9).Style.Font.Bold = True
WSControl.Cell(CuerrentRow + 1, 9).Style.NumberFormat.Format = "$ ###,###,###.00"
Dim range = WSControl.Range($"A{CuerrentRow + 3}:D{CuerrentRow + 3}")
range.Merge()
range.Style.Border.TopBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range = WSControl.Range($"E{CuerrentRow + 3}:I{CuerrentRow + 3}")
range.Merge()
range.Style.Border.TopBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range = WSControl.Range($"A{CuerrentRow + 4}:D{CuerrentRow + 4}")
range.Merge()
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range.Value = "ING. WALTER ROBERTO VILLEGAS LARES"
range = WSControl.Range($"E{CuerrentRow + 4}:I{CuerrentRow + 4}")
range.Merge()
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range.Value = "C. SALVADOR SUAREZ"
range = WSControl.Range($"A{CuerrentRow + 5}:D{CuerrentRow + 5}")
range.Merge()
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range.Value = "SERVICIOS ELECTRICOS Y CONTROL DE HERMOSILLO S.A. DE C.V."
range.Style.Font.Bold = True
range = WSControl.Range($"E{CuerrentRow + 5}:I{CuerrentRow + 5}")
range.Merge()
range.Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Thin
range.Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
range.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
range.Value = "GASERVICIO MATAMOROS SA DE CV"
range.Style.Font.Bold = True
End If
CuerrentRow = CuerrentRow + 1
RowCountControl = RowCountControl + 1
Next
WBAnexo.Worksheet(1).CopyTo(WBAnexoSalvar, "CONTROL")
@@ -280,13 +396,13 @@ Partial Class RepContratosObraAvancesDetalle
End Sub
Public Function GetStream(excelWorkbook As ClosedXML.Excel.XLWorkbook) As Stream
'Public Function GetStream(excelWorkbook As ClosedXML.Excel.XLWorkbook) As Stream
Dim fs = New MemoryStream()
excelWorkbook.SaveAs(fs)
fs.Position = 0
Return fs
' Dim fs = New MemoryStream()
' excelWorkbook.SaveAs(fs)
' fs.Position = 0
' Return fs
End Function
'End Function
End Class