diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb index 74b4d1432..c716f91b6 100644 --- a/App_Code/ClsContratos.vb +++ b/App_Code/ClsContratos.vb @@ -182,11 +182,16 @@ Public Class ClsContratos Public Property EstatusFianza As Integer Public Property Folio As Integer Public Property FechaVenc As Date - Public Property AplicaImpuestosLocales As Boolean - - + Public Property AplicaImpuestosLocales As Boolean + Public Property CveEstimacionActual As Integer + Public Property NumeroEstimacionActual As Integer + + + + + #End Region - + #Region " C O N T R A T O S " Public Function GetContratosReporte(CveEmpresa As Integer, FechaInicial As DateTime, FechaFinal As DateTime) As Boolean Dim Retorno As Boolean = False @@ -1276,15 +1281,15 @@ Public Class ClsContratos Return Retorno End Function - Public Function GetContratosAvanceAnexos(CveContratoDetalle As Integer, fecha As String, CveUsuario As Integer, Optional CveEstimacion As Integer = -1) As Boolean + Public Function GetContratosAvanceAnexos(CveContratoDetalle As Integer, CveUsuario As Integer, Optional CveEstimacion As Integer = -1, Optional CveContratoAvance As Integer = -1) As Boolean Dim Retorno = False DataAdapter("PA_Con_ContratosAvanceAnexos") With SqlAdapter.SelectCommand.Parameters - .Add("@CveContratoDetalle", SqlDbType.Int).Value = CveContratoDetalle - .Add("@Fecha", SqlDbType.Date).Value = fecha + .Add("@CveContratoDetalle", SqlDbType.Int).Value = CveContratoDetalle .Add("@CveUsuario", SqlDbType.Float).Value = CveUsuario .Add("@CveEstimacion", SqlDbType.Float).Value = CveEstimacion + .Add("@CveContratoAvance", SqlDbType.Float).Value = CveContratoAvance End With Try @@ -1300,13 +1305,49 @@ Public Class ClsContratos #Region "ESTIMACION" - Public Function GetContratosAvanceEstimacion(CveContrato As Integer, CveEmpresa As Integer) As Boolean + + Public Function AddContratosObraAvance(CveContrato As Integer, CveContratoDetalle As Integer, Cantidad As Double, Fecha As Date, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + CveEstimacionActual = 0 + + DataAdapter("PA_Con_ContratosObraAvanceAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveContratoDetalle", SqlDbType.Int).Value = CveContratoDetalle + .Add("@Cantidad", SqlDbType.Int).Value = Cantidad + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveEstimacionActual", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@NumeroEstimacionActual", SqlDbType.Int).Direction = ParameterDirection.Output + + End With + + Try + SqlAdapter.Fill(Data) + + CveEstimacionActual = SqlAdapter.SelectCommand.Parameters("@CveEstimacionActual").Value.ToString.ToEntero + NumeroEstimacionActual = SqlAdapter.SelectCommand.Parameters("@NumeroEstimacionActual").Value.ToString.ToEntero + + Retorno = True + + Catch ex As Exception + OnError("Ocurrió un error al agregar el avance.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function GetContratosAvanceEstimacion(CveContrato As Integer, CveEmpresa As Integer, CveEstimacion As Integer) As Boolean Dim Retorno = False DataAdapter("PA_Con_ContratosAvanceEstimacionGet") With SqlAdapter.SelectCommand.Parameters .Add("@CveContrato", SqlDbType.Int).Value = CveContrato .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveEstimacion", SqlDbType.Int).Value = CveEstimacion End With Try @@ -1374,6 +1415,27 @@ Public Class ClsContratos + Public Function RemoveContratosAvance(CveContratoAvance As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Con_ContratosAvanceRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveContratoAvance", SqlDbType.Int).Value = CveContratoAvance + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el avance.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + + End Function + + #End Region #Region "CONTRATOS OBRA COMPRAS" diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index b1d582319..58f52703a 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5020,6 +5020,9 @@ Public Class ClsPaginas PaginaDict.Add("/Contratos/RepContratosObraAvances.aspx".ToUpper(), -1) PaginaDict.Add("/Contratos/RepContratosObraAvancesDetalle.aspx".ToUpper(), -1) PaginaDict.Add("/Contratos/RepContratosObraAvancesPartida.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/ContratoObraAutorizacion.aspx".ToUpper(), -1) + + 'Orden Produccion' diff --git a/Contratos/ContratoAvance.aspx b/Contratos/ContratoAvance.aspx index 45bf7c3d0..f52875650 100644 --- a/Contratos/ContratoAvance.aspx +++ b/Contratos/ContratoAvance.aspx @@ -63,11 +63,11 @@
- +
-
+
@@ -117,6 +117,7 @@ + Producto / Servicio @@ -124,106 +125,114 @@ Ultimo Avance Levantamiento Anexo +
-
+
- - - - - - - - - - - <%# Eval("Cantidad", "{0:N2}")%> - - - - - <%# Eval("Importe", "{0:N2}")%> - - - - - <%# Eval("Cantidad_Ultima", "{0:N2}")%> - - - - - <%# Eval("Importe_Ultima", "{0:N2}")%> - - - - - - - - - - - - - - - - - - <%-- --%> - - - - - - - - - - - + + + + + + + + -
+ + + <%# Eval("Abreviatura")%> + + + + + + <%# Eval("Cantidad", "{0:N2}")%> + + + + + + <%# Eval("Importe", "{0:N2}")%> + + + + + <%# Eval("Cantidad_Ultima", "{0:N2}")%> + + + + + <%# Eval("Importe_Ultima", "{0:N2}")%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-
+
@@ -234,7 +243,7 @@ - + @@ -254,7 +263,7 @@
- +
diff --git a/Contratos/ContratoAvance.aspx.vb b/Contratos/ContratoAvance.aspx.vb index 451b2c4a4..66c961842 100644 --- a/Contratos/ContratoAvance.aspx.vb +++ b/Contratos/ContratoAvance.aspx.vb @@ -91,16 +91,43 @@ Partial Class Contratos_ContratoAvance End Property + Property CveEstimacionActual As Integer + Get + If ViewState("CveEstimacionActual") Is Nothing Then + Return -1 + Else + Return ViewState("CveEstimacionActual").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveEstimacionActual") = value + End Set + End Property + + Property NuemeroEstimacionActual As Integer + Get + If ViewState("NuemeroEstimacionActual") Is Nothing Then + Return -1 + Else + Return ViewState("NuemeroEstimacionActual").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("NuemeroEstimacionActual") = value + End Set + End Property + + + #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then + BtnGuardar.Visible = False - CargaContrato() - End If End Sub @@ -112,54 +139,34 @@ Partial Class Contratos_ContratoAvance DdlContratos.DataBind() DDlContratosEstimaciones.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}")) - DDlContratosEstimaciones.DataBind() - - - CargaddlAvance() - End Sub - - Protected Sub DdlContratos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlContratos.SelectedIndexChanged - CargaddlAvance() - End Sub - Private Sub CargaddlAvance() - DdlAvances.Items.Clear() - Dim ObjContratos As New ClsContratos() - If ObjContratos.GetContratosAvanceFecha(DdlContratos.SelectedValue.ToEntero, 2) Then - DdlAvances.DataSource = ObjContratos.DtResultados - End If - ObjContratos.Dispose() - DdlAvances.DataBind() - DdlAvances.Items.Insert(0, New ListItem(" ---- ", "-1")) + DDlContratosEstimaciones.DataBind() 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 - Dim ObjContratos As New ClsContratos() - If DdlAvances.SelectedValue = "-1" Then - If ObjContratos.GetContratosAvanceTodos(CveContrato, 2) Then - fecha = "" - DtDatos = ObjContratos.DtResultados - If ObjContratos.DtResultados.Rows.Count > 0 Then - BtnGuardar.Visible = True + Dim ObjContratos As New ClsContratos() - End If - End If - Else - If ObjContratos.GetContratosAvanceHistoricos(CveContrato, 2, DdlAvances.SelectedValue) Then - fecha = DdlAvances.SelectedValue - DtDatos = ObjContratos.DtResultados - BtnGuardar.Visible = False + If ObjContratos.GetContratosAvanceTodos(CveContrato, 2) Then + fecha = "" + DtDatos = ObjContratos.DtResultados + If ObjContratos.DtResultados.Rows.Count > 0 Then + BtnGuardar.Visible = True + End If + End If - End If - End If ObjContratos.Dispose() CargaGrid() + End Sub #Region "GV" @@ -175,7 +182,8 @@ Partial Class Contratos_ContratoAvance Alert("no se encontraron productos en el presupuesto") End If End Sub - Protected Sub GV_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles Gv.RowDataBound + Protected Sub GV_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles Gv.RowDataBound + If e.Row.RowIndex > -1 Then e.Row.FCTextBox("TxtCantidad").Visible = (fecha = "") @@ -209,10 +217,12 @@ Partial Class Contratos_ContratoAvance LnkAnexo.Visible = True End If - End If - - - + Dim LnkGuardarAvance As LinkButton = e.Row.FCLinkButton("LnkGuardarAvance") + LnkGuardarAvance.Visible = True + + End If + + End If End Sub Protected Sub GetAnexos(sender As Object, e As System.EventArgs) @@ -226,7 +236,7 @@ Partial Class Contratos_ContratoAvance Dim gvr As GridViewRow = DirectCast(btn.NamingContainer, GridViewRow) Dim CveContratoDetalle As Integer = gvr.DataKey("CveContratoDetalle").ToString.ToEntero Dim objContrato As New ClsContratos - If objContrato.GetContratosAvanceAnexos(CveContratoDetalle, fecha, UsuarioActual.CveUsuario) Then + If objContrato.GetContratosAvanceAnexos(CveContratoDetalle, UsuarioActual.CveUsuario, -1) Then GvAnexos.DataSource = objContrato.DtResultados GvAnexos.DataBind() GvAnexos.Visible = True @@ -277,10 +287,13 @@ Partial Class Contratos_ContratoAvance Dim ObjContratos As New ClsContratos ObjContratos.IniciaTransacSQL() + Dim TieneError = False Dim CveContratoDetalle As Integer - Dim Cantidad As Double - 'Dim filesgral As List(Of Archivo) = AnexoGral.getfiles().Archivos + Dim Cantidad As Double + + Dim NumeroEstimacionActual As Integer = 0 + Dim guardarArchivos As New List(Of Archivo) For Each gvr As GridViewRow In Gv.Rows @@ -292,19 +305,14 @@ Partial Class Contratos_ContratoAvance Cantidad = gvr.FCTextBox("TxtCantidad").Text.ToDouble If Cantidad > 0 Then - If ObjContratos.AddContratosAvance(CveContratoDetalle, Cantidad, TxtFecha.Text.ToDateTime, UsuarioActual.CveUsuario) Then + + If ObjContratos.AddContratosObraAvance(DdlContratos.SelectedValue.ToEntero, CveContratoDetalle, Cantidad, TxtFecha.Text.ToDateTime, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + + NumeroEstimacionActual = ObjContratos.NumeroEstimacionActual Dim CveContratoAvance As Integer = ObjContratos.DtResultados.Rows(0)("CveContratoAvance").ToString.ToEntero - Dim files As List(Of Archivo) = gvr.FCTextBox("TXTAnexo").getfiles().Archivos - - 'For Each fileItem As Archivo In filesgral 'GENERAL - ' guardarArchivos.Add(fileItem) - ' If Not ObjContratos.AddContratosAvanceAnexo(CveContratoAvance, fileItem.filename, UsuarioActual.CveUsuario) Then - ' TieneError = True - ' Exit For - ' End If - 'Next - + Dim files As List(Of Archivo) = gvr.FCTextBox("TXTAnexo").getfiles().Archivos + For Each fileItem As Archivo In files guardarArchivos.Add(fileItem) If Not ObjContratos.AddContratosAvanceAnexo(CveContratoAvance, fileItem.filename, UsuarioActual.CveUsuario) Then @@ -326,26 +334,100 @@ Partial Class Contratos_ContratoAvance If TieneError Then ObjContratos.RollBack() Alert("No se logro guardar el Presupuesto favor de intentarlo mas tarde o comuniquese con soporte", TipoMensaje.MsgAdvertencia) - Else + Else + Dim urlsave As String = String.Format("Empresas\{0}\Contrato\{1}\Anexos", UsuarioActual.CveEmpresa, CveContrato) - 'For Each fileItem As Archivo In filesgral - ' fileItem.filename.FilesMove(fileItem.filename, urlsave) - 'Next - For Each fileItem As Archivo In guardarArchivos fileItem.filename.FilesMove(fileItem.filename.Replace($".{fileItem.Extencion}", ""), urlsave) - Next + Next + + ObjContratos.Commit() - Alert("se guardo Correctamente") + + 'Alert("se avance guardado correctamente") + Alert("se avance guardado correctamente en estimacion numero " & NumeroEstimacionActual) + End If 'AnexoGral.Text = "[]" ObjContratos.Dispose() - CargaddlAvance() + 'CargaddlAvance() CargaDatosAvance() End Sub + Protected Sub LnkGuardarAvance_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + + Dim ObjContratos As New ClsContratos + ObjContratos.IniciaTransacSQL() + Dim TieneError = False + Dim CveContratoDetalle As Integer + Dim Cantidad As Double + Dim guardarArchivos As New List(Of Archivo) + + Dim NumeroEstimacionActual As Integer = 0 + + CveContratoDetalle = GvRow.DataKey("CveContratoDetalle").ToEntero + + If CveContratoDetalle > 0 Then + + Cantidad = GvRow.FCTextBox("TxtCantidad").Text.ToDouble + + If Cantidad > 0 Then + If ObjContratos.AddContratosObraAvance(DdlContratos.SelectedValue.ToEntero, CveContratoDetalle, Cantidad, TxtFecha.Text.ToDateTime, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + NumeroEstimacionActual = ObjContratos.NumeroEstimacionActual + + Dim CveContratoAvance As Integer = ObjContratos.DtResultados.Rows(0)("CveContratoAvance").ToString.ToEntero + Dim files As List(Of Archivo) = GvRow.FCTextBox("TXTAnexo").getfiles().Archivos + + For Each fileItem As Archivo In files + guardarArchivos.Add(fileItem) + If Not ObjContratos.AddContratosAvanceAnexo(CveContratoAvance, fileItem.filename, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + Next + + Else + TieneError = True + End If + + + If TieneError Then + ObjContratos.RollBack() + Alert("No se logro guardar el Presupuesto favor de intentarlo mas tarde o comuniquese con soporte", TipoMensaje.MsgAdvertencia) + Else + + Dim urlsave As String = String.Format("Empresas\{0}\Contrato\{1}\Anexos", UsuarioActual.CveEmpresa, CveContrato) + For Each fileItem As Archivo In guardarArchivos + fileItem.filename.FilesMove(fileItem.filename.Replace($".{fileItem.Extencion}", ""), urlsave) + Next + ObjContratos.Commit() + + 'Alert("se avance guardado correctamente") + Alert("se avance guardado correctamente en estimacion numero " & NumeroEstimacionActual) + End If + + + + + End If + Else + ObjContratos.RollBack() + End If + + + + + ObjContratos.Dispose() + CargaDatosAvance() + + End Sub + + #Region "ESTIMACION" @@ -355,9 +437,9 @@ Partial Class Contratos_ContratoAvance Dim ObjContratos As New ClsContratos() Dim DTEstimaciones As New DataTable + Dim NumeroEstimacionActual As Integer = 0 - - If ObjContratos.GetContratosAvanceEstimacion(DDlContratosEstimaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjContratos.GetContratosAvanceEstimacion(DDlContratosEstimaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1) Then DTEstimaciones = ObjContratos.DtResultados CveContratoEstimacion = DDlContratosEstimaciones.SelectedValue.ToEntero @@ -465,7 +547,6 @@ Partial Class Contratos_ContratoAvance 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" @@ -683,7 +764,7 @@ Partial Class Contratos_ContratoAvance 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 + If objContrato.GetContratosAvanceAnexos(Drow("CveContratoDetalle").ToString.ToEntero, UsuarioActual.CveUsuario, CveEstimacion:=CveEstimacion) Then DTArchivos = objContrato.DtResultados End If objContrato.Dispose() @@ -748,6 +829,10 @@ Partial Class Contratos_ContratoAvance #End Region + + + + End Class diff --git a/Contratos/ContratoObra.aspx b/Contratos/ContratoObra.aspx index e3ccfab73..86f5165e3 100644 --- a/Contratos/ContratoObra.aspx +++ b/Contratos/ContratoObra.aspx @@ -110,17 +110,7 @@
- <%-- - - - - - - - - - - --%> + @@ -132,80 +122,169 @@ -<%-- - - -
-
- -
-
-
- -

Tipo de Contrato

-
-
-
-
-
-
-
-
-
-
- -
-
- -
-
-
-
-
Tipo Contrato:
-
- - -
-
-
-
-
- -
-
-
-
- -
-
-
-
- -
- -
- -
- -
- -
-
-
-
--%>
- + + + + + +
+ +
+
+ +
+ +
+ Contratos +

+ + +

+ +
+ +
+ Total Contratado +

+ $ +

+
+ +
+ +
+ +
+ +
+ +
+ + +
+
+
+ +
+ + + + +
+ Ventas +

+ + + + +

+ +
+ Porcentaje +

+ + + + +

+ +
+ +
+ +
+ +
+
+
+ +
+ + <%--76% Avance--%> + +
+ +
+
Avance
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+ + + + +
+ Interno +

+ + + + +

+ +
+ Porcentaje +

+ + + + +

+ +
+ + +
+ +
+ +
+
+
+
+ + <%--76% Avance--%> + +
+
+
Faltante
+
+ +
+
+
+
+
+ +
+ +
+
+ + <%-- + @@ -219,14 +298,20 @@
Importe Contratado: $ - Facturado: $
-
+
--%> + + + + + +
-
+
@@ -236,6 +321,12 @@
Datos del Contrato
+ + + + + +
@@ -306,187 +397,8 @@
- <%--
- -
- -
-
-
- -
- - - -
-
-
- -
- - - -
-
-
- -
- - -
-
--%> - - - -
-
-
- -
- - -
-
-
- -
-
-
-
-
- Proyecto: -
- - - - - - - -
-
-
- - : -
- - - <%--
-
- - - - - -
-
--%> - - <%--
- -
- -
-
--%> - -
-
-
-
-
- -
- -
-
-
-
-
- -
-
Información
-
-
-
-
- -
-
- - -
-
- - - -
-
-
-
- - -<%-- - -
-
- - - -
-
-
-
--%> - - - <%-- - -
-
- - - -
-
-
-
- - - - -
-
- - - -
-
-
-
- - - -
-
-
-
- - - -
-
--%> - - -
+
@@ -526,6 +438,81 @@
+ + + + + +
+ + Proyecto: +
+ + + + + + + +
+
+ +
+ + + +
+ + +
+
+ + + +
+
+
+ + + +
+
+
+
+ +
+
Información
+
+
+ + + + + +
+
+ +
+
+ + + +
+
+ + + +
+
+
+
+ + + +
@@ -563,18 +550,7 @@
- <%--
- -
- -
-
-
- -
- -
-
--%> +
@@ -604,9 +580,17 @@
-
+ -
+
+ +
+ + + +
+ +
@@ -624,54 +608,6 @@
- <%--
- -
- - - - - - -
-
--%> - - - <%-- - - --%>
@@ -679,59 +615,25 @@
- <%-- AGREGAR FIANZA --%> - <%--
-
-
-
-
- -
-
Fianzas
-
-
- -
-
-
-
-
+ -
- - - - - - - - - - - - - - - - - - - - - -
-
+ <%--
+
+
+
+ +
--%> - <%-- --%> -
-
+
+ +
+
@@ -751,14 +653,7 @@ - <%-- - Archivo - --%> - - <%-- - Archivo - --%> @@ -768,73 +663,11 @@
-
+
-
-
-
-
- - -
-
-
-
- <%--
-
-
-
-
- - -
-
- - Impuestos Locales: -
-
- -
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
--%> -
+
diff --git a/Contratos/ContratoObra.aspx.vb b/Contratos/ContratoObra.aspx.vb index 50310de8a..932c9a1c1 100644 --- a/Contratos/ContratoObra.aspx.vb +++ b/Contratos/ContratoObra.aspx.vb @@ -357,6 +357,40 @@ Partial Class Contratos_ContratoObra End Property + + Property TotalAvanceVentas As Decimal + Get + + If ViewState("TotalAvanceVentas") Is Nothing Then + Return 0D + Else + Return ViewState("TotalAvanceVentas").ToString.ToDecimal + End If + End Get + Set(value As Decimal) + ViewState("TotalAvanceVentas") = value + End Set + End Property + + + + Property TotalAvanceInterno As Decimal + Get + + If ViewState("TotalAvanceInterno") Is Nothing Then + Return 0D + Else + Return ViewState("TotalAvanceInterno").ToString.ToDecimal + End If + End Get + Set(value As Decimal) + ViewState("TotalAvanceInterno") = value + End Set + End Property + + + + #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load @@ -417,6 +451,8 @@ Partial Class Contratos_ContratoObra End If + Indicadores() + Else 'Configuración de Modalidad Insert LblFechaCaptura.Text = Now.ToShortDateString() @@ -440,7 +476,7 @@ Partial Class Contratos_ContratoObra CargaPS() CargaPSInsumos() ConfiguraTipos() - CargaDatosEncabezado() + 'CargaDatosEncabezado() End If @@ -620,9 +656,9 @@ Partial Class Contratos_ContratoObra DvTotal.Visible = True - If CveContrato > 0 AndAlso CveTipoContrato <> 25 Then - TableDatosCabecera.Visible = True - End If + 'If CveContrato > 0 AndAlso CveTipoContrato <> 25 Then + ' TableDatosCabecera.Visible = True + 'End If If CveTipoContrato = 25 Then @@ -638,9 +674,9 @@ Partial Class Contratos_ContratoObra DvTotal.Visible = True - If CveContrato > 0 AndAlso CveTipoContrato <> 25 Then - TableDatosCabecera.Visible = True - End If + 'If CveContrato > 0 AndAlso CveTipoContrato <> 25 Then + ' TableDatosCabecera.Visible = True + 'End If @@ -668,8 +704,8 @@ Partial Class Contratos_ContratoObra msjpresupuestos.Visible = False If ArchivoUpdate = ObjContratos.Archivo.ToString Then - LinkArchivo.Visible = True - LinkArchivo.HRef = String.Format("{0}{1}", Ruta, ObjContratos.Archivo.ToString) + 'LinkArchivo.Visible = True + 'LinkArchivo.HRef = String.Format("{0}{1}", Ruta, ObjContratos.Archivo.ToString) End If Titulo = $"{ObjContratos.NumeroContrato} - {ObjContratos.DescripcionContrato} ({ObjContratos.DtResultados.Rows(0)("ContratoTipo")})" TituloCorto = $"{ObjContratos.NumeroContrato} - {ObjContratos.DescripcionContrato} " @@ -719,7 +755,7 @@ Partial Class Contratos_ContratoObra TabPVInsumos.Visible = False RowEstatus.Visible = False TabPres.HeaderText = "Partidas" - TableDatosCabecera.Visible = False + 'TableDatosCabecera.Visible = False TabAvanveDocumento.Visible = False TabSistema.Visible = False TabContratosGastos.Visible = False @@ -862,9 +898,15 @@ Partial Class Contratos_ContratoObra UpGV.Update() UpGVInsumos.Update() - UPGVInt.Update() + UPGVInt.Update() + + + TotalAvanceVentas = TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").ToDecimal + TotalAvanceInterno = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").ToDecimal + LbTotalGeneral.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").FormatoNumero() LbTotalGeneralInsumos.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").FormatoNumero() + LbTotalGeneralInt.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").FormatoNumero() 'LblImporte.Text = "$" & TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").FormatoNumero() End If @@ -1116,7 +1158,7 @@ Partial Class Contratos_ContratoObra LblProyecto.Visible = True - LblCentroCosto.Text = LblSubProyectoTitulo.Text + 'LblCentroCosto.Text = LblSubProyectoTitulo.Text LblSubProyectoTitulo.Text = LblSubProyectoTitulo.Text & ":" 'If UsuarioActual.Empresa.GralSoloProyecto Then @@ -2841,22 +2883,22 @@ Partial Class Contratos_ContratoObra End If ObjVentas.Dispose() - End Sub - - - - - Public Sub CargaDatosEncabezado() - - TablaUtilidad.Visible = True - LblUtilidad.Text = $"$ {(SumaAvance - SumaGasto).ToString.FormatoNumero()}" - - If (SumaAvance - SumaGasto) < 0 Then LblUtilidad.ForeColor = Drawing.Color.Red - LblFacturado.Text = SumaAvance.FormatoNumero - LblPorFacturar.Text = (LblImporte.Text.ToDouble - SumaAvance).FormatoNumero - End Sub + + + + 'Public Sub CargaDatosEncabezado() + + ' TablaUtilidad.Visible = True + ' LblUtilidad.Text = $"$ {(SumaAvance - SumaGasto).ToString.FormatoNumero()}" + + ' If (SumaAvance - SumaGasto) < 0 Then LblUtilidad.ForeColor = Drawing.Color.Red + ' LblFacturado.Text = SumaAvance.FormatoNumero + ' LblPorFacturar.Text = (LblImporte.Text.ToDouble - SumaAvance).FormatoNumero + + 'End Sub + #End Region #End Region @@ -3063,176 +3105,10 @@ Partial Class Contratos_ContratoObra End While Return dataTable - End Function - - 'Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String) - ' Dim dt As New DataTable - ' dt = ReadExcelFile(Ruta + FileName, True) - ' Dim ErrorArchivo = False - - ' 'Dim Conexion As Odbc.OdbcConnection = Nothing - ' 'Try - ' ' Select Case Tipo - ' ' Case "EXCEL" - ' ' Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";") - ' ' Conexion.Open() - ' ' Dim cmd = Conexion.CreateCommand() - ' ' cmd.CommandType = CommandType.Text - ' ' cmd.CommandText = "SELECT * FROM [Hoja1$]" - ' ' Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) - ' ' DataAdapter.Fill(dt) - ' ' Case Else - ' ' Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError) - ' ' Exit Sub - ' ' End Select - ' 'Catch ex As Exception - ' ' ErrorArchivo = True - ' ' OnError("Ocurrio un error al leer el archivo
" & ex.Message, ex) - ' 'End Try - ' 'Conexion.Close() - ' If Not ErrorArchivo AndAlso dt IsNot Nothing Then - ' If Not dt.Columns(0).ColumnName = "OC Interna" Then - ' Alert("El nombre de la primera columna debe ser 'OC Interna'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' If Not dt.Columns(1).ColumnName = "Cantidad" Then - ' Alert("El nombre de la primera columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' If Not dt.Columns(2).ColumnName = "Clave Interna Cliente" Then - ' Alert("El nombre de la segunda columna debe ser 'Clave Interna'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' If Not dt.Columns(3).ColumnName = "Código" Then - ' Alert("El nombre de la tercera columna debe ser 'Código'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' If Not dt.Columns(4).ColumnName = "Código Barras" Then - ' Alert("El nombre de la cuarta columna debe ser 'Código Barras'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' If Not dt.Columns(5).ColumnName = "Producto/Servicio" Then - ' Alert("El nombre de la quinta columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' If Not dt.Columns(6).ColumnName = "UM" Then - ' Alert("El nombre de la sexta columna debe ser 'U.M'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' If Not dt.Columns(7).ColumnName = "Precio Unitario" Then - ' Alert("El nombre de la septima columna debe ser 'Precio Unitario'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - - ' dt.TableName = "Datos" - - ' If Not ErrorArchivo Then - ' NumRow = 1 - ' Dim RowNoEncontrados As String = String.Empty - ' Dim NumAgregados As Integer = 0 - ' For Each Row As DataRow In dt.Rows - ' Dim Cantidad As Integer = Row("Cantidad").ToString.ToEntero - ' Dim Codigo As String = Row("Código").ToString.Trim.ToUpper - ' Dim CodigoBarras As String = Row("Código Barras").ToString.Trim.ToUpper - ' Dim UM As String = Row("UM").ToString - ' Dim ClaveInterna As String = Row("Clave Interna Cliente").ToString.Trim.ToUpper - ' Dim OCInterna As String = Row("OC Interna").ToString.Trim.ToUpper - ' Dim ProductoServicio As String = Row("Producto/Servicio").ToString.Trim.ToUpper - ' Dim PrecioUnitario As Double = Row("Precio Unitario").ToString.ToDouble - ' Dim CvePS As Integer = 0 - ' Dim CveUM As Integer = 0 ' GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero - ' Dim CodigoPS As Integer = 0 - ' Dim Total As Double = (Cantidad * PrecioUnitario) - - - ' NumRow = NumRow + 1 - - ' If Codigo.Length > 0 Then - ' Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c) - ' If StrArray.Length > 0 Then - ' If CBool(StrArray(0)) = True Then - ' CvePS = StrArray(1).ToEntero - ' Else - ' RowNoEncontrados &= StrArray(1) & "<\BR>" - ' End If - ' End If - ' ElseIf CodigoBarras.Length > 0 Then - ' Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c) - ' If StrArray.Length > 0 Then - ' If CBool(StrArray(0)) = True Then - ' CvePS = StrArray(1).ToEntero - ' Else - ' RowNoEncontrados &= StrArray(1) & "<\BR>" - ' End If - ' End If - ' ElseIf ProductoServicio.Length > 0 Then - ' Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c) - ' If StrArray.Length > 0 Then - ' If CBool(StrArray(0)) = True Then - ' CvePS = StrArray(1).ToEntero - ' Else - ' RowNoEncontrados &= StrArray(1) & "<\BR>" - ' End If - ' End If - ' Else - ' RowNoEncontrados &= "<\BR>    - En la fila " & NumRow & " no se especificó código, código de barras ó descripción." - ' End If - ' CveUM = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveUnidadMedida", "").ToString.ToEntero - - ' If TmpDT IsNot Nothing AndAlso CvePS > 0 Then - ' Dim dr As DataRow = TmpDT.NewRow - ' dr("Cantidad") = Cantidad - ' dr("CantidadContratada") = Cantidad - ' dr("CveUM") = CveUM - ' dr("UM") = UM - ' dr("CveClasificacion") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveClasificacion", "").ToString.ToEntero - ' dr("Clasificacion") = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = '{dr("CveClasificacion")}'").ToString - ' dr("CvePS") = CvePS - ' dr("PS") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=dr("CvePS").ToString.ToEntero).FiltroPrimeroValor("PS", "").ToString - ' dr("CodigoPS") = dr("PS") - ' dr("PU") = PrecioUnitario - ' dr("Total") = Cantidad * PrecioUnitario - ' dr("CveTipoPresupuesto") = 2 - ' dr("NoIdentificacion") = ClaveInterna - ' dr("OCInterna") = OCInterna - ' dr("LimitarCantidad") = 0 - - ' If CvePS > 0 Then - ' Dim ObjContratos As New ClsContratos - ' If ObjContratos.AddContratosDetalle(CveContrato, dr("CvePS").ToString.ToEntero, dr("Cantidad").ToString.ToDouble, dr("PU").ToString.ToDouble, UsuarioActual.CveUsuario, dr("CveTipoPresupuesto").ToString.ToEntero, dr("NoIdentificacion").ToString, dr("LimitarCantidad").ToString.ToEntero = 1, dr("OCInterna").ToString) Then - ' Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con un precio ${3}.", dr("Cantidad"), dr("UM"), dr("PS"), dr("PU")) - ' guardarBitacora(msj) - ' dr("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle") - ' TmpDT.Rows.Add(dr) - ' Dim TotalRow = dr("Total").ToString.ToDouble - - ' CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2")) - ' LbTotalGeneral.Text = (LbTotalGeneral.Text.ToDouble + TotalRow).ToString.FormatoNumero - ' LblImporte.Text = LbTotalGeneral.Text - ' Else - ' Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError) - ' End If - ' ObjContratos.Dispose() - ' End If - - - ' End If - ' Next - ' 'Cargo el GridView - ' Gv.DataSource = TmpDT - ' Gv.DataBind() - ' UpGV.Update() - - - ' If RowNoEncontrados.Length > 0 Then - ' Alert("Los siguientes Productos o Servicios no se encontraron en la Base de Datos.<\BR>" & RowNoEncontrados, TipoMensaje.MsgAdvertencia) - ' Else - ' Alert("Se Cargaron " & NumRow & " Productos o Servicios correctamente.") - ' End If - ' End If - ' End If - 'End Sub - + End Function + + + Private Function GetPS(Opt As String, Valor As String) As String Dim StrReturn As String = String.Empty Dim CvePS As Integer = 0 @@ -3260,34 +3136,7 @@ Partial Class Contratos_ContratoObra #End Region -#Region " GPS " - 'Private Sub CargaCuentasEquipos() - ' Dim GPS As New ClsGPS - ' If GPS.DispositivosGet(-1, -1, DdlCliente.SelectedValue.ToEntero) Then - ' DdlCuentaEquipo.DataSource = GPS.DtResultados - ' Else - ' DdlCuentaEquipo.DataSource = Nothing - ' End If - ' GPS.Dispose() - ' DdlCuentaEquipo.DataBind() - ' UpGral.Update() - - 'End Sub - - 'Private Sub CargaPeriodos() - ' Dim ObjContratos As New ClsContratos - ' If ObjContratos.GetPeriodos(-1, UsuarioActual.CveEmpresa) Then - ' DtPeriodo = ObjContratos.DtResultados - ' Else - ' DtPeriodo = Nothing - ' End If - ' DdlPeriodo.DataSource = DtPeriodo - ' ObjContratos.Dispose() - ' DdlPeriodo.DataBind() - ' UpGral.Update() - 'End Sub -#End Region #Region " IMPRESION " @@ -3322,57 +3171,7 @@ Partial Class Contratos_ContratoObra ImprimirPDF("Empresas/Grales/Formatos/RepContratoAvanceDocumento.rdlc", dt, params, $"{Nombre}-AvanceDocumento", Formato:=Formato) End Sub - 'Private Sub LBImprimirInformacionG_Click(sender As Object, e As EventArgs) Handles LBImprimirInformacionG.Click - ' Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) - ' Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) - ' Dim dt As DataTable = DtAvanceDocumento - ' Dim params As New List(Of ReportParameter) - ' params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) - ' params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - ' params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) - ' params.Add(New ReportParameter("Contrato", Titulo)) - ' 'DATOS DEL CONTRATO - ' params.Add(New ReportParameter("NoContrato", TxtNumeroContrato.Text.Trim)) - ' params.Add(New ReportParameter("Descripcion", TxtDescripcionContrato.Text.Trim)) - ' params.Add(New ReportParameter("Proveedor", If(TrProveedor.Visible = True, DdlContratista.SelectedItem.Text.Trim, "-"))) - ' params.Add(New ReportParameter("Ubicacion", TxtUbicacion.Text.Trim)) - ' params.Add(New ReportParameter("Responsable", TxtResponsable.Text.Trim)) - ' params.Add(New ReportParameter("Almacen", "-")) - ' params.Add(New ReportParameter("Porcentaje", "-")) - ' 'CENTRO DE COSTOS - ' params.Add(New ReportParameter("Proyecto", If(DVddlproyecto.Visible = True, DdlProyecto.SelectedItem.Text.Trim, "-"))) - ' params.Add(New ReportParameter("SubProyecto", CveSubProyecto.ToString)) - ' params.Add(New ReportParameter("Addendum", "")) - ' 'INFORMACION - ' params.Add(New ReportParameter("Cliente", If(TrCliente.Visible = True, DdlCliente.SelectedItem.Text.Trim, "-"))) - ' params.Add(New ReportParameter("Sucursal", If(TrClienteSucursal.Visible = True, DdlSucursalCliente.SelectedItem.Text.Trim, "-"))) - ' params.Add(New ReportParameter("FechaInicial", TxtFechaInicial.Text.Trim)) - ' params.Add(New ReportParameter("FechaFinal", TxtFechaFinal.Text.Trim)) - ' params.Add(New ReportParameter("Moneda", DdlMoneda.SelectedItem.Text.Trim)) - ' params.Add(New ReportParameter("TipoCambio", If(tipoCambio.Visible = True, TxtTipoCambio.Text.Trim, "-"))) - ' params.Add(New ReportParameter("IVA", TxtPorIVA.Text.Trim)) - ' params.Add(New ReportParameter("Anticipo", TxtPorAnticipo.Text.Trim)) - ' params.Add(New ReportParameter("Amortizacion", TxtPorAmortizacionAnticipo.Text.Trim)) - ' params.Add(New ReportParameter("Garantia", TxtPorGarantia.Text.Trim)) - ' params.Add(New ReportParameter("Minimo", "-")) - ' params.Add(New ReportParameter("Maximo", "-")) - ' params.Add(New ReportParameter("Total", If(DvTotal.Visible = True, TxtTotal.Text.Trim, "-"))) - ' 'Estatus - ' params.Add(New ReportParameter("Estatus", DdlEstatus.SelectedItem.Text.Trim)) - ' params.Add(New ReportParameter("TipoGarantia", "")) - ' params.Add(New ReportParameter("EstatusFianza", "")) - ' params.Add(New ReportParameter("Folio", "0")) - ' params.Add(New ReportParameter("FechaVencimiento", "")) - - ' If Imagen.Exists Then - ' params.Add(New ReportParameter("LogoPath", logouri)) - ' Else - ' params.Add(New ReportParameter("LogoPath", "")) - ' End If - ' ImprimirPDF("Empresas/Grales/Formatos/Contrato.rdlc", dt, params, $"Contrato-{Titulo}", Formato:="PDF") - - 'End Sub #End Region @@ -3384,10 +3183,10 @@ Partial Class Contratos_ContratoObra Private Sub GenerarPDFGastos(Optional Formato As String = "PDF") Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) - Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) - Dim UtilidadGastos As String = IIf(LblUtilidad.Text <> "", LblUtilidad.Text, "-").ToString - - + Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + ' Dim UtilidadGastos As String = IIf(LblUtilidad.Text <> "", LblUtilidad.Text, "-").ToString + + Dim dt As DataTable = DtGastos Dim params As New List(Of ReportParameter) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) @@ -3400,9 +3199,9 @@ Partial Class Contratos_ContratoObra params.Add(New ReportParameter("FechaInicio", TxtFechaInicial.Text.Trim)) params.Add(New ReportParameter("FechaFin", TxtFechaFinal.Text.Trim)) params.Add(New ReportParameter("TipoContrato", TipoDocumento)) - params.Add(New ReportParameter("TotalContrato", LblImporte.Text)) - params.Add(New ReportParameter("Utilidad", UtilidadGastos)) - + params.Add(New ReportParameter("TotalContrato", LblImporte.Text)) + ' params.Add(New ReportParameter("Utilidad", UtilidadGastos)) + If Imagen.Exists Then params.Add(New ReportParameter("LogoPath", logouri)) Else @@ -3898,59 +3697,12 @@ Partial Class Contratos_ContratoObra LnkDescargar.Visible = False 'BtnGuardarFianza.Text = "Guardar" UPModalFianza.Update() - Me.RegistraScript("$('#DvModalFianza').modal();") - 'GvFianzas.DataSource = DtTmpFianzas - 'GvFianzas.DataBind() - 'UpGvFianzas.Update() - End Sub - 'Protected Sub BtnGuardarFianza_Click(sender As Object, e As EventArgs) - - ' Dim dr As DataRow = DtTmpFianzas.NewRow() - - ' Dim Folio As String = txtFolioFianza.Text - ' Dim CveEstatus As Integer = DdlFianza.SelectedValue.ToEntero() - ' Dim Estatus As String = DdlFianza.SelectedItem.Text - - ' Dim TieneError As Boolean = False - - ' Dim Adjunto As String = "" - ' If TxtModalAdjuntoArchivo.getfiles.Archivos.Count > 0 Then - ' Dim ArchivoAdjunto As Archivo = TxtModalAdjuntoArchivo.getfiles.Archivos(0) - ' Adjunto = ArchivoAdjunto.filenameO - ' End If - - - ' If EsEditarFianza Then - ' DtTmpFianzas.Rows.RemoveAt(IndexFianzaEditar) - ' dr("CveContratoFianza") = GvFianzas.Rows(IndexFianzaEditar).DataKey("CveContratoFianza").ToString - ' dr("Folio") = Folio - ' dr("EstatusFianza") = Estatus - ' dr("CveEstatusFianza") = CveEstatus - ' dr("FechaVencimiento") = txtFechaVenFianza.Text - ' dr("Adjunto") = If(Adjunto = "", GvFianzas.Rows(IndexFianzaEditar).DataKey("Adjunto").ToString, Adjunto) - ' Else - ' dr("CveContratoFianza") = "-1" - ' dr("Folio") = Folio - ' dr("EstatusFianza") = Estatus - ' dr("CveEstatusFianza") = CveEstatus - ' dr("FechaVencimiento") = txtFechaVenFianza.Text - ' dr("Adjunto") = Adjunto - ' End If - - ' DtTmpFianzas.Rows.Add(dr) - ' GuardaAdjunto($"{Folio} - {txtFechaVenFianza.Text}") - - ' GvFianzas.DataSource = DtTmpFianzas - ' GvFianzas.DataBind() - ' UpGvFianzas.Update() - - ' LimpiarCamposModalFianzas() - ' Me.RegistraScript("$('#DvModalFianza').modal('hide');") - - 'End Sub - - - + Me.RegistraScript("$('#DvModalFianza').modal();") + + End Sub + + + Private Sub GuardaAdjunto(FolioFechaVencimiento As String) If Not TxtModalAdjuntoArchivo.getfiles.Archivos.Count > 0 Then Exit Sub @@ -3972,39 +3724,13 @@ Partial Class Contratos_ContratoObra Catch ex As Exception Alert("Ocurrió un error al guardar el archivo Adjunto. Por favor vuelva a intentar.", TipoMensaje.MsgError) End Try - End Sub - 'Private Sub DescargarAdjunto() - ' Dim filename As String = GvFianzas.Rows(IndexFianzaEditar).DataKey("Adjunto").ToString - ' If Not String.IsNullOrEmpty(filename) Then - ' Dim rutaAplicacion As String = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath) - ' Dim Path As String = String.Format("{0}\\{1}\\{2}\\{3}", UsuarioActual.Empresa.Ruta, "Contratos", "Fianzas", $"{GvFianzas.Rows(IndexFianzaEditar).DataKey("Folio").ToString} - {GvFianzas.Rows(IndexFianzaEditar).DataKey("FechaVencimiento").ToDate.ToShortDateString}") - ' Dim ArchivoDestino As String = String.Format("{0}\\{1}", Path, GvFianzas.Rows(IndexFianzaEditar).DataKey("Adjunto").ToString) - ' Dim toDownload As System.IO.FileInfo = New System.IO.FileInfo(ArchivoDestino) - ' If toDownload.Exists Then - ' Response.ClearContent() - ' Response.ClearHeaders() - ' Response.AddHeader("Content-Disposition", "attachment; filename=" + filename) - ' Response.ContentType = "application/octet-stream" - ' Response.WriteFile(ArchivoDestino) - ' Response.Flush() - ' Response.Close() - ' Response.End() - ' HttpContext.Current.ApplicationInstance.CompleteRequest() - ' End If - ' End If - 'End Sub - + End Sub + + Protected Sub LnkDescargar_Click(sender As Object, e As EventArgs) 'DescargarAdjunto() - End Sub - 'Protected Sub GvFianzas_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) - - ' DtTmpFianzas.Rows.RemoveAt(e.RowIndex) - ' GvFianzas.DataSource = DtTmpFianzas - ' GvFianzas.DataBind() - ' UpGvFianzas.Update() - - 'End Sub + End Sub + Protected Sub imgEFianzaGv_Click(sender As Object, e As EventArgs) LimpiarCamposModalFianzas() EsEditarFianza = True @@ -4018,13 +3744,11 @@ Partial Class Contratos_ContratoObra txtFechaVenFianza.Text = GvRow.DataKey("FechaVencimiento").ToString() LnkDescargar.Visible = GvRow.DataKey("Adjunto").ToString <> "" - txth4Fianza.InnerText = "Editar Fianza" - 'BtnGuardarFianza.Text = "Actualizar" + txth4Fianza.InnerText = "Editar Fianza" + UPModalFianza.Update() - Me.RegistraScript("$('#DvModalFianza').modal();") - 'GvFianzas.DataSource = DtTmpFianzas - 'GvFianzas.DataBind() - 'UpGvFianzas.Update() + Me.RegistraScript("$('#DvModalFianza').modal();") + End Sub Protected Sub CreaDtTmpFianzas() DtTmpFianzas = New DataTable() @@ -4037,11 +3761,8 @@ Partial Class Contratos_ContratoObra DtTmpFianzas.Columns.Add("FechaVencimiento", GetType(String)) DtTmpFianzas.Columns.Add("Adjunto", GetType(String)) - DtTmpFianzasInicial = DtTmpFianzas.Copy - - 'GvFianzas.DataSource = DtTmpFianzas - 'GvFianzas.DataBind() - 'UpGvFianzas.Update() + DtTmpFianzasInicial = DtTmpFianzas.Copy + End Sub Protected Function GuardaFianzas(ObjContrato As ClsContratos) As Boolean @@ -4853,9 +4574,65 @@ Partial Class Contratos_ContratoObra End Sub + Private Sub Indicadores() + Dim Con As New ClsContratos + Dim DTDatos As New DataTable + + If Con.GetContratosObraRepAvances(MinFecha, MaxFecha, DdlCliente.SelectedValue.ToEntero, CveContrato, UsuarioActual.CveEmpresa) Then + DTDatos = Con.DtResultados + End If + + Con.Dispose() + + + If DTDatos.Rows.Count > 0 Then + + Dim CantidadAvance As Decimal = DTDatos.Rows(0)("Cantidad").ToString.ToDecimal + Dim ImporteAvance As Decimal = DTDatos.Rows(0)("AvanceImporte").ToString.ToDecimal + Dim TotalAvancePorcentaje As Decimal = (ImporteAvance * 100 / TotalAvanceVentas).RoundSQL(2) + + Dim CantidadInterno As Decimal = DTDatos.Rows(0)("CantidadInterno").ToString.ToDecimal + Dim ImporteInterno As Decimal = DTDatos.Rows(0)("ImporteInterno").ToString.ToDecimal + Dim TotalFaltantePorcentaje As Decimal = (ImporteInterno * 100 / TotalAvanceInterno).RoundSQL(2) + + + LtlAvanceImporte.Text = $"$ { ImporteAvance.ToString("###,###,###.00") }" + LtlAvanceImporteProcentaje1.Text = $"{TotalAvancePorcentaje.ToString("###.00")} %" + LtlAvanceImporteProcentaje2.Text = $"{TotalAvancePorcentaje.ToString("###.00")}%" + SPAvance1.Attributes.Add("style", $"width:{TotalAvancePorcentaje.ToString.ToEntero}%") + + + LtlAvanceInternoImporte.Text = $"$ {DTDatos.Rows(0)("ImporteInterno").ToString.ToDecimal.ToString("###,###,###.00")}" + LtlAvanceInternoImportePorcentaje1.Text = $"{TotalFaltantePorcentaje.ToString("###.00")} %" + LtlAvanceInternoImportePorcentaje2.Text = $"{TotalFaltantePorcentaje.ToString("###.00")}%" + SPFaltante.Attributes.Add("style", $"width:{TotalFaltantePorcentaje.ToString.ToEntero}%") + + End If + + + 'Dim TotalContratos As Decimal = DTDatos.SUM("Importe") + 'Dim TotalAvance As Decimal = DTDatos.SUM("AvanceImporte") + 'Dim TotalFaltante As Decimal = TotalContratos - TotalAvance + + + 'Dim TotalAvancePorcentaje As Decimal = ((TotalAvance * 100) / TotalContratos).RoundAD(2) + 'Dim TotalFaltantePorcentaje As Decimal = (100 - TotalAvancePorcentaje).RoundAD(2) + + + ' LtlGrafNumeroContratos.Text = NumeroContratos.ToString + 'LtlGrafTotal.Text = TotalContratos.ToString("###,###,###.00") + + + DVGraficas.Visible = True + + UpGrafica.Update() + + End Sub + + End Class diff --git a/Contratos/ContratoObraAutorizacion.aspx b/Contratos/ContratoObraAutorizacion.aspx new file mode 100644 index 000000000..f22ccaceb --- /dev/null +++ b/Contratos/ContratoObraAutorizacion.aspx @@ -0,0 +1,324 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="ContratoObraAutorizacion.aspx.vb" Inherits="Contratos_ContratoObraAutorizacion" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ +
+ + + +
+
+ + +
+
+ +
+
+
+
+
+ + +
+
+ + + + + + + + + + + + <%# Eval("Cantidad", "{0:N2}")%> + + + + + <%# Eval("Importe", "{0:N2}")%> + + + + + <%# Eval("Cantidad_Ultima", "{0:N2}")%> + + + + + <%# Eval("Importe_Ultima", "{0:N2}")%> + + + + + + + + + + + +
+ + + +
+ + +
+
+ + + + +
+
+ +
+
+ + +
+
+
+ + + + + +
+
+
+ +
+ + + +
+ + +
+
+ + +
+ + + + + + + + + + + + + + + + <%----%> +
+ + + + + diff --git a/Contratos/ContratoObraAutorizacion.aspx.vb b/Contratos/ContratoObraAutorizacion.aspx.vb new file mode 100644 index 000000000..bec497e3b --- /dev/null +++ b/Contratos/ContratoObraAutorizacion.aspx.vb @@ -0,0 +1,659 @@ +Option Explicit On +Option Strict On + +Imports Extensiones +Imports System.IO +Imports System.Data +Imports Newtonsoft.Json +Imports ClosedXML.Excel + +Partial Class Contratos_ContratoObraAutorizacion + Inherits ClsPaginas + +#Region "Propiedades" + Private Property DtDatos As DataTable + Get + If ViewState("DtDatos") Is Nothing Then + Return Nothing + Else + Return CType(ViewState("DtDatos"), DataTable) + End If + End Get + Set(value As DataTable) + ViewState("DtDatos") = value + End Set + End Property + + Private Property CveContrato As Integer + Get + If ViewState("CveContrato") Is Nothing Then + Return Nothing + Else + Return ViewState("CveContrato").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveContrato") = value + End Set + End Property + + + Private Property CveContratoEstimacion As Integer + Get + If ViewState("CveContratoEstimacion") Is Nothing Then + Return Nothing + Else + Return ViewState("CveContratoEstimacion").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveContratoEstimacion") = value + End Set + End Property + + 'fecha seleccionada del historico de avances + Private Property fecha As String + Get + If ViewState("fecha") Is Nothing Then + Return "" + Else + Return ViewState("fecha").ToString + End If + End Get + Set(value As String) + ViewState("fecha") = value + 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 + + + Property CveEstimacionActual As Integer + Get + If ViewState("CveEstimacionActual") Is Nothing Then + Return -1 + Else + Return ViewState("CveEstimacionActual").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveEstimacionActual") = value + End Set + End Property + + Property NuemeroEstimacionActual As Integer + Get + If ViewState("NuemeroEstimacionActual") Is Nothing Then + Return -1 + Else + Return ViewState("NuemeroEstimacionActual").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("NuemeroEstimacionActual") = value + End Set + End Property + + + + +#End Region + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + + If Not IsPostBack Then + CargaContrato() + End If + + End Sub + + + + Private Sub CargaContrato() + DDlContratosEstimaciones.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}")) + DDlContratosEstimaciones.DataBind() + End Sub + + + + + + + Protected Sub GetAnexos(sender As Object, e As System.EventArgs) + Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + + LblTituloModalAnexo.Text = "Anexo " & GvRow.DataKey("PS") + + 'Get the button that raised the event + Dim btn As LinkButton = DirectCast(sender, LinkButton) + Dim gvr As GridViewRow = DirectCast(btn.NamingContainer, GridViewRow) + Dim CveContratoDetalle As Integer = gvr.DataKey("CveContratoDetalle").ToString.ToEntero + Dim CveContratoAvance As Integer = gvr.DataKey("CveContratoAvance").ToEntero + Dim Fecha As Date = gvr.DataKey("Fecha").ToDate + + Dim objContrato As New ClsContratos + If objContrato.GetContratosAvanceAnexos(CveContratoDetalle, UsuarioActual.CveUsuario, CveContratoAvance:=CveContratoAvance) Then + GvAnexos.DataSource = objContrato.DtResultados + GvAnexos.DataBind() + GvAnexos.Visible = True + Else + GvAnexos.Visible = False + End If + + objContrato.Dispose() + + UpModalAnexos.Update() + + RegistraScript("$('#ModalAnexos').modal('show');") + + End Sub + + Protected Sub GvAnexos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvAnexos.RowDataBound + + If e.Row.RowIndex > -1 Then + Dim Archivo As String = e.Row.DBCampo("Archivo").ToString + Dim start As Integer = Len(Archivo.Split("-"c)(0)) + Dim LnkArchivo As LinkButton = e.Row.FCLinkButton("LnkArchivo") + + LnkArchivo.Text = Archivo.Substring(start + 1) + + ScriptManager.GetCurrent(Me).RegisterPostBackControl(LnkArchivo) + End If + + End Sub + + + Protected Sub LnkArchivo_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + Dim Archivo As String = GvRow.DataKey("Archivo").ToString + + Response.ContentType = "application/octet-stream" + Response.AppendHeader("Content-Disposition", $"attachment; filename={Archivo}") + Response.TransmitFile($"{UsuarioActual.Empresa.Ruta}\Contrato\{DDlContratosEstimaciones.SelectedValue.ToEntero}\Anexos\{Archivo}") + Response.End() + + End Sub + + + +#Region "ESTIMACION" + + + Private Sub CargaAvancesParaEstimar() + CveContratoEstimacion = -1 + + Dim ObjContratos As New ClsContratos() + Dim DTEstimaciones As New DataTable + Dim NumeroEstimacionActual As Integer = 0 + + If ObjContratos.GetContratosAvanceEstimacion(DDlContratosEstimaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1) Then + DTEstimaciones = ObjContratos.DtResultados + + CveContratoEstimacion = DDlContratosEstimaciones.SelectedValue.ToEntero + + + End If + + + ObjContratos.Dispose() + + + If DTEstimaciones.Rows.Count > 0 Then + GvEstimaciones.DataSource = DTEstimaciones + ' BtnGuardarEstimacion.Visible = True + BtnAutoriza.Visible = True + Else + GvEstimaciones.DataSource = Nothing + BtnGuardarEstimacion.Visible = False + End If + GvEstimaciones.DataBind() + + UpEstimaciones.Update() + End Sub + + Private Sub BtnConsultarEstimaciones_Click(sender As Object, e As EventArgs) Handles BtnConsultarEstimaciones.Click + + CargaAvancesParaEstimar() + + End Sub + + Private Sub GvEstimaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstimaciones.RowDataBound + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("CveContratoDetalle").ToString.ToEntero = 0 Then + + + If e.Row.DBCampo("CveSubFamilias").ToString.ToEntero = 0 Then + If e.Row.DBCampo("CveFamilias").ToString.ToEntero = 0 Then + e.Row.CssClass = "SubTotales" + Else + e.Row.CssClass = "SubTotales2" + End If + Else + e.Row.CssClass = "SubTotales3" + End If + + + + + End If + + If e.Row.DBCampo("CveContratoDetalle").ToString.ToEntero > 0 Then + Dim LnkAnexo As LinkButton = e.Row.FCLinkButton("LnkAnexo") + Dim LnkEliminarAvance As LinkButton = e.Row.FCLinkButton("LnkEliminarAvance") + LnkAnexo.Visible = True + LnkEliminarAvance.Visible = True + End If + + + + + End If + + End Sub + + 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 + + ObjContratos.IniciaTransacSQL() + + + If ObjContratos.AddContratosAvanceEstimacion(CveContratoEstimacion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + + CveEstimacionNueva = ObjContratos.CveEstimacionNueva + NuemeroEstimacionNuevo = ObjContratos.NumeroEstimacionNueva + + For Each GvRow As GridViewRow In GvEstimaciones.Rows + + If GvRow.DataKey("CveContratoAvance").ToEntero > 0 Then + If Not ObjContratos.UpdateContratosAvanceEstimacion(GvRow.DataKey("CveContratoAvance").ToEntero, ObjContratos.CveEstimacionNueva, UsuarioActual.CveEmpresa) Then + ErrorProceso = True + Exit For + End If + End If + Next + + Else + ErrorProceso = True + End If + + 'AddContratosAvanceEstimacion + 'UpdateContratosAvanceEstimacion + + + + If Not ErrorProceso Then + ObjContratos.Commit() + 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 + Dim Lugar As String = "" + Dim DescripcionContrato As String = "" + + + If ObjContratos.GetContratosObraAvancesControlAcumulativo(CveContrato, CveEstimacion, UsuarioActual.CveEmpresa) Then + DtControl = ObjContratos.DtResultados + If DtControl.Rows.Count > 0 Then + Lugar = DtControl(0)("Lugar").ToString + DescripcionContrato = DtControl(0)("DescripcionContrato").ToString + End If + 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(18, 2).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left) + WSControl.Cell(18, 2).Style.Alignment.SetVertical(XLAlignmentVerticalValues.Top) + + WSControl.Cell(17, 6).Value = "" 'Periodo Fecha Inicial + WSControl.Cell(17, 7).Value = "" 'Periuodo Fecha Final + WSControl.Cell(20, 2).Value = DescripcionContrato + WSControl.Cell(20, 2).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left) + WSControl.Cell(20, 2).Style.Alignment.SetVertical(XLAlignmentVerticalValues.Top) + + 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.Cell(6, 6).Value = DescripcionContrato + + 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, 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 + + + + + + Protected Sub LnkEliminarAvance_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + Dim CveContratoAvance As Integer = GvRow.DataKey("CveContratoAvance").ToEntero + Dim ErrorProceso As Boolean = True + + + + Dim ObjContrato As New ClsContratos + + If ObjContrato.RemoveContratosAvance(CveContratoAvance, UsuarioActual.CveEmpresa) Then + ErrorProceso = False + End If + + ObjContrato.Dispose() + + If Not ErrorProceso Then + + CargaAvancesParaEstimar() + Alert("Avance elimiando correctamente.") + End If + + + + End Sub +End Class + + + diff --git a/Contratos/RepContratosObraAvancesPartida.aspx b/Contratos/RepContratosObraAvancesPartida.aspx index b577c1fb4..a231acd89 100644 --- a/Contratos/RepContratosObraAvancesPartida.aspx +++ b/Contratos/RepContratosObraAvancesPartida.aspx @@ -43,7 +43,7 @@
diff --git a/Contratos/RepContratosObraAvancesPartida.aspx.vb b/Contratos/RepContratosObraAvancesPartida.aspx.vb index 2abb6424b..e016c56b7 100644 --- a/Contratos/RepContratosObraAvancesPartida.aspx.vb +++ b/Contratos/RepContratosObraAvancesPartida.aspx.vb @@ -113,8 +113,10 @@ Partial Class RepContratosObraAvancesPartida Dim CveEstimacion As Integer = GvRow.DataKey("CveEstimacion").ToEntero Dim CveContratoDetalle As Integer = GvRow.DataKey("CveContratoDetalle").ToEntero + Dim CveContratoAvance As Integer = GvRow.DataKey("CveContratoAvance").ToEntero + Dim objContrato As New ClsContratos - If objContrato.GetContratosAvanceAnexos(CveContratoDetalle, Fecha, UsuarioActual.CveUsuario, CveEstimacion:=CveEstimacion) Then + If objContrato.GetContratosAvanceAnexos(CveContratoDetalle, Fecha, UsuarioActual.CveUsuario, CveEstimacion:=CveEstimacion, CveContratoAvance:=CveContratoAvance) Then GvAnexos.DataSource = objContrato.DtResultados GvAnexos.DataBind() GvAnexos.Visible = True @@ -150,11 +152,18 @@ Partial Class RepContratosObraAvancesPartida Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) Dim Archivo As String = GvRow.DataKey("Archivo").ToString + Dim FI As New IO.FileInfo($"{UsuarioActual.Empresa.Ruta}\Contrato\{CveContrato}\Anexos\{Archivo}") + + + If FI.Exists Then + + Response.ContentType = "application/octet-stream" + Response.AppendHeader("Content-Disposition", $"attachment; filename={Archivo}") + Response.TransmitFile(FI.FullName) + Response.End() + + End If - Response.ContentType = "application/octet-stream" - Response.AppendHeader("Content-Disposition", $"attachment; filename={Archivo}") - Response.TransmitFile($"{UsuarioActual.Empresa.Ruta}\Contrato\{CveContrato}\Anexos\{Archivo}") - Response.End() End Sub