Contratos

This commit is contained in:
Rakcsle Supertramp
2020-12-11 12:46:26 -07:00
parent 1ea0fdaa53
commit 17348ffe57
5 changed files with 309 additions and 108 deletions

View File

@@ -596,6 +596,16 @@ Partial Class Contratos_ContratoObra
TmpDT.Columns.Add("LimitarCantidad", GetType(Integer))
TmpDT.Columns.Add("OCInterna", GetType(String))
TmpDT.Columns.Add("Observacion", GetType(String))
TmpDT.Columns.Add("CveRubro", GetType(Integer))
TmpDT.Columns.Add("CveActividad", GetType(Integer))
TmpDT.Columns.Add("CveSubTipoActivoFijo", GetType(Integer))
TmpDT.Columns.Add("Rubro", GetType(String))
TmpDT.Columns.Add("Actividad", GetType(String))
TmpDT.Columns.Add("SubTipoActivoFijo", GetType(String))
End Sub
Protected Sub Limpiar()
TxtNumeroContrato.Text = ""
@@ -4126,27 +4136,58 @@ Partial Class Contratos_ContratoObra
Protected Sub BtnCargaPresupuesto_Click(sender As Object, e As EventArgs)
Dim DTCargaPresupuesto As New DataTable
DTCargaPresupuesto = CargaPreSupuestoExcel()
Dim DTCargaPresupuestoInsumos As New DataTable
Dim DTCargaPresupuestoManoObra As New DataTable
Dim DTCargaPresupuestoFlotillas As New DataTable
If TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas Then
DTCargaPresupuesto = CargaPreSupuestoExcel("Presupuesto")
If DTCargaPresupuesto.Rows.Count > 0 Then
ProcesaDatosCargaPresupuesto(DTCargaPresupuesto, Nothing, Nothing)
Else
Alert("No se encintraron partidas en el documento", TipoMensaje.MsgAdvertencia)
End If
If DTCargaPresupuesto.Rows.Count > 0 Then
ProcesaDatosCargaPresupuesto(DTCargaPresupuesto)
Else
Alert("No se encintraron partidas en el documento", TipoMensaje.MsgAdvertencia)
DTCargaPresupuesto = CargaPreSupuestoExcel("Insumos")
DTCargaPresupuestoManoObra = CargaPreSupuestoExcel("ManoObra")
DTCargaPresupuestoFlotillas = CargaPreSupuestoExcel("Flotillas")
ProcesaDatosCargaPresupuesto(DTCargaPresupuesto, DTCargaPresupuestoManoObra, DTCargaPresupuestoFlotillas)
End If
TxtModalCargaPresupuesto.Text = ""
End Sub
Protected Sub BtnDecargaFormato_Click(sender As Object, e As EventArgs)
Dim FI As New IO.FileInfo($"{Extensiones.DirectorioBaseEmpresas}\Empresas\Grales\Formatos\FormatoPresupuestoObra.xlsx")
If TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas Then
FI = New IO.FileInfo($"{Extensiones.DirectorioBaseEmpresas}\Empresas\Grales\Formatos\FormatoPresupuestoObra.xlsx")
Else
FI = New IO.FileInfo($"{Extensiones.DirectorioBaseEmpresas}\Empresas\Grales\Formatos\FormatoPresupuestoObraInterno.xlsx")
End If
If FI.Exists Then
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", $"attachment; filename=FormatoPresupuestoObra.xlsx")
If TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas Then
Response.AppendHeader("Content-Disposition", $"attachment; filename=FormatoPresupuestoObra.xlsx")
Else
Response.AppendHeader("Content-Disposition", $"attachment; filename=FormatoPresupuestoObraInterno.xlsx")
End If
Response.TransmitFile(FI.FullName)
Response.End()
@@ -4156,7 +4197,7 @@ Partial Class Contratos_ContratoObra
End Sub
Private Function CargaPreSupuestoExcel() As DataTable
Private Function CargaPreSupuestoExcel(Hoja As String) As DataTable
Dim FileExtension As String = "-1"
Dim Filesgral As List(Of Archivo) = TxtModalCargaPresupuesto.getfiles().Archivos
@@ -4178,7 +4219,7 @@ Partial Class Contratos_ContratoObra
tempArray = fileItem.filename.ToString().Split("-".ToCharArray())
SpreadsheetInfo.SetLicense(Extensiones.SerialGemBoxSpreadsheet)
Dim workbook = ExcelFile.Load(fileItem.FileUrl)
Dim worksheet = workbook.Worksheets(0)
Dim worksheet = workbook.Worksheets(Hoja)
DTPS = worksheet.CreateDataTable(New CreateDataTableOptions() With
{
.ColumnHeaders = True,
@@ -4190,7 +4231,7 @@ Partial Class Contratos_ContratoObra
Next
TxtModalCargaPresupuesto.Text = ""
RegistraScript("$('#ModalUploadPresupuesto').modal('hide')")
@@ -4201,7 +4242,25 @@ Partial Class Contratos_ContratoObra
End Function
Private Sub ProcesaDatosCargaPresupuesto(DTPresupuesto As DataTable)
Private Sub ProcesaDatosCargaPresupuesto(DTPresupuesto As DataTable, DTCargaPresupuestoManoObra As DataTable, DTCargaPresupuestoFlotillas As DataTable)
If Not DTPresupuesto Is Nothing Then
DTPresupuesto.CaseSensitive = False
End If
If Not DTCargaPresupuestoManoObra Is Nothing Then
DTCargaPresupuestoManoObra.CaseSensitive = False
End If
If Not DTCargaPresupuestoFlotillas Is Nothing Then
DTCargaPresupuestoFlotillas.CaseSensitive = False
End If
Dim DTPS = New DataTable
DTPS.Columns.Add("CveContratoDetalle", GetType(Integer))
@@ -4228,65 +4287,141 @@ Partial Class Contratos_ContratoObra
DTPS.Columns.Add("OCInterna", GetType(String))
DTPS.Columns.Add("Observacion", GetType(String))
DTPS.Columns.Add("CveRubro", GetType(Integer))
DTPS.Columns.Add("CveActividad", GetType(Integer))
DTPS.Columns.Add("CveSubTipoActivoFijo", GetType(Integer))
DTPS.Columns.Add("Rubro", GetType(String))
DTPS.Columns.Add("Actividad", GetType(String))
DTPS.Columns.Add("SubTipoActivoFijo", GetType(String))
Dim RowNoEncontrados As String = ""
For Each DrowPS As DataRow In DTPresupuesto.Rows
If Not DTPresupuesto Is Nothing Then
For Each DrowPS As DataRow In DTPresupuesto.Rows
Dim StrArray() As String = GetPS("PS", DrowPS("PS").ToString).Split("|"c)
Dim CvePS As Integer
Dim CveUM As Integer
Dim StrArray() As String = GetPS("PS", DrowPS("Producto").ToString).Split("|"c)
Dim CvePS As Integer
Dim CveUM As Integer
If StrArray.Length > 0 Then
If CBool(StrArray(0)) = True Then
CvePS = StrArray(1).ToEntero
Else
RowNoEncontrados &= StrArray(1) & "<\BR>"
If StrArray.Length > 0 Then
If CBool(StrArray(0)) = True Then
CvePS = StrArray(1).ToEntero
Else
RowNoEncontrados &= StrArray(1) & "<\BR>"
End If
End If
End If
If CvePS > 0 And DrowPS("Cantidad").ToString.ToDouble > 0 Then
CveUM = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveUnidadMedida", "").ToString.ToEntero
Dim Row As DataRow = DTPS.NewRow()
Row("Cantidad") = DrowPS("Cantidad").ToString.ToDouble
Row("CantidadContratada") = DrowPS("Cantidad").ToString.ToDouble
Row("CveUM") = CveUM
Row("UM") = ""
Row("CveClasificacion") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveClasificacion", "").ToString.ToEntero
Row("Clasificacion") = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = '{ Row("CveClasificacion").ToString }'").ToString
Row("CvePS") = CvePS
Row("PS") = DrowPS("PS").ToString
Row("CodigoPS") = DrowPS("PS").ToString
Row("PU") = DrowPS("PU").ToString.ToDouble
Row("Total") = DrowPS("Cantidad").ToString.ToDouble * DrowPS("PU").ToString.ToDouble
Select Case TipoCargaPresupuesto
Case EnumTipoCargaPresupuesto.Ventas
Row("CveTipoPresupuesto") = 2
Exit Select
Case EnumTipoCargaPresupuesto.Control
Row("CveTipoPresupuesto") = 1
Exit Select
Case Else
Row("CveTipoPresupuesto") = 1
End Select
Row("NoIdentificacion") = ""
Row("OCInterna") = ""
Row("LimitarCantidad") = 0
Row("Observacion") = ""
DTPS.Rows.Add(Row)
End If
Next
If CvePS > 0 And DrowPS("Cantidad").ToString.ToDouble > 0 Then
CveUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $" UnidadMedida = '{ DrowPS("UnidadMedida").ToString.Trim }' OR Abreviatura = '{ DrowPS("UnidadMedida").ToString.Trim }'").ToEntero
If CveUM <= 0 Then
CveUM = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveUnidadMedida", "").ToString.ToEntero
End If
Dim Row As DataRow = DTPS.NewRow()
Row("Cantidad") = DrowPS("Cantidad").ToString.ToDouble
Row("CantidadContratada") = DrowPS("Cantidad").ToString.ToDouble
Row("CveUM") = CveUM
Row("UM") = ""
Row("CveClasificacion") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveClasificacion", "").ToString.ToEntero
Row("Clasificacion") = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = '{ Row("CveClasificacion").ToString }'").ToString
Row("CvePS") = CvePS
Row("PS") = DrowPS("Producto").ToString
Row("CodigoPS") = DrowPS("Producto").ToString
Row("PU") = DrowPS("PU").ToString.ToDouble
Row("Total") = DrowPS("Cantidad").ToString.ToDouble * DrowPS("PU").ToString.ToDouble
Select Case TipoCargaPresupuesto
Case EnumTipoCargaPresupuesto.Ventas
Row("CveTipoPresupuesto") = 2
Row("CveRubro") = 1
Row("CveActividad") = -1
Row("CveSubTipoActivoFijo") = -1
Exit Select
Case EnumTipoCargaPresupuesto.Control
Row("CveTipoPresupuesto") = 1
Row("CveRubro") = 2
Row("CveActividad") = -1
Row("CveSubTipoActivoFijo") = -1
Exit Select
Case Else
Row("CveTipoPresupuesto") = 1
Row("CveActividad") = -1
Row("CveSubTipoActivoFijo") = -1
End Select
Row("NoIdentificacion") = ""
Row("OCInterna") = ""
Row("LimitarCantidad") = 0
Row("Observacion") = ""
DTPS.Rows.Add(Row)
End If
Next
End If
If Not DTCargaPresupuestoManoObra Is Nothing Then
For Each DrowPS As DataRow In DTCargaPresupuestoManoObra.Rows
Dim CveActividad As Integer = 0
CveActividad = GlobalDTRHActividades(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveActividad", $" Actividad = '{ DrowPS("Actividad").ToString.Trim }'").ToEntero
If CveActividad > 0 And DrowPS("Cantidad").ToString.ToDouble > 0 Then
Dim Row As DataRow = DTPS.NewRow()
Row("Cantidad") = DrowPS("Cantidad").ToString.ToDouble
Row("CantidadContratada") = DrowPS("Cantidad").ToString.ToDouble
Row("CveUM") = -1
Row("UM") = ""
Row("CveClasificacion") = -1
Row("Clasificacion") = ""
Row("CvePS") = -1
Row("PS") = DrowPS("Actividad").ToString
Row("CodigoPS") = DrowPS("Actividad").ToString
Row("PU") = DrowPS("PU").ToString.ToDouble
Row("Total") = DrowPS("Cantidad").ToString.ToDouble * DrowPS("PU").ToString.ToDouble
Row("CveTipoPresupuesto") = 2
Row("CveRubro") = 3
Row("CveActividad") = CveActividad
Row("CveSubTipoActivoFijo") = -1
Row("NoIdentificacion") = ""
Row("OCInterna") = ""
Row("LimitarCantidad") = 0
Row("Observacion") = ""
DTPS.Rows.Add(Row)
End If
Next
End If
If Not DTCargaPresupuestoFlotillas Is Nothing Then
End If
Dim ErrorProceso = False
Dim ObjContratos As New ClsContratos
@@ -4295,10 +4430,12 @@ Partial Class Contratos_ContratoObra
For Each Row As DataRow In DTPS.Rows
If ObjContratos.AddContratosDetalle(CveContrato, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, UsuarioActual.CveUsuario, Row("CveTipoPresupuesto").ToString.ToEntero, Row("NoIdentificacion").ToString, Convert.ToBoolean(Row("LimitarCantidad")), Row("OCInterna").ToString, Observacion:=Row("Observacion").ToString) Then
If ObjContratos.AddContratosDetalle(CveContrato, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, UsuarioActual.CveUsuario, Row("CveTipoPresupuesto").ToString.ToEntero,
Row("NoIdentificacion").ToString, Convert.ToBoolean(Row("LimitarCantidad")), Row("OCInterna").ToString, Observacion:=Row("Observacion").ToString, CveRubro:=Row("CveRubro").ToString.ToEntero,
CveActividad:=Row("CveActividad").ToString.ToEntero, CveSubTipoActivoFijo:=Row("CveSubTipoActivoFijo").ToString.ToEntero) Then
If Autorizado Then
Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con un precio ${3}.", Row("Cantidad"), Row("UM"), Row("PS"), Row("PU"))
Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con rubro {4} con un precio ${3}.", Row("Cantidad"), Row("UM"), Row("PS"), Row("PU"), Row("CveRubro"))
guardarBitacora(msj)
End If
@@ -4322,6 +4459,14 @@ Partial Class Contratos_ContratoObra
NrowTmpDT("LimitarCantidad") = Row("LimitarCantidad")
NrowTmpDT("Observacion") = Row("Observacion")
NrowTmpDT("CveRubro") = Row("CveRubro")
NrowTmpDT("CveActividad") = Row("CveActividad")
NrowTmpDT("CveSubTipoActivoFijo") = Row("CveSubTipoActivoFijo")
NrowTmpDT("Rubro") = Row("Rubro")
NrowTmpDT("Actividad") = Row("Actividad")
NrowTmpDT("SubTipoActivoFijo") = Row("SubTipoActivoFijo")
NrowTmpDT("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle")
@@ -4606,42 +4751,38 @@ Partial Class Contratos_ContratoObra
Con.Dispose()
If DTDatos.Rows.Count > 0 Then
Try
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 = If(ImporteAvance > 0, (ImporteAvance * 100 / TotalAvanceVentas).RoundSQL(2), 0)
Dim CantidadAvance As Decimal = DTDatos.Rows(0)("Cantidad").ToString.ToDecimal
Dim ImporteAvance As Decimal = DTDatos.Rows(0)("AvanceImporte").ToString.ToDecimal
Dim TotalAvancePorcentaje As Decimal = If(ImporteAvance > 0, (ImporteAvance * 100 / TotalAvanceVentas).RoundSQL(2), 0)
Dim CantidadInterno As Decimal = DTDatos.Rows(0)("CantidadInterno").ToString.ToDecimal
Dim ImporteInterno As Decimal = DTDatos.Rows(0)("ImporteInterno").ToString.ToDecimal
Dim TotalFaltantePorcentaje As Decimal = If(ImporteInterno > 0, (ImporteInterno * 100 / TotalAvanceInterno).RoundSQL(2), 0)
Dim CantidadInterno As Decimal = DTDatos.Rows(0)("CantidadInterno").ToString.ToDecimal
Dim ImporteInterno As Decimal = DTDatos.Rows(0)("ImporteInterno").ToString.ToDecimal
Dim TotalFaltantePorcentaje As Decimal = If(ImporteInterno > 0, (ImporteInterno * 100 / TotalAvanceInterno).RoundSQL(2), 0)
LtlAvanceImporte.Text = $"$ { ImporteAvance.ToString("###,###,###.00") }"
LtlAvanceImporteProcentaje1.Text = $"{TotalAvancePorcentaje.ToString("###.00")} %"
LtlAvanceImporteProcentaje2.Text = $"{TotalAvancePorcentaje.ToString("###.00")}%"
SPAvance1.Attributes.Add("style", $"width:{TotalAvancePorcentaje.ToString.ToEntero}%")
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}%")
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
End If
Catch ex As Exception
End Try
'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