diff --git a/Contratos/ContratoObra.aspx b/Contratos/ContratoObra.aspx index 18722fc8a..c8230178d 100644 --- a/Contratos/ContratoObra.aspx +++ b/Contratos/ContratoObra.aspx @@ -157,8 +157,30 @@ + + + +
  • + Agregar PS Venta +
  • + +
  • + Agregar PS Control +
  • +
  • + Agregar Presupuesto Venta +
  • + +
  • + Agregar Presupuesto Control +
  • + +
    +
    + + @@ -890,71 +912,10 @@ " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> - - - - - - - - - - - - - <%-- --%> - - - - - - - - + - - - - - - - - - - - - -
    - - Cantidad - - Producto/ServicioU. M.ObservaciónPrecio UnitarioTotalPermite AvancePermite Estimación Comandos
    - - - - - - - - - - -
    - -
    - -
    -
    - - - - - - - -
    @@ -965,122 +926,134 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - <%-- - - - - - --%> - - -
    - -
    -
    - - - -
    - - - - - -
    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + +
    + +
    +
    + + + +
    --%> + + + + + + + + + + +
    +
    + + @@ -1117,10 +1090,10 @@ - + - + <%-- @@ -1140,7 +1113,7 @@ - <%-- --%> + @@ -1180,109 +1153,126 @@ - + --%> + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - <%-- - - - - - --%> - - -
    - -
    -
    - - - -
    - - - - - -
    -
    + + + + + + + + + + + + + + + + + + + + + <%-- + +
    + +
    +
    + + + +
    --%> + + + + + + + + + +
    +
    Precio Unitario Total Permite AvancePermite Estimación Comandos
    @@ -2233,6 +2223,7 @@ <%--MODAL UPLOAD--%> + + + + + + + + + + + + <%--MODAL CONTROL PRESUPUESTOS AGREGAR--%> + + + + + + + + + + + + + + <%--Modal Carga Presupuesto--%> + + + + + + + + + + + + + + + + diff --git a/Contratos/ContratoObra.aspx.vb b/Contratos/ContratoObra.aspx.vb index 2bdcf71b0..063bf57b7 100644 --- a/Contratos/ContratoObra.aspx.vb +++ b/Contratos/ContratoObra.aspx.vb @@ -394,7 +394,17 @@ Partial Class Contratos_ContratoObra 'Configuración de Modalidad Update BtnGuardar.Text = "Guardar Cambios" - If Request("Opt") IsNot Nothing AndAlso IsNumeric(Request("Opt")) Then TAB.ActiveTabIndex = Request("Opt").ToEntero + If Request("Opt") IsNot Nothing AndAlso IsNumeric(Request("Opt")) Then Tab.ActiveTabIndex = Request("Opt").ToEntero + + If CveContrato > 0 Then + + LnkModalAddPSVentas.Visible = True + LnkModalAddPSControl.Visible = True + LnkModalAddPresupuestoVentas.Visible = True + LnkModalAddPresupuestoControl.Visible = True + + End If + Else 'Configuración de Modalidad Insert LblFechaCaptura.Text = Now.ToShortDateString() @@ -1001,30 +1011,30 @@ Partial Class Contratos_ContratoObra TabPVInsumos.Visible = False RowEstatus.Visible = False TabPres.HeaderText = "Partidas" - thOcCliente.Style.Add("display", "none") - tdOcCliente.Style.Add("display", "none") - thNoIdentificacionv.Style.Add("display", "none") - thLimitar.Style.Add("display", "none") - tdLimitar2.Style.Add("display", "none") - tdNoIdentificacionv.Style.Add("display", "none") + 'thOcCliente.Style.Add("display", "none") + 'tdOcCliente.Style.Add("display", "none") + 'thNoIdentificacionv.Style.Add("display", "none") + 'thLimitar.Style.Add("display", "none") + 'tdLimitar2.Style.Add("display", "none") + 'tdNoIdentificacionv.Style.Add("display", "none") 'RowFlexible.Visible = False TableDatosCabecera.Visible = False TabAvanveDocumento.Visible = False TabSistema.Visible = False 'RowPorcentajeComision.Visible = False TabContratosGastos.Visible = False - tdCveInterna.Text = "" - tdLimitar.Text = "" - tdOC.Text = "" - THAvance.Visible = False - THAvance.Style.Add("display", "none") + 'tdCveInterna.Text = "" + 'tdLimitar.Text = "" + 'tdOC.Text = "" + 'THAvance.Visible = False + 'THAvance.Style.Add("display", "none") TDAvance.Style.Add("display", "none") TxtOCInterna.Visible = False TxtNoIdentificacionv.Visible = False ChkLimitarVenta.Visible = False DvObservaciones.Visible = True - TDObservacion.Visible = True - tdObservaciones.Visible = True + 'TDObservacion.Visible = True + 'tdObservaciones.Visible = True TxtObservaciones.Text = ObjContratos.DtResultados.Rows(0)("Observaciones").ToString Gv.Columns(6).Visible = True 'DdlPeriodo.SelectedValueExist(ObjContratos.DtResultados.Rows(0)("CvePeriodo").ToString) @@ -1768,6 +1778,9 @@ Partial Class Contratos_ContratoObra DdlProductows.SelectedText = "Seleccione" DdlProductows.SelectedValue = "-1" End If + + UpModalVentasAddPS.Update() + End Sub Private Sub CargaPSInsumos() @@ -1852,53 +1865,123 @@ Partial Class Contratos_ContratoObra End Sub Protected Sub BtnAgregarDetalle_Click(sender As Object, e As EventArgs) - Dim Row As DataRow = TmpDT.NewRow() - Row("Cantidad") = TxtCantidad.Text.ToDouble.FormatoNumero - Row("CantidadContratada") = TxtCantidad.Text.ToDouble.FormatoNumero - Row("CveUM") = DdlUM.SelectedValue.ToEntero - Row("UM") = DdlUM.SelectedItem - Row("CveClasificacion") = DdlClasificacionAdd.SelectedValue - Row("Clasificacion") = DdlClasificacionAdd.SelectedItem - Row("CvePS") = DdlProductows.SelectedValue.ToEntero - Row("PS") = DdlProductows.SelectedText - Row("CodigoPS") = DdlProductows.SelectedText - Row("PU") = TxtPU.Text.ToDouble.FormatoNumero - Row("Total") = (TxtCantidad.Text.ToDouble * TxtPU.Text.ToDouble).FormatoNumero - Row("CveTipoPresupuesto") = 2 - Row("NoIdentificacion") = TxtNoIdentificacionv.Text.Trim - Row("OCInterna") = TxtOCInterna.Text.Trim - Row("LimitarCantidad") = If(ChkLimitarVenta.Checked, 1, 0) - Row("Observacion") = TxtObservacionesDetalles.Text - Dim ObjContratos As New ClsContratos - 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 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")) - guardarBitacora(msj) - End If - Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle") - TmpDT.Rows.Add(Row) - TmpDT.AcceptChanges() - Dim TotalRow = Row("Total").ToString.ToDouble - CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2")) - - UpGV.Update() - TxtCantidad.Text = "" - TxtOCInterna.Text = "" - TxtNoIdentificacionv.Text = "" - TxtObservacionesDetalles.Text = "" - TxtPU.Text = "" - DdlClasificacionAdd.SelectedValue = "-1" - LbTotalGeneral.Text = (LbTotalGeneral.Text.ToDouble + TotalRow).ToString.FormatoNumero - LblImporte.Text = LbTotalGeneral.Text - TxtCantidad.Focus() - UpGral.Update() - Else - Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError) - End If - - ObjContratos.Dispose() + If CveContratoDetalleEditar = -1 Then + + Dim Row As DataRow = TmpDT.NewRow() + Row("Cantidad") = TxtCantidad.Text.ToDouble.FormatoNumero + Row("CantidadContratada") = TxtCantidad.Text.ToDouble.FormatoNumero + Row("CveUM") = DdlUM.SelectedValue.ToEntero + Row("UM") = DdlUM.SelectedItem + Row("CveClasificacion") = DdlClasificacionAdd.SelectedValue + Row("Clasificacion") = DdlClasificacionAdd.SelectedItem + Row("CvePS") = DdlProductows.SelectedValue.ToEntero + Row("PS") = DdlProductows.SelectedText + Row("CodigoPS") = DdlProductows.SelectedText + Row("PU") = TxtPU.Text.ToDouble.FormatoNumero + Row("Total") = (TxtCantidad.Text.ToDouble * TxtPU.Text.ToDouble).FormatoNumero + Row("CveTipoPresupuesto") = 2 + Row("NoIdentificacion") = TxtNoIdentificacionv.Text.Trim + Row("OCInterna") = TxtOCInterna.Text.Trim + Row("LimitarCantidad") = If(ChkLimitarVenta.Checked, 1, 0) + Row("Observacion") = "" 'TxtObservacionesDetalles.Text + + Dim ObjContratos As New ClsContratos + + + 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 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")) + guardarBitacora(msj) + End If + + Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle") + TmpDT.Rows.Add(Row) + TmpDT.AcceptChanges() + Dim TotalRow = Row("Total").ToString.ToDouble + + CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2")) + + UpGV.Update() + LimpiarModalVentas() + + LbTotalGeneral.Text = (LbTotalGeneral.Text.ToDouble + TotalRow).ToString.FormatoNumero + LblImporte.Text = LbTotalGeneral.Text + TxtCantidad.Focus() + UpGral.Update() + + + If Not ChkContinualAgregandoVentas.Checked Then + RegistraScript("$('#ModalVentasAddPS').modal('hide')") + End If + + Else + Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError) + End If + + ObjContratos.Dispose() + Else + + + Dim Cantidad, PU As Double : Dim CvePS, CveUM As Integer + Dim NoIdentificacion As String = "" + Dim OCInterna As String = "" + Dim LimitarCantidad As Boolean + Dim Observaciones As String = "" + + Cantidad = TxtCantidad.Text.ToDouble + PU = TxtPU.Text.ToDouble + CvePS = DdlProductows.SelectedValue.ToEntero + CveUM = DdlUM.SelectedValue.ToEntero + NoIdentificacion = TxtNoIdentificacionv.Text.Trim + OCInterna = TxtOCInterna.Text.Trim + LimitarCantidad = If(ChkLimitarVenta.Checked, True, False) + Observaciones = "" + + Dim row = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalleEditar))(0) + Dim LimitarCantidadValidator As Boolean = row("LimitarCantidad").ToString = "True" + + + Dim ObjContratos As New ClsContratos + If ObjContratos.UpdateContratosDetalle(CveContratoDetalleEditar, CveContrato, CvePS, Cantidad, PU, UsuarioActual.CveUsuario, NoIdentificacion, LimitarCantidad, OCInterna, Observaciones) Then + + If Autorizado Then + Dim msj As String = String.Format("Se realizaron los siguientes cambios, el Presupuesto Interno se modificó: {1} {0} {2:C2} a {3} {0} {4:C2}", + row("PS").ToString, row("Cantidad").ToString, row("PU").ToString, Cantidad, PU) + guardarBitacora(msj) + End If + + row("Cantidad") = Cantidad + row("CantidadContratada") = Cantidad + row("PU") = PU + row("Total") = Cantidad * PU + row("CveUM") = CveUM + row("UM") = DdlUM.SelectedItem.Text + row("NoIdentificacion") = NoIdentificacion + row("OCInterna") = OCInterna + row("LimitarCantidad") = LimitarCantidad + row("Observacion") = Observaciones + + TmpDT.AcceptChanges() + Alert("Cambios realizados correctamente.", TipoMensaje.MsgInformacion) + RegistraScript("$('#ModalVentasAddPS').modal('hide')") + Else + Alert("Error al Actualizar Detalle", TipoMensaje.MsgError) + End If + ObjContratos.Dispose() + + + + Gv.EditIndex = -1 + LbTotalGeneral.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").FormatoNumero + LblImporte.Text = LbTotalGeneral.Text + CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2")) + + End If + + End Sub Private Sub CargaDatosPresup() @@ -2069,7 +2152,8 @@ Partial Class Contratos_ContratoObra If ObjContratos.RemoveContratosDetalle(CveContratoDetalle, CveContrato) Then TmpDT.Rows.Remove(DbRow) CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2")) - LbTotalGeneral.Text = Gv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCLabel("LtTotal").Text.ToDouble).ToString.FormatoNumero + LbTotalGeneral.Text = Gv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCLabel("LtTotal").Text.ToDouble).ToString.FormatoNumero + Alert("Detalle eliminado eliminado correctamente.") Else Alert("Ocurrió un error al eliminar el detalle (Producto/Servicio). Por favor vuelva a intentar", TipoMensaje.MsgError) End If @@ -2100,48 +2184,112 @@ Partial Class Contratos_ContratoObra UpGVInsumos.Update() End Sub - Protected Sub BtnAgregarDetalleInsumos_Click(sender As Object, e As EventArgs) - Dim Row As DataRow = TmpDT.NewRow() - Row("Cantidad") = TxtCantidadInsumos.Text.ToDouble.FormatoNumero - Row("CantidadContratada") = TxtCantidadInsumos.Text.ToDouble.FormatoNumero - Row("CveUM") = DdlUMInsumos.SelectedValue.ToEntero - Row("UM") = DdlUMInsumos.SelectedItem - Row("CveClasificacion") = DdlClasificacionAddInsumos.SelectedValue - Row("Clasificacion") = DdlClasificacionAddInsumos.SelectedItem - Row("CvePS") = DdlProductowsInsumos.SelectedValue.ToEntero - Row("PS") = DdlProductowsInsumos.SelectedText - Row("CodigoPS") = DdlProductowsInsumos.SelectedText - Row("PU") = TxtPUInsumos.Text.ToDouble.FormatoNumero - Row("Total") = (TxtCantidadInsumos.Text.ToDouble * TxtPUInsumos.Text.ToDouble).FormatoNumero - Row("CveTipoPresupuesto") = 1 - Row("NoIdentificacion") = TxtNoIdentificacionvInsumos.Text.Trim - Row("LimitarCantidad") = If(ChkLimitar.Checked, 1, 0) + Protected Sub BtnAgregarDetalleInsumos_Click(sender As Object, e As EventArgs) + + If CveContratoDetalleEditar = -1 Then + + Dim Row As DataRow = TmpDT.NewRow() + Row("Cantidad") = TxtCantidadInsumos.Text.ToDouble.FormatoNumero + Row("CantidadContratada") = TxtCantidadInsumos.Text.ToDouble.FormatoNumero + Row("CveUM") = DdlUMInsumos.SelectedValue.ToEntero + Row("UM") = DdlUMInsumos.SelectedItem + Row("CveClasificacion") = DdlClasificacionAddInsumos.SelectedValue + Row("Clasificacion") = DdlClasificacionAddInsumos.SelectedItem + Row("CvePS") = DdlProductowsInsumos.SelectedValue.ToEntero + Row("PS") = DdlProductowsInsumos.SelectedText + Row("CodigoPS") = DdlProductowsInsumos.SelectedText + Row("PU") = TxtPUInsumos.Text.ToDouble.FormatoNumero + Row("Total") = (TxtCantidadInsumos.Text.ToDouble * TxtPUInsumos.Text.ToDouble).FormatoNumero + Row("CveTipoPresupuesto") = 1 + Row("NoIdentificacion") = TxtNoIdentificacionvInsumos.Text.Trim + Row("LimitarCantidad") = If(ChkLimitarInsumos.Checked, 1, 0) + + Dim ObjContratos As New ClsContratos + 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")), "") 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")) + guardarBitacora(msj) + End If + Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle") + TmpDT.Rows.Add(Row) + Dim TotalRow = Row("Total").ToString.ToDouble + + CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1")) + + UpGVInsumos.Update() + LimpiarModalControl() + LbTotalGeneralInsumos.Text = (LbTotalGeneralInsumos.Text.ToDouble + TotalRow).ToString.FormatoNumero + 'LblImporte.Text = LbTotalGeneral.Text + TxtCantidadInsumos.Focus() + UpGral.Update() + + + If Not ChkContinualAgregandoControl.Checked Then + RegistraScript("$('#ModalControlAddPS').modal('hide')") + End If + + Else + Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError) + End If + + ObjContratos.Dispose() + + Else + + Dim Cantidad, PU As Double + Dim CvePS, CveUM As Integer + Dim NoIdentificacion As String = "" + Dim LimitarCantidad As Boolean + + Cantidad = TxtCantidadInsumos.Text.ToDouble + PU = TxtPUInsumos.Text.ToDouble + CvePS = DdlProductowsInsumos.SelectedValue.ToEntero + CveUM = DdlUMInsumos.SelectedValue.ToEntero + NoIdentificacion = TxtNoIdentificacionvInsumos.Text.Trim + LimitarCantidad = If(ChkLimitarInsumos.Checked, True, False) + + Dim row = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalleEditar))(0) + + + + Dim ObjContratos As New ClsContratos + If ObjContratos.UpdateContratosDetalle(CveContratoDetalleEditar, CveContrato, CvePS, Cantidad, PU, UsuarioActual.CveUsuario, NoIdentificacion, LimitarCantidad, "") Then + + If Autorizado Then + Dim msj As String = String.Format("Se realizaron los siguientes cambios, el Presupuesto Interno se modificó: {1} {0} {2:C2} a {3} {0} {4:C2}", + row("PS").ToString, row("Cantidad").ToString, row("PU").ToString, Cantidad, PU) + guardarBitacora(msj) + End If + + row("Cantidad") = Cantidad + row("CantidadContratada") = Cantidad + row("PU") = PU + row("Total") = Cantidad * PU + row("CveUM") = CveUM + row("UM") = DdlUMInsumos.SelectedItem.Text + row("NoIdentificacion") = NoIdentificacion + row("LimitarCantidad") = LimitarCantidad + TmpDT.AcceptChanges() + Alert("Cambios realizados correctamente.", TipoMensaje.MsgInformacion) + RegistraScript("$('#ModalControlAddPS').modal('hide')") + Else + Alert("Error al Actualizar Detalle", TipoMensaje.MsgError) + End If + ObjContratos.Dispose() + + + GvInsumos.EditIndex = -1 + LbTotalGeneralInsumos.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").FormatoNumero + CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1")) + + + End If + + - Dim ObjContratos As New ClsContratos - 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")), "") 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")) - guardarBitacora(msj) - End If - Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle") - TmpDT.Rows.Add(Row) - Dim TotalRow = Row("Total").ToString.ToDouble - CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1")) - UpGVInsumos.Update() - TxtCantidadInsumos.Text = "" - TxtPUInsumos.Text = "" - DdlClasificacionAddInsumos.SelectedValue = "-1" - LbTotalGeneralInsumos.Text = (LbTotalGeneralInsumos.Text.ToDouble + TotalRow).ToString.FormatoNumero - 'LblImporte.Text = LbTotalGeneral.Text - TxtCantidadInsumos.Focus() - UpGral.Update() - Else - Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError) - End If - ObjContratos.Dispose() End Sub #Region "GV PRESUPUESTOS" @@ -2251,7 +2399,8 @@ Partial Class Contratos_ContratoObra If ObjContratos.RemoveContratosDetalle(CveContratoDetalle, CveContrato) Then TmpDT.Rows.Remove(DbRow) CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1")) - LbTotalGeneralInsumos.Text = GvInsumos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCLiteral("LtTotal").Text.ToDouble).ToString.FormatoNumero + LbTotalGeneralInsumos.Text = GvInsumos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCLabel("LtTotal").Text.ToDouble).ToString.FormatoNumero + Alert("Detalle eliminado eliminado correctamente.") Else Alert("Ocurrió un error al eliminar el detalle (Producto/Servicio). Por favor vuelva a intentar", TipoMensaje.MsgError) End If @@ -2284,7 +2433,7 @@ Partial Class Contratos_ContratoObra Row("Total") = (TxtCantidadInt.Text.ToDouble * TxtPUInt.Text.ToDouble).FormatoNumero Row("CveTipoPresupuesto") = 1 Row("NoIdentificacion") = TxtNoIdentificacionv.Text.Trim - Row("LimitarCantidad") = ChkLimitar.Checked + Row("LimitarCantidad") = False 'ChkLimitar.Checked <-- Estaba usando un checkbox de un logar muy diferente a donde esta ese formilario, posiblemente se copio codigo y se fue por equivocacion Dim ObjContratos As New ClsContratos 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, Row("LimitarCantidad").ToString.ToEntero = 1, "") Then @@ -4408,6 +4557,473 @@ Partial Class Contratos_ContratoObra + Property ModalVentasPSAdd As Boolean + Get + If ViewState("ModalVentasAdd") Is Nothing Then + Return False + Else + Return Boolean.Parse(ViewState("ModalVentasAdd").ToString) + End If + End Get + Set(value As Boolean) + ViewState("ModalVentasAdd") = value + End Set + End Property + + + Property ModalControlPSAdd As Boolean + Get + If ViewState("ModalControlPSAdd") Is Nothing Then + Return False + Else + Return Boolean.Parse(ViewState("ModalControlPSAdd").ToString) + End If + End Get + Set(value As Boolean) + ViewState("ModalControlPSAdd") = value + End Set + End Property + + Property Carga As Boolean + Get + If ViewState("ModalControlPSAdd") Is Nothing Then + Return False + Else + Return Boolean.Parse(ViewState("ModalControlPSAdd").ToString) + End If + End Get + Set(value As Boolean) + ViewState("ModalControlPSAdd") = value + End Set + End Property + + Enum EnumTipoCargaPresupuesto + Ventas + Control + End Enum + + Property TipoCargaPresupuesto As EnumTipoCargaPresupuesto + Get + If ViewState("TipoCargaPresupuesto") Is Nothing Then + Return EnumTipoCargaPresupuesto.Ventas + Else + Return DirectCast(ViewState("TipoCargaPresupuesto"), EnumTipoCargaPresupuesto) + End If + End Get + Set(value As EnumTipoCargaPresupuesto) + ViewState("TipoCargaPresupuesto") = value + End Set + End Property + + + Property CveContratoDetalleEditar As Integer + Get + + If ViewState("CveContratoDetalleEditar") Is Nothing Then + Return -1 + Else + Return ViewState("CveContratoDetalleEditar").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CveContratoDetalleEditar") = value + End Set + End Property + + Protected Sub LnkModalAddPresupuestoVentas_Click(sender As Object, e As EventArgs) + + LnlModalcargaPresupuestoTitulo.Text = "Carga Presupuesto Ventas" + UpModalCargaPresupuesto.Update() + RegistraScript("$('#ModalUploadPresupuesto').modal('show')") + TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas + + End Sub + + Protected Sub LnkModalAddPresupuestoControl_Click(sender As Object, e As EventArgs) + + LnlModalcargaPresupuestoTitulo.Text = "Carga Presupuesto Control" + UpModalCargaPresupuesto.Update() + RegistraScript("$('#ModalUploadPresupuesto').modal('show')") + TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Control + + End Sub + + Protected Sub LnkModalAddPSVentas_Click(sender As Object, e As EventArgs) + + ModalVentasPSAdd = True + ChkContinualAgregandoVentas.Visible = True + ChkContinualAgregandoVentas.Checked = True + LimpiarModalVentas() + RegistraScript("$('#ModalVentasAddPS').modal('show')") + + End Sub + + Protected Sub LnkModalAddPSControl_Click(sender As Object, e As EventArgs) + + ModalControlPSAdd = True + ChkContinualAgregandoControl.Visible = True + ChkContinualAgregandoControl.Checked = True + LimpiarModalControl() + RegistraScript("$('#ModalControlAddPS').modal('show')") + + End Sub + + + Protected Sub LnkEditarPresupuestoVentaDetalle_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + LimpiarModalVentas() + + 'CveContratoDetalle,CveUM,CvePS,Cantidad,PU,CveTipoPresupuesto,CveClasificacion,CodigoPS,LimitarCantidad + + CveContratoDetalleEditar = GvRow.DataKey("CveContratoDetalle").ToEntero + + + TxtOCInterna.Text = GvRow.DataKey("OCInterna") + TxtCantidad.Text = GvRow.DataKey("Cantidad").ToDouble.ToString + + ChkLimitarVenta.Checked = Boolean.Parse(GvRow.DataKey("LimitarCantidad")) + + TxtNoIdentificacionv.Text = GvRow.DataKey("NoIdentificacion").ToDouble.ToString + DdlClasificacionAdd.SelectedValueExist(GvRow.DataKey("CveClasificacion").ToEntero) + + DdlProductows.txtText.Value = GvRow.DataKey("PS").ToString + DdlProductows.txtValue.Value = GvRow.DataKey("CvePS").ToString + + DdlUM.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductows.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + DdlUM.DataBind() + DdlUM.SelectedValueExist(GvRow.DataKey("CveUM").ToDouble.ToString) + + TxtPU.Text = GvRow.DataKey("PU").ToDouble.ToString + + + + ModalVentasPSAdd = False + ChkContinualAgregandoVentas.Visible = False + ChkContinualAgregandoVentas.Checked = False + + + RegistraScript("$('#ModalVentasAddPS').modal('show')") + End Sub + Protected Sub LnkEditarPresupuestoControlDetalle_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + LimpiarModalControl() + + CveContratoDetalleEditar = gvRow.DataKey("CveContratoDetalle").ToEntero + + TxtCantidadInsumos.Text = gvRow.DataKey("Cantidad").ToDouble.ToString + ChkLimitarInsumos.Checked = Boolean.Parse(gvRow.DataKey("LimitarCantidad")) + TxtNoIdentificacionvInsumos.Text = gvRow.DataKey("NoIdentificacion") + + DdlClasificacionAddInsumos.SelectedValueExist(gvRow.DataKey("CveClasificacion").ToEntero) + + DdlProductowsInsumos.txtText.Value = gvRow.DataKey("PS").ToString + DdlProductowsInsumos.txtValue.Value = gvRow.DataKey("CvePS").ToString + + + DdlUMInsumos.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductowsInsumos.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + DdlUMInsumos.DataBind() + DdlUMInsumos.SelectedValueExist(gvRow.DataKey("CveUM").ToDouble.ToString) + + + + TxtPUInsumos.Text = gvRow.DataKey("PU").ToDouble.ToString + + + + ModalControlPSAdd = False + ChkContinualAgregandoControl.Visible = False + ChkContinualAgregandoControl.Checked = False + + RegistraScript("$('#ModalControlAddPS').modal('show')") + End Sub + + + Private Sub LimpiarModalVentas() + + TxtOCInterna.Text = "" + TxtCantidad.Text = "" + ChkLimitarVenta.Checked = False + TxtNoIdentificacionv.Text = "" + DdlClasificacionAdd.SelectedValueExist(-1) + DdlProductows.txtText.Value = "" + DdlProductows.txtValue.Value = "" + DdlUM.SelectedValueExist(-1) + TxtPU.Text = "" + + + If ModalVentasPSAdd = True Then + LtlModalVentasPSTitulo.Text = "Agregar Producto Presupuesto de Ventas" + Else + LtlModalVentasPSTitulo.Text = "Editar Producto Presupuesto de Ventas" + End If + + + UpModalVentasAddPS.Update() + + End Sub + Private Sub LimpiarModalControl() + + + + TxtCantidadInsumos.Text = "" + ChkLimitarInsumos.Checked = False + TxtNoIdentificacionvInsumos.Text = "" + + DdlClasificacionAddInsumos.SelectedValueExist(-1) + DdlProductowsInsumos.txtText.Value = "" + DdlProductowsInsumos.txtValue.Value = "" + DdlUMInsumos.SelectedValueExist(-1) + TxtPUInsumos.Text = "" + + + If ModalControlPSAdd = True Then + LtlModalControlPSTitulo.Text = "Agregar Producto Presupuesto Control" + Else + LtlModalControlPSTitulo.Text = "Editar Producto Presupuesto Control" + End If + + UpModalControlAddPS.Update() + + End Sub + + + + Protected Sub BtnCargaPresupuesto_Click(sender As Object, e As EventArgs) + + Dim DTCargaPresupuesto As New DataTable + DTCargaPresupuesto = CargaPreSupuestoExcel() + + If DTCargaPresupuesto.Rows.Count > 0 Then + ProcesaDatosCargaPresupuesto(DTCargaPresupuesto) + Else + Alert("No se encintraron partidas en el documento", TipoMensaje.MsgAdvertencia) + End If + + End Sub + + + + Private Function CargaPreSupuestoExcel() As DataTable + + Dim FileExtension As String = "-1" + Dim Filesgral As List(Of Archivo) = TxtModalCargaPresupuesto.getfiles().Archivos + Dim Filename As String = "" + Dim DTPS = New DataTable + + For Each fileItem As Archivo In Filesgral + + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + + + If Not FileExtension.ToUpper.Contiene("XLSX", "XSL") Then + Alert("El archivo no es una archivo de Excel", TipoMensaje.MsgAdvertencia) + Exit For + End If + + + Dim tempArray() As String + tempArray = fileItem.filename.ToString().Split("-".ToCharArray()) + SpreadsheetInfo.SetLicense(Extensiones.SerialGemBoxSpreadsheet) + Dim workbook = ExcelFile.Load(fileItem.FileUrl) + Dim worksheet = workbook.Worksheets(0) + DTPS = worksheet.CreateDataTable(New CreateDataTableOptions() With + { + .ColumnHeaders = True, + .StartRow = 0, + .NumberOfColumns = 4, + .NumberOfRows = worksheet.Rows.Count, + .Resolution = ColumnTypeResolution.AutoPreferStringCurrentCulture + }) + + Next + + TxtModalCargaPresupuesto.Text = "" + + RegistraScript("$('#ModalUploadPresupuesto').modal('hide')") + + UpModalCargaPresupuesto.Update() + + Return DTPS + + End Function + + + Private Sub ProcesaDatosCargaPresupuesto(DTPresupuesto As DataTable) + + Dim DTPS = New DataTable + DTPS.Columns.Add("CveContratoDetalle", GetType(Integer)) + DTPS.Columns.Add("Cantidad", GetType(Double)) + DTPS.Columns.Add("CantidadContratada", GetType(Double)) + DTPS.Columns.Add("CveUM", GetType(Integer)) + DTPS.Columns.Add("UM", GetType(String)) + DTPS.Columns.Add("CveClasificacion", GetType(Integer)) + DTPS.Columns.Add("Clasificacion", GetType(String)) + DTPS.Columns.Add("CvePS", GetType(Integer)) + DTPS.Columns.Add("PS", GetType(String)) + DTPS.Columns.Add("CodigoPS", GetType(String)) + DTPS.Columns.Add("PU", GetType(Double)) + DTPS.Columns.Add("Total", GetType(Double)) + DTPS.Columns.Add("CveTipoPresupuesto", GetType(Integer)) + DTPS.Columns.Add("PermitirAvance", GetType(Integer)) + DTPS.Columns.Add("PermitirEstimacion", GetType(Integer)) + DTPS.Columns.Add("UsuarioAvance", GetType(Integer)) + DTPS.Columns.Add("Cantidad_Original", GetType(Double)) + DTPS.Columns.Add("PU_Original", GetType(Double)) + DTPS.Columns.Add("Total_Original", GetType(Double)) + DTPS.Columns.Add("NoIdentificacion", GetType(String)) + DTPS.Columns.Add("LimitarCantidad", GetType(Integer)) + DTPS.Columns.Add("OCInterna", GetType(String)) + DTPS.Columns.Add("Observacion", GetType(String)) + + Dim RowNoEncontrados As String = "" + + 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 + + If StrArray.Length > 0 Then + If CBool(StrArray(0)) = True Then + CvePS = StrArray(1).ToEntero + Else + RowNoEncontrados &= StrArray(1) & "<\BR>" + 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 + + + + + Dim ErrorProceso = False + Dim ObjContratos As New ClsContratos + Dim TotalRow As Double = 0 + ObjContratos.IniciaTransacSQL() + + 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 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")) + guardarBitacora(msj) + End If + + Dim NrowTmpDT As DataRow = TmpDT.NewRow + + + NrowTmpDT("Cantidad") = Row("Cantidad") + NrowTmpDT("CantidadContratada") = Row("CantidadContratada") + NrowTmpDT("CveUM") = Row("CveUM") + NrowTmpDT("UM") = Row("UM") + NrowTmpDT("CveClasificacion") = Row("CveClasificacion") + NrowTmpDT("Clasificacion") = Row("Clasificacion") + NrowTmpDT("CvePS") = Row("CvePS") + NrowTmpDT("PS") = Row("PS") + NrowTmpDT("CodigoPS") = Row("CodigoPS") + NrowTmpDT("PU") = Row("PU") + NrowTmpDT("Total") = Row("Total") + NrowTmpDT("CveTipoPresupuesto") = Row("CveTipoPresupuesto") + NrowTmpDT("NoIdentificacion") = Row("NoIdentificacion") + NrowTmpDT("OCInterna") = Row("OCInterna") + NrowTmpDT("LimitarCantidad") = Row("LimitarCantidad") + NrowTmpDT("Observacion") = Row("Observacion") + + + NrowTmpDT("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle") + + TmpDT.Rows.Add(NrowTmpDT) + TmpDT.AcceptChanges() + + TotalRow = TotalRow + NrowTmpDT("Total").ToString.ToDouble + Else + ErrorProceso = True + Exit For + End If + Next + + + If ErrorProceso Then + ObjContratos.RollBack() + Alert("Se presento un error al cargar el presupuesto.", TipoMensaje.MsgError) + Else + + ObjContratos.Commit() + Alert("Presupuesto Cargado correctamente") + + + Select Case TipoCargaPresupuesto + Case EnumTipoCargaPresupuesto.Ventas + CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2")) + UpGV.Update() + Exit Select + Case EnumTipoCargaPresupuesto.Control + CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1")) + UpGVInsumos.Update() + Exit Select + Case Else + + End Select + + LbTotalGeneral.Text = (LbTotalGeneral.Text.ToDouble + TotalRow).ToString.FormatoNumero + LblImporte.Text = LbTotalGeneral.Text + UpGral.Update() + + End If + + + + ObjContratos.Dispose() + + If RowNoEncontrados.Length > 0 Then + Alert($"Productos no encontrados
    {RowNoEncontrados} ") + End If + + + End Sub + End Class diff --git a/TareasProgramadas/FormatosThalamus/FormatoAlmacenes.xlsx b/TareasProgramadas/FormatosThalamus/FormatoAlmacenes.xlsx index a1ee06186..735c70745 100644 Binary files a/TareasProgramadas/FormatosThalamus/FormatoAlmacenes.xlsx and b/TareasProgramadas/FormatosThalamus/FormatoAlmacenes.xlsx differ diff --git a/TareasProgramadas/FormatosThalamus/FormatoVentas.xlsx b/TareasProgramadas/FormatosThalamus/FormatoVentas.xlsx index 9fef83a64..1d0287413 100644 Binary files a/TareasProgramadas/FormatosThalamus/FormatoVentas.xlsx and b/TareasProgramadas/FormatosThalamus/FormatoVentas.xlsx differ diff --git a/TareasProgramadas/Tareas119.ashx b/TareasProgramadas/Tareas119.ashx index 18ff8f5a9..dfbee9c74 100644 --- a/TareasProgramadas/Tareas119.ashx +++ b/TareasProgramadas/Tareas119.ashx @@ -205,7 +205,7 @@ public class TareasJam : IHttpHandler DataTable dtCloned = DTVentas.Clone(); - dtCloned.Columns[3].DataType = typeof(string); + dtCloned.Columns[3].DataType = typeof(DateTime); foreach (DataRow row in DTVentas.Rows) { @@ -215,7 +215,7 @@ public class TareasJam : IHttpHandler DTVentas = dtCloned; foreach (DataRow dRow in DTVentas.Rows) { - string tmpDate = dRow[3].ToString().ToDate().ToString("yyyy/MM/dd"); + DateTime tmpDate = dRow[3].ToString().ToDate().ToString("yyyy/MM/dd").ToDate(); dRow[3] = tmpDate; } @@ -223,7 +223,7 @@ public class TareasJam : IHttpHandler dtCloned = DTAlmacenes.Clone(); - dtCloned.Columns[3].DataType = typeof(string); + dtCloned.Columns[3].DataType = typeof(DateTime); foreach (DataRow row in DTAlmacenes.Rows) { @@ -233,7 +233,7 @@ public class TareasJam : IHttpHandler DTAlmacenes = dtCloned; foreach (DataRow dRow in DTAlmacenes.Rows) { - string tmpDate = dRow[3].ToString().ToDate().ToString("yyyy/MM/dd"); + DateTime tmpDate = dRow[3].ToString().ToDate().ToString("yyyy/MM/dd").ToDate(); dRow[3] = tmpDate; } DTAlmacenes.AcceptChanges(); @@ -249,8 +249,6 @@ public class TareasJam : IHttpHandler if (!ErrorProceso) { - - ////////////////////////////////////////////////////////////// int count = 2; var wbVentas = new ClosedXML.Excel.XLWorkbook(FormatoVentas); @@ -261,7 +259,7 @@ public class TareasJam : IHttpHandler wsVentas.Cell(count, 1).Value = "'" + DRow["systemId"].ToString(); wsVentas.Cell(count, 2).Value = DRow["Branch"].ToString(); wsVentas.Cell(count, 3).Value = "'" + DRow["Code"].ToString(); - wsVentas.Cell(count, 4).Value = "'" + DRow["Sale Date"].ToString(); + wsVentas.Cell(count, 4).Value = DRow["Sale Date"].ToString(); wsVentas.Cell(count, 5).Value = DRow["Quantity"].ToString(); wsVentas.Cell(count, 6).Value = DRow["Amount"].ToString(); wsVentas.Cell(count, 7).Value = DRow["Transaction ID"].ToString(); @@ -279,7 +277,7 @@ public class TareasJam : IHttpHandler wsAlmacenes.Cell(count, 1).Value = "'" + DRow["Code"].ToString(); wsAlmacenes.Cell(count, 2).Value = DRow["Quantity"].ToString(); wsAlmacenes.Cell(count, 3).Value = DRow["Description"].ToString(); - wsAlmacenes.Cell(count, 4).Value = "'" + DRow["Stock Date"].ToString(); + wsAlmacenes.Cell(count, 4).Value = DRow["Stock Date"].ToString(); count++; } wbAlmacenes.SaveAs(RutaAlmacenes); @@ -455,7 +453,7 @@ public class TareasJam : IHttpHandler Ventas.Ruta = RutaVentas; Clientes.Ruta = RutaClientes; Almacenes.Ruta = RutaAlmacenes; - + ListaArchivos.Add(Productos); ListaArchivos.Add(Ventas); ListaArchivos.Add(Clientes); @@ -479,7 +477,7 @@ public class TareasJam : IHttpHandler private bool CargarArchivos(FileInfo FInfo, string FTPServer, string FTPUsr, string FTPPass ) { bool Respuesta; - + if (FInfo.Exists) { FtpWebRequest request = (FtpWebRequest)WebRequest.Create($"{FTPServer}/{FInfo.Name}"); diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index e83a4b491..3fd7ef33f 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -21907,7 +21907,14 @@ Partial Class Ventas Dim Mensaje = UsuarioActual.Empresa.Funcionalidad(152) If Mensaje = "" Then Return 0 - Dim Celular = ObjFactura.Cliente.CobranzaTelefono + Dim Celular As String = "" + + Try + Celular = ObjFactura.Cliente.CobranzaTelefono + Catch ex As Exception + + End Try + If Celular.Length <> 10 Then Return 3 'ARMA MENSAJE