diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb
index 04f11c855..81a59e8f0 100644
--- a/App_Code/ClsInventarios.vb
+++ b/App_Code/ClsInventarios.vb
@@ -65,6 +65,8 @@ Public Class ClsInventarios
Public Property ConceptoRelacionado As String
Public Property CveMovimientoVirtual As Integer
Public Property FolioVirtual As Integer
+ Public Property CveMovimientoTransitorio As Integer
+ Public Property FolioTransitorio As Integer
Public Property Folio As Integer
Public Property IDPoliza As Integer
Public Property CvePrePoliza As Integer
@@ -829,7 +831,10 @@ Public Class ClsInventarios
TieneRelacionado = If(dr("TieneRelacionado").ToString.ToEntero > 0, 1, -1)
ConceptoRelacionado = dr("ConceptoRelacionado").ToString
CveMovimientoVirtual = dr("CveMovimientoVirtual").ToString.ToEntero
+
FolioVirtual = dr("FolioVirtual").ToString.ToEntero
+ CveMovimientoTransitorio = dr("CveMovimientoTransitorio").ToString.ToEntero
+ FolioTransitorio = dr("FolioTransitorio").ToString.ToEntero
TipoCambio = dr("TipoCambio").ToString.ToDouble
FolioVenta = dr("FolioVenta").ToString
diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb
index c557b907e..df4f9c307 100644
--- a/App_Code/Modelos.vb
+++ b/App_Code/Modelos.vb
@@ -5308,6 +5308,8 @@ Namespace Modelos
If Not ErrorCancelar Then
Dim Filtro As String = ""
Dim FiltroDevAlmacen As String = ""
+ Dim FiltroEntradaUsados As String = ""
+
Select Case ObjFactura.TipoDocto
Case "Ing"
Filtro = "CveConcepto IN (3, 40)"
@@ -5318,6 +5320,10 @@ Namespace Modelos
Filtro = "CveConcepto = 18"
Case Else
Filtro = "CveConcepto = 9"
+ 'VERIFICA SI TIENE ENTRADAS DE USADOS TAMBIEN
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ObjFactura.TipoDocto = "Rem" Then
+ FiltroEntradaUsados = "CveConcepto = 42"
+ End If
End Select
'CARGA REMISIONES DE LA VENTA DEVUELTA
@@ -5342,6 +5348,14 @@ Namespace Modelos
DtExistencias = DtInventario.FiltraParametros($"CvePS IS NOT NULL AND {Filtro} AND CveTipoPS = 2")
TieneSalida = DtExistencias.Rows.Count > 0
+
+ 'VERIFICA SI SOLO TIENE CARGA DE USADOS EN CASO DE NO TENER SALIDAS DE ALMACEN
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ObjFactura.TipoDocto = "Rem" Then
+ FiltroEntradaUsados = "CveConcepto = 42"
+ If Not TieneSalida Then
+ TieneSalida = DtInventario.FiltraParametros($"CvePS IS NOT NULL AND {FiltroEntradaUsados}").Rows.Count > 0
+ End If
+ End If
Else
ErrorCancelar = True
MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar."
diff --git a/Bancos/PagoDeudor.aspx.cs b/Bancos/PagoDeudor.aspx.cs
index 4a6183671..c4e0bac4f 100644
--- a/Bancos/PagoDeudor.aspx.cs
+++ b/Bancos/PagoDeudor.aspx.cs
@@ -336,7 +336,7 @@ public partial class Bancos_PagoDeudor : ClsPaginas
// DATOS PREPOLIZA
if (DdlTipoTransaccionPrestamo.SelectedValue == "1" && UsuarioActual.CveEmpresa != 119) FolioFijo = TxtFolioPrestamo.Text.ToEntero();
- CvePrePoliza = ObjMov.AddPrePolizas("Bancos/IE PRESTAMO DEUDORES", CvePlantillaPoliza, TxtImportePrestamo.Text.Trim().ToDouble(), TxtImportePrestamo.Text.Trim().ToDouble(), CveMonedaPrestamo, TxtFechaPrestamo.Text.ToDate(), DdlProveedorPrestamo.SelectedText.ToString(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransaccionPrestamo.SelectedValue, "-1", UsuarioActual.CveEmpresa));
+ CvePrePoliza = ObjMov.AddPrePolizas("PRESTAMO DEUDORES", CvePlantillaPoliza, TxtImportePrestamo.Text.Trim().ToDouble(), TxtImportePrestamo.Text.Trim().ToDouble(), CveMonedaPrestamo, TxtFechaPrestamo.Text.ToDate(), DdlProveedorPrestamo.SelectedText.ToString(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransaccionPrestamo.SelectedValue, "-1", UsuarioActual.CveEmpresa));
if (CvePrePoliza > 0)
{
@@ -671,7 +671,7 @@ public partial class Bancos_PagoDeudor : ClsPaginas
// DATOS PREPOLIZA
if (DdlTipoTransaccion.SelectedValue == "1" && UsuarioActual.CveEmpresa != 119) FolioFijo = TxtFolio.Text.ToEntero();
- CvePrePoliza = ObjMov.AddPrePolizas("Bancos/IE PAGO DEUDORES", CvePlantillaPoliza, TxtImporte.Text.Trim().ToDouble(), TxtImporte.Text.Trim().ToDouble(), CveMoneda, TxtFechaDocumento.Text.ToDate(), DdlProveedores.SelectedText.ToString(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa));
+ CvePrePoliza = ObjMov.AddPrePolizas("PAGO DEUDORES", CvePlantillaPoliza, TxtImporte.Text.Trim().ToDouble(), TxtImporte.Text.Trim().ToDouble(), CveMoneda, TxtFechaDocumento.Text.ToDate(), DdlProveedores.SelectedText.ToString(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa));
if (CvePrePoliza > 0)
{
diff --git a/Bancos/PrestamoPersonal.aspx.cs b/Bancos/PrestamoPersonal.aspx.cs
index 038100bf5..09dbde1c3 100644
--- a/Bancos/PrestamoPersonal.aspx.cs
+++ b/Bancos/PrestamoPersonal.aspx.cs
@@ -263,7 +263,7 @@ public partial class Bancos_PrestamoPersonal : ClsPaginas
// DATOS PREPOLIZA
if (DdlTipoTransaccion.SelectedValue == "1" && UsuarioActual.CveEmpresa != 119) FolioFijo = TxtFolio.Text.ToEntero();
- CvePrePoliza = ObjMov.AddPrePolizas("Bancos/IE PAGO ACRREDORES", CvePlantillaPoliza, TxtImporte.Text.Trim().ToDouble(), TxtImporte.Text.Trim().ToDouble(), CveMoneda, TxtFechaDocumento.Text.ToDate(), DdlFuncionarioEmpleadoPago.SelectedItem.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa));
+ CvePrePoliza = ObjMov.AddPrePolizas("Bancos/IE PAGO PRESTAMOPER", CvePlantillaPoliza, TxtImporte.Text.Trim().ToDouble(), TxtImporte.Text.Trim().ToDouble(), CveMoneda, TxtFechaDocumento.Text.ToDate(), DdlFuncionarioEmpleadoPago.SelectedItem.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa));
if (CvePrePoliza > 0)
{
diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb
index 9dfcbe489..c148ba7af 100644
--- a/Compras/PopUpVerFactura.aspx.vb
+++ b/Compras/PopUpVerFactura.aspx.vb
@@ -5196,7 +5196,7 @@ Partial Class PopUpVerFactura
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("Direccion", Almacen))
- params.Add(New ReportParameter("FechaConFormato", Now.ToString("dd/MM/yyyy")))
+ params.Add(New ReportParameter("FechaConFormato", Fecha))
'params.Add(New ReportParameter("FechaInicial", Fecha))
'params.Add(New ReportParameter("FechaFinal", Today.ToString("dd/MM/yyyy")))
params.Add(New ReportParameter("Sucursal", "Sucursal"))
diff --git a/Inventarios/EntradasSalidas.aspx b/Inventarios/EntradasSalidas.aspx
index caa056712..1ce8ec81e 100644
--- a/Inventarios/EntradasSalidas.aspx
+++ b/Inventarios/EntradasSalidas.aspx
@@ -513,6 +513,14 @@
Virtual
+
+
+
+
diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb
index ebc7303a3..c57e02d42 100644
--- a/Inventarios/EntradasSalidas.aspx.vb
+++ b/Inventarios/EntradasSalidas.aspx.vb
@@ -730,8 +730,17 @@ Partial Class Inventarios_EntradasSalidas
If Mov.CveMovimientoVirtual > 0 Then
DivMovtoVirtual.Visible = True
HplMtoVirtual.NavigateUrl = "/Inventarios/EntradasSalidas.aspx?CveMovimiento=" & Mov.CveMovimientoVirtual
+ HplMtoVirtual.Text = Mov.FolioVirtual.ToString
End If
+ If Mov.CveMovimientoTransitorio > 0 Then
+ DivMovtoTransitorio.Visible = True
+ HplMtoTransitorio.NavigateUrl = "/Inventarios/EntradasSalidas.aspx?CveMovimiento=" & Mov.CveMovimientoTransitorio
+ HplMtoTransitorio.Text = Mov.FolioTransitorio.ToString
+ End If
+
+
+
If (DdlAlmacen.Items.FindByValue(Mov.CveAlmacen.ToString()) Is Nothing) Then
Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveEstatus:=-1).FiltroPrimero(String.Format("CveAlmacen = {0}", Mov.CveAlmacen))
If dr IsNot Nothing Then
@@ -1798,7 +1807,7 @@ Partial Class Inventarios_EntradasSalidas
If DdlConcepto.SelectedValue.ToEntero = 31 Then
IdCtaContableOtro = 1319
End If
-
+ EsContabilizable = False
Case 30
CveConceptoContable = 181
TipoMovtoOtro = False
@@ -3805,26 +3814,26 @@ Partial Class Inventarios_EntradasSalidas
End If
Else
If DdlConcepto.SelectedValue.Contiene("6", "22", "23", "7", "16", "21", "24") Then
- 'genero las prepolizas manuales
- Dim tCveConcepto As Integer = 95
- Dim CveCuenta As Integer
- If UsuarioActual.CveEmpresa = 119 Then CveCuenta = 55519
- IdCtaContable = 1
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total"), Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total"), CveSubProyecto:=-1, CveCuenta:=CveCuenta, Contabilizable:=Contabilizable) Then
- ErrorMovInv = True
+ 'genero las prepolizas manuales
+ Dim tCveConcepto As Integer = 95
+ Dim CveCuenta As Integer
+ If UsuarioActual.CveEmpresa = 119 Then CveCuenta = 55519
+ IdCtaContable = 1
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total"), Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total"), CveSubProyecto:=-1, CveCuenta:=CveCuenta, Contabilizable:=Contabilizable) Then
+ ErrorMovInv = True
- End If
+ End If
- Else
+ Else
- Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero
+ Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero
Dim tCveConcepto As Integer = 69
- If DdlConcepto.SelectedValue = "30" Then
- tCveConcepto = 181
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(342).ToEntero
- End If
+ If ObjInventario.CveConcepto = 37 Then
+ tCveConcepto = 181
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(342).ToEntero
+ End If
- For Each RowInv As DataRow In tmpCostos.Rows
+ For Each RowInv As DataRow In tmpCostos.Rows
ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal.RoundSQL
If tCveConcepto = 69 Then
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb
index fea4ddc65..aba81d922 100644
--- a/Inventarios/EntregaAlmacen.aspx.vb
+++ b/Inventarios/EntregaAlmacen.aspx.vb
@@ -2064,10 +2064,25 @@ Partial Class Inventarios_EntregaAlmacen
End If
If ErrorMovInv Then Exit For
-
Next
End If
+ If Not ErrorMovInv Then
+ Dim CvePrePolizaSinCosto As Integer = ObjConta.AddPrePolizas("EA/SinCost", 53, 0, 0, 1, TxtFecha.Text.ToDate, "Entrega", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If CvePrePolizaSinCosto > 0 Then
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaSinCosto, False, 0, 0, 68, TxtObservaciones.Text, TxtObservaciones.Text, -1, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=False) Then
+ ErrorMovInv = True
+ End If
+
+ If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePolizaSinCosto, True, 0, 0, 68, TxtObservaciones.Text, TxtObservaciones.Text, -1, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=False) Then
+ ErrorMovInv = True
+ End If
+ Else
+ ErrorMovInv = True
+ End If
+ End If
+
Dim ImportePrePoliza As Decimal = 0D
diff --git a/Inventarios/EntregaAlmacenRuta.aspx.cs b/Inventarios/EntregaAlmacenRuta.aspx.cs
index 2d1bcef57..1b367e86d 100644
--- a/Inventarios/EntregaAlmacenRuta.aspx.cs
+++ b/Inventarios/EntregaAlmacenRuta.aspx.cs
@@ -1,218 +1,217 @@
-using Extensiones;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Text;
-using System.Web.UI.WebControls;
-
-public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
-{
-
- DataTable DTGenerarDocumentos
- {
- get
- {
-
- if (ViewState["DTGenerarDocumentos"] == null)
- {
- ViewState["DTGenerarDocumentos"] = new DataTable();
- }
- return (DataTable)ViewState["DTGenerarDocumentos"];
-
- }
- set
- {
- ViewState["DTGenerarDocumentos"] = (DataTable)value;
- }
- }
-
- DataTable DTDatosConsulta
- {
- get
- {
-
- if (ViewState["DTDatosConsulta"] == null)
- {
- ViewState["DTDatosConsulta"] = new DataTable();
- }
- return (DataTable)ViewState["DTDatosConsulta"];
-
- }
- set
- {
- ViewState["DTDatosConsulta"] = (DataTable)value;
- }
- }
-
-
- DataTable DTRecoleccion
- {
- get
- {
- if (ViewState["DTRecoleccion"] == null)
- {
- ViewState["DTRecoleccion"] = InitDTRecoleccion();
- }
- return (DataTable)ViewState["DTRecoleccion"];
- }
- set
- {
- ViewState["DTRecoleccion"] = (DataTable)value;
- }
- }
-
- bool SeleccionEntrega
- {
- get
- {
- if (ViewState["SeleccionEntrega"] == null)
- {
- ViewState["SeleccionEntrega"] = false;
- }
- return (bool)ViewState["SeleccionEntrega"];
- }
- set
- {
- ViewState["SeleccionEntrega"] = (bool)value;
- }
- }
-
- int CveEntregaAlmacen
- {
- get
- {
-
- if (ViewState["CveEntregaAlmacen"] == null)
- {
- ViewState["CveEntregaAlmacen"] = -1;
- }
- return (int)ViewState["CveEntregaAlmacen"];
- }
- set
- {
- ViewState["CveEntregaAlmacen"] = (int)value;
- }
- }
-
-
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
-
- SeleccionEntrega = true;
- CargaCombos();
- CargaDatos();
-
- #region RECOLEECION
- // CargaDatosRecoleccion();
-
- #endregion
-
- }
- }
-
- protected void BtnAsignar_Click(object sender, EventArgs e)
- {
-
-
- if (DdlChofer.SelectedValue.ToEntero() <= 0)
- {
- Alert("Debe seleccionar un chofer.", ModExtensiones.TipoMensaje.MsgAdvertencia);
- return;
- }
-
- if (DdlUnidadCamion.SelectedValue.ToEntero() <= 0)
- {
- Alert("Debe seleccionar una unidad", ModExtensiones.TipoMensaje.MsgAdvertencia);
- return;
- }
-
- StringBuilder SBError = new StringBuilder();
- ActualizaOrdenDTGenerarDocumentos();
- List ListaTimbres = new List();
-
-
- bool TieneError = false;
- ClsGenerales ObjGeneral = new ClsGenerales();
- ObjGeneral.IniciaTransacSQL();
- GridViewRowCollection Grid = GvGenerarDocumentos.Rows;
- string Usuario = DdlChofer.SelectedItem.Text;
-
-
-
- int CveDireccionOrigen = -1;
- foreach (GridViewRow row in Grid)
- {
- int Orden = row.DataKey("Orden").ToEntero();
- int CveDireccionDestino = row.DataKey("CveDireccionEnvio").ToEntero();
-
- if (CveDireccionDestino <= 0)
- {
- SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} el cliente {row.DataKey("Nombre")} no tiene una dirección de envio. ");
- TieneError = true;
- break;
- }
- DateTime fechallegada = (TxtFechaEntrega.Text + " 23:59").ToDate();
- int CveEntregaAlmacen = ObjGeneral.AddInvEntregaAlmacenRuta(row.DataKey("CveSubProyectoOrigen").ToEntero(), CveDireccionOrigen, CveDireccionDestino, row.DataKey("CveMovimiento").ToEntero(), DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), fechallegada, "E", "", "", "1900-01-01".ToDate(), Orden, 0, 1);
- CveDireccionOrigen = row.DataKey("CveDireccionEnvio").ToEntero();
-
- if (CveEntregaAlmacen > 0)
- {
- int CveTimbre = ObjGeneral.AddGralTimbre("Ent", row.DataKey("CveSubProyectoOrigen").ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen: CveEntregaAlmacen, AplicaCP: ChkEmitirCartaPorte.Checked);
-
- if (CveTimbre <= 0)
- {
- SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar timbre. ");
-
- TieneError = true;
- break;
- }
- else
- {
- ListaTimbres.Add(CveTimbre);
- }
- }
- else
- {
- SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar entrega almacen. ");
- TieneError = true;
- break;
- }
- }
-
-
- if (!TieneError)
- {
-
- foreach (GridViewRow row in Grid)
- {
- try
- {
- //MandarNotificacionCorreo(row);
- }
- catch (Exception ex)
- {
- TieneError = true;
- ModExtensiones.GuardaLog(ex.Message);
- }
- }
-
- if (!TieneError)
- {
- ObjGeneral.Commit();
- StringBuilder MensajeAlert = new StringBuilder();
- //recorrer para timbrar
- MensajeAlert.Append(" Entregas creadas correctamente
");
- bool huboerror = false;
-
- foreach (int cvetimbre in ListaTimbres)
- {
- Timbres ObjTimbres = new Timbres("Ent", cvetimbre, UsuarioActual);
- MensajeAlert.AppendFormat("Folio: {0} ", ObjTimbres.ObjFactura.SerieFolio);
- if (ObjTimbres.Timbrar())
- {
-
+using Extensiones;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Text;
+using System.Web.UI.WebControls;
+
+public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
+{
+
+ DataTable DTGenerarDocumentos
+ {
+ get
+ {
+
+ if (ViewState["DTGenerarDocumentos"] == null)
+ {
+ ViewState["DTGenerarDocumentos"] = new DataTable();
+ }
+ return (DataTable)ViewState["DTGenerarDocumentos"];
+
+ }
+ set
+ {
+ ViewState["DTGenerarDocumentos"] = (DataTable)value;
+ }
+ }
+
+ DataTable DTDatosConsulta
+ {
+ get
+ {
+
+ if (ViewState["DTDatosConsulta"] == null)
+ {
+ ViewState["DTDatosConsulta"] = new DataTable();
+ }
+ return (DataTable)ViewState["DTDatosConsulta"];
+
+ }
+ set
+ {
+ ViewState["DTDatosConsulta"] = (DataTable)value;
+ }
+ }
+
+
+ DataTable DTRecoleccion
+ {
+ get
+ {
+ if (ViewState["DTRecoleccion"] == null)
+ {
+ ViewState["DTRecoleccion"] = InitDTRecoleccion();
+ }
+ return (DataTable)ViewState["DTRecoleccion"];
+ }
+ set
+ {
+ ViewState["DTRecoleccion"] = (DataTable)value;
+ }
+ }
+
+ bool SeleccionEntrega
+ {
+ get
+ {
+ if (ViewState["SeleccionEntrega"] == null)
+ {
+ ViewState["SeleccionEntrega"] = false;
+ }
+ return (bool)ViewState["SeleccionEntrega"];
+ }
+ set
+ {
+ ViewState["SeleccionEntrega"] = (bool)value;
+ }
+ }
+
+ int CveEntregaAlmacen
+ {
+ get
+ {
+
+ if (ViewState["CveEntregaAlmacen"] == null)
+ {
+ ViewState["CveEntregaAlmacen"] = -1;
+ }
+ return (int)ViewState["CveEntregaAlmacen"];
+ }
+ set
+ {
+ ViewState["CveEntregaAlmacen"] = (int)value;
+ }
+ }
+
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!IsPostBack)
+ {
+
+ SeleccionEntrega = true;
+ CargaCombos();
+ CargaDatos();
+
+ #region RECOLEECION
+ // CargaDatosRecoleccion();
+
+ #endregion
+
+ }
+ }
+
+ protected void BtnAsignar_Click(object sender, EventArgs e)
+ {
+
+
+ if (DdlChofer.SelectedValue.ToEntero() <= 0)
+ {
+ Alert("Debe seleccionar un chofer.", ModExtensiones.TipoMensaje.MsgAdvertencia);
+ return;
+ }
+
+ if (DdlUnidadCamion.SelectedValue.ToEntero() <= 0)
+ {
+ Alert("Debe seleccionar una unidad", ModExtensiones.TipoMensaje.MsgAdvertencia);
+ return;
+ }
+
+ StringBuilder SBError = new StringBuilder();
+ ActualizaOrdenDTGenerarDocumentos();
+ List ListaTimbres = new List();
+
+
+ bool TieneError = false;
+ ClsGenerales ObjGeneral = new ClsGenerales();
+ ObjGeneral.IniciaTransacSQL();
+ GridViewRowCollection Grid = GvGenerarDocumentos.Rows;
+ string Usuario = DdlChofer.SelectedItem.Text;
+
+
+
+ int CveDireccionOrigen = -1;
+ foreach (GridViewRow row in Grid)
+ {
+ int Orden = row.DataKey("Orden").ToEntero();
+ int CveDireccionDestino = row.DataKey("CveDireccionEnvio").ToEntero();
+
+ if (CveDireccionDestino <= 0)
+ {
+ SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} el cliente {row.DataKey("Nombre")} no tiene una dirección de envio. ");
+ TieneError = true;
+ break;
+ }
+ DateTime fechallegada = (TxtFechaEntrega.Text + " 23:59").ToDate();
+ int CveEntregaAlmacen = ObjGeneral.AddInvEntregaAlmacenRuta(row.DataKey("CveSubProyectoOrigen").ToEntero(), CveDireccionOrigen, CveDireccionDestino, row.DataKey("CveMovimiento").ToEntero(), DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), fechallegada, "E", "", "", "1900-01-01".ToDate(), Orden, 0, 1);
+ CveDireccionOrigen = row.DataKey("CveDireccionEnvio").ToEntero();
+
+ if (CveEntregaAlmacen > 0)
+ {
+ int CveTimbre = ObjGeneral.AddGralTimbre("Ent", row.DataKey("CveSubProyectoOrigen").ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen: CveEntregaAlmacen, AplicaCP: ChkEmitirCartaPorte.Checked);
+
+ if (CveTimbre <= 0)
+ {
+ SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar timbre. ");
+
+ TieneError = true;
+ break;
+ }
+ else
+ {
+ ListaTimbres.Add(CveTimbre);
+ }
+ }
+ else
+ {
+ SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar entrega almacen. ");
+ TieneError = true;
+ break;
+ }
+ }
+
+
+ if (!TieneError)
+ {
+
+ foreach (GridViewRow row in Grid)
+ {
+ try
+ {
+ //MandarNotificacionCorreo(row);
+ }
+ catch (Exception ex)
+ {
+ TieneError = true;
+ ModExtensiones.GuardaLog(ex.Message);
+ }
+ }
+
+ if (!TieneError)
+ {
+ ObjGeneral.Commit();
+ StringBuilder MensajeAlert = new StringBuilder();
+ //recorrer para timbrar
+ MensajeAlert.Append(" Entregas creadas correctamente
");
+
+ foreach (int cvetimbre in ListaTimbres)
+ {
+ Timbres ObjTimbres = new Timbres("Ent", cvetimbre, UsuarioActual);
+ MensajeAlert.AppendFormat("Folio: {0} ", ObjTimbres.ObjFactura.SerieFolio);
+ if (ObjTimbres.Timbrar())
+ {
+
MensajeAlert.AppendFormat("XML ", ModExtensiones.Encripta(String.Format("OP=DesXmlTra&CveTimbre={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", cvetimbre, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto)));
if (ChkEmitirCartaPorte.Checked)
{
@@ -223,81 +222,80 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
MensajeAlert.AppendFormat("PDF ", ModExtensiones.Encripta(String.Format("OP=CARPO&CVETIMBRE={0}", cvetimbre)));
}
- MensajeAlert.Append("
");
-
- DdlChofer.SelectedValueExist("-1");
- DdlUnidadCamion.SelectedValueExist("-1");
- ChkEmitirCartaPorte.Checked = false;
-
- SeleccionEntrega = false;
- SeleccionarGenerar(1);
- }
- else
- {
- huboerror = true;
- MensajeAlert.AppendFormat("", ObjTimbres.MsgError);
- }
- }
- Alert(MensajeAlert.ToString(), ModExtensiones.TipoMensaje.MsgInformacion);
- CargaDatos();
- UpDatos.Update();
- }
- else
- {
- ObjGeneral.RollBack();
- }
- ObjGeneral.Dispose();
- }
- else
- {
- Alert(SBError.ToString(), ModExtensiones.TipoMensaje.MsgAdvertencia);
- }
- }
-
-
- protected void LnkGeneraRecoleccion_Click(object sender, EventArgs e)
- {
- if (DdlChoferRec.SelectedValue.ToEntero() <= 0)
- {
- Alert("Debe seleccionar un chofer.", ModExtensiones.TipoMensaje.MsgAdvertencia);
- return;
- }
-
- if (DdlUnidadRec.SelectedValue.ToEntero() <= 0)
- {
- Alert("Debe seleccionar una unidad", ModExtensiones.TipoMensaje.MsgAdvertencia);
- return;
- }
-
-
- StringBuilder SBError = new StringBuilder();
- //ActualizaOrdenDTGenerarDocumentos();
- List ListaTimbres = new List();
-
- bool TieneError = false;
- ClsGenerales ObjGeneral = new ClsGenerales();
- ObjGeneral.IniciaTransacSQL();
+ MensajeAlert.Append("
");
+
+ DdlChofer.SelectedValueExist("-1");
+ DdlUnidadCamion.SelectedValueExist("-1");
+ ChkEmitirCartaPorte.Checked = false;
+
+ SeleccionEntrega = false;
+ SeleccionarGenerar(1);
+ }
+ else
+ {
+ MensajeAlert.AppendFormat("", ObjTimbres.MsgError);
+ }
+ }
+ Alert(MensajeAlert.ToString(), ModExtensiones.TipoMensaje.MsgInformacion);
+ CargaDatos();
+ UpDatos.Update();
+ }
+ else
+ {
+ ObjGeneral.RollBack();
+ }
+ ObjGeneral.Dispose();
+ }
+ else
+ {
+ Alert(SBError.ToString(), ModExtensiones.TipoMensaje.MsgAdvertencia);
+ }
+ }
+
+
+ protected void LnkGeneraRecoleccion_Click(object sender, EventArgs e)
+ {
+ if (DdlChoferRec.SelectedValue.ToEntero() <= 0)
+ {
+ Alert("Debe seleccionar un chofer.", ModExtensiones.TipoMensaje.MsgAdvertencia);
+ return;
+ }
+
+ if (DdlUnidadRec.SelectedValue.ToEntero() <= 0)
+ {
+ Alert("Debe seleccionar una unidad", ModExtensiones.TipoMensaje.MsgAdvertencia);
+ return;
+ }
+
+
+ StringBuilder SBError = new StringBuilder();
+ //ActualizaOrdenDTGenerarDocumentos();
+ List ListaTimbres = new List();
+
+ bool TieneError = false;
+ ClsGenerales ObjGeneral = new ClsGenerales();
+ ObjGeneral.IniciaTransacSQL();
try
{
string Usuario = DdlChofer.SelectedItem.Text;
-
+
int CveDireccionOrigen = -1;
foreach (GridViewRow row in gvR.Rows)
{
int Orden = row.DataKey("Orden").ToEntero();
int CveEntregaAlmacen = row.DataKey("CveEntregaAlmacen").ToEntero();
-
+
if (row.FCCheckBox("Chk").Checked)
{
CveDireccionOrigen = row.DataKey("CveDireccionOrigen").ToEntero();
-
- if (CveEntregaAlmacen > 0)
- {
- // se actualizan los datos de unidad, chofer, fechas y Carta porte
- if (ObjGeneral.AsignaEntregaAlmacenRuta(DdlUnidadRec.SelectedValue.ToEntero(), DdlChoferRec.SelectedValue.ToEntero(), TxtFechaRec.Text.ToDate(), CveEntregaAlmacen, UsuarioActual.CveEmpresa))
- {
- int CveTimbre = ObjGeneral.AddGralTimbre("Rec", row.DataKey("CveSubProyecto").ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen: CveEntregaAlmacen, AplicaCP: ChkEmitirPorteRec.Checked);
-
+
+ if (CveEntregaAlmacen > 0)
+ {
+ // se actualizan los datos de unidad, chofer, fechas y Carta porte
+ if (ObjGeneral.AsignaEntregaAlmacenRuta(DdlUnidadRec.SelectedValue.ToEntero(), DdlChoferRec.SelectedValue.ToEntero(), TxtFechaRec.Text.ToDate(), (TxtFechaRec.Text + " 23:59").ToDate(), CveEntregaAlmacen, UsuarioActual.CveEmpresa))
+ {
+ int CveTimbre = ObjGeneral.AddGralTimbre("Rec", row.DataKey("CveSubProyecto").ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen: CveEntregaAlmacen, AplicaCP: ChkEmitirPorteRec.Checked);
+
if (CveTimbre <= 0)
{
SBError.AppendLine($"Folio {row.DataKey("FolioReferencia")} ocurrió un error al agregar timbre. ");
@@ -330,9 +328,9 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
TieneError = true;
this.OnError("Ocurrió un error al generar la entrega", ex);
}
-
- if (!TieneError)
- {
+
+ if (!TieneError)
+ {
ObjGeneral.Commit();
}
else
@@ -340,7 +338,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
ObjGeneral.RollBack();
}
ObjGeneral.Dispose();
-
+
if (!TieneError)
{
StringBuilder MensajeAlert = new StringBuilder();
@@ -350,7 +348,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
foreach (int cvetimbre in ListaTimbres)
{
Timbres ObjTimbres = new Timbres("Rec", cvetimbre, UsuarioActual);
-
+
if (ObjTimbres.Timbrar())
{
@@ -359,7 +357,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
if (ChkEmitirPorteRec.Checked)
{
- MensajeAlert.AppendFormat("PDF ", ModExtensiones.Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", cvetimbre)));
+ MensajeAlert.AppendFormat("PDF ", ModExtensiones.Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", cvetimbre)));
}
else
{
@@ -367,7 +365,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
}
MensajeAlert.Append("
");
-
+
}
else
{
@@ -380,7 +378,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
CargaDatosRecoleccion();
DdlChofer.SelectedValueExist("-1");
DdlUnidadCamion.SelectedValueExist("-1");
-
+
SeleccionEntrega = false;
SeleccionarGenerar(1);
UpDatos.Update();
@@ -388,663 +386,663 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
else
{
Alert(SBError.ToString(), ModExtensiones.TipoMensaje.MsgError);
- }
-
- }
- private void CargaDatos()
- {
- ClsGenerales ObjGeneral = new ClsGenerales();
- if (ObjGeneral.GetInvEntregaAlmacenRuta(DdlSubProyecto.SelectedValue.ToEntero(), TxtFechaI.Text.ToDate(), TxtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 1))
- {
- GvEntregas.DataSource = ObjGeneral.DtResultados;
- DTDatosConsulta = ObjGeneral.DtResultados;
- DTGenerarDocumentos = ObjGeneral.DtResultados.Clone();
-
- }
- ObjGeneral.Dispose();
- GvEntregas.DataBind();
-
- UpDatos.Update();
- }
- private void CargaCombos()
- {
-
- DdlUnidadCamion.DataSource = get_GlobalDTInvCamiones(UsuarioActual.CveEmpresa);
- DdlUnidadCamion.Items.Insert(0, new ListItem("Seleccione", "-1"));
- DdlUnidadCamion.DataBind();
- DdlUnidadRec.DataSource = get_GlobalDTInvCamiones(UsuarioActual.CveEmpresa);
- DdlUnidadRec.Items.Insert(0, new ListItem("Seleccione", "-1"));
- DdlUnidadRec.DataBind();
-
- TxtFechaI.Text = DateTime.Now.AddDays(-1).ToShortDateString();
- TxtFechaF.Text = DateTime.Now.AddDays(3).ToShortDateString();
-
- DdlChofer.DataSource = get_GlobalDTChoferes(UsuarioActual.CveEmpresa);
- DdlChofer.DataBind();
- DdlChofer.Items.Insert(0, new ListItem("Seleccione", "-1"));
- DdlChoferRec.DataSource = get_GlobalDTChoferes(UsuarioActual.CveEmpresa);
- DdlChoferRec.DataBind();
- DdlChoferRec.Items.Insert(0, new ListItem("Seleccione", "-1"));
-
- TxtFechaEntrega.Text = DateTime.Now.ToShortDateString();
-
- TabRecoleccion.Visible = UsuarioActual.Empresa.Funcionalidad(531) == "1";
- TxtFechaLimite.Text = DateTime.Now.ToShortDateString();
-
- CargarCentrosDeCosto(null, DdlSubProyecto, null, LblSubProyecto);
- CargarCentrosDeCosto(null, DdlSubProyectoRecoleccion, null, LblSubProyectoRecoleccion);
-
- }
-
- protected void LnkGenerarDocumentos_Click(object sender, EventArgs e)
- {
- SeleccionarGenerar(1);
- }
- private void SeleccionarGenerar(int Opcion)
- {
-
- if (SeleccionEntrega)
- {
- DTGenerarDocumentos.Rows.Clear();
-
- if (Opcion == 2) //cuando es recolección
- {
- int CountRows = 0;
- foreach (GridViewRow GvRow in gvR.Rows)
- {
-
- CheckBox ChkAsigna = GvRow.FCCheckBox("Chk");
-
- if (ChkAsigna.Checked)
- {
-
- int CveMovimiento = GvRow.DataKey("Cve").ToEntero();
-
- DataRow dRow = DTGenerarDocumentos.NewRow();
- DataRow dRowOrigen = DTDatosConsulta.FiltraParametros($"CveMovimiento = {CveMovimiento}").Rows[0];
-
- int IndexColun = 0;
- foreach (DataColumn dColumn in DTDatosConsulta.Columns)
- {
- dRow[IndexColun] = dRowOrigen[IndexColun];
- IndexColun++;
- }
-
- dRow["Num"] = CountRows + 1;
- DTGenerarDocumentos.Rows.Add(dRow);
- CountRows++;
- }
- }
- }
- else
- {
-
- int CountRows = 0;
- foreach (GridViewRow GvRow in GvEntregas.Rows)
- {
-
- CheckBox ChkAsigna = GvRow.FCCheckBox("ChkAsigna");
-
- if (ChkAsigna.Checked)
- {
-
- int CveMovimiento = GvRow.DataKey("CveMovimiento").ToEntero();
-
- DataRow dRow = DTGenerarDocumentos.NewRow();
- DataRow dRowOrigen = DTDatosConsulta.FiltraParametros($"CveMovimiento = {CveMovimiento}").Rows[0];
-
- int IndexColun = 0;
- foreach (DataColumn dColumn in DTDatosConsulta.Columns)
- {
- dRow[IndexColun] = dRowOrigen[IndexColun];
- IndexColun++;
- }
-
- dRow["Num"] = CountRows + 1;
- DTGenerarDocumentos.Rows.Add(dRow);
- CountRows++;
- }
- }
-
- DTGenerarDocumentos.AcceptChanges();
-
- SeleccionEntrega = false;
- LnkGenerarDocumentos.Text = "Regresar";
- LnkGenerarDocumentos.CssClass = "btn btn-default";
-
- OcultarmostarDatosEntrega(true);
-
- BtnConsultar.Visible = false;
-
- UpDatos.Update();
- UpFiltro.Update();
-
- if (CountRows > 0)
- {
- GvGenerarDocumentos.DataSource = DTGenerarDocumentos;
- GvGenerarDocumentos.DataBind();
-
- DVGvGenerarDocumentos.Visible = true;
- BtnAsignar.Visible = true;
- DVGvEntregas.Visible = false;
-
- RegistraScript("InitOrdenamientoGvGenerarDocumentos();");
- }
- else
- {
- Alert("No hay entregas seleccionadas", ModExtensiones.TipoMensaje.MsgAdvertencia);
- return;
- }
-
- }
-
- }
- else
- {
-
- BtnConsultar.Visible = true;
- SeleccionEntrega = true;
- LnkGenerarDocumentos.Text = "Preseleccionar";
- LnkGenerarDocumentos.CssClass = "btn btn-primary";
-
-
- OcultarmostarDatosEntrega(false);
-
- BtnAsignar.Visible = false;
- DVGvGenerarDocumentos.Visible = false;
- DVGvEntregas.Visible = true;
- UpDatos.Update();
- UpFiltro.Update();
-
- }
- }
-
- private void OcultarmostarDatosEntrega(bool mostrar)
- {
- //DVDatosEntrega1.Visible = mostrar;
- DVDatosEntrega2.Visible = mostrar;
- //DVDatosEntrega3.Visible = mostrar;
- DVDatosEntrega4.Visible = mostrar;
- //DVDatosEntrega5.Visible = mostrar;
- DVDatosEntrega6.Visible = mostrar;
-
- //if (mostrar)
- //{
- // DVDatosEntrega7.Attributes.Add("class", "col-md-1");
- //}
- //else
- //{
- // DVDatosEntrega7.Attributes.Add("class", "col-md-9");
- //}
-
- if (UsuarioActual.Empresa.Funcionalidad(161).ToEntero() == 1)
- {
- DvCartaPorte2.Visible = mostrar;
- }
-
-
- }
-
-
- private void ActualizaOrdenDTGenerarDocumentos()
- {
- string[] OrdenMovimientos = Request.Form.GetValues("OrdenMovimientos");
-
- int NumOrden = 1;
- foreach (string CveMovimiento in OrdenMovimientos)
- {
- foreach (DataRow dRow in DTGenerarDocumentos.Rows)
- {
- if (CveMovimiento.ToEntero() == dRow["CveMovimiento"].ToString().ToEntero())
- {
- dRow["Orden"] = NumOrden;
- }
- }
- DTGenerarDocumentos.AcceptChanges();
- NumOrden++;
- }
-
- DataView DTview = new DataView(DTGenerarDocumentos);
-
- // Sort by State and ZipCode column in descending order
- DTview.Sort = "Orden ASC";
-
- GvGenerarDocumentos.DataSource = DTview;
- GvGenerarDocumentos.DataBind();
- UpDatos.Update();
-
-
-
- }
-
- protected void BtnConsultar_Click(object sender, EventArgs e)
- {
- if (Tab.ActiveTabIndex == 0)
- {
- CargaDatos();
- }
- else
- {
- CargaDatosRecoleccion();
- }
-
-
- }
-
-
- #region RECOLECCION
-
-
- private DataTable InitDTRecoleccion()
- {
- DataTable DT = new DataTable();
-
- DT.Columns.Add("CveEntregaAlmacenDetalle", System.Type.GetType("System.Int32"));
- DT.Columns.Add("CveEntregaAlmacen", System.Type.GetType("System.Int32"));
- DT.Columns.Add("CvePS", System.Type.GetType("System.Int32"));
- DT.Columns.Add("Cantidad", System.Type.GetType("System.Double"));
- DT.Columns.Add("CveUnidadMedida", System.Type.GetType("System.Int32"));
- DT.Columns.Add("CveUsuario", System.Type.GetType("System.Int32"));
- DT.Columns.Add("FechaIng", System.Type.GetType("System.DateTime"));
- DT.Columns.Add("CodigoPS", System.Type.GetType("System.String"));
- DT.Columns.Add("Abreviatura", System.Type.GetType("System.String"));
-
- return DT;
-
- }
-
- private void CargaDatosRecoleccion()
- {
- ClsGenerales ObjGeneral = new ClsGenerales();
- if (ObjGeneral.GetInvEntregaAlmacenRuta(DdlSubProyecto.SelectedValue.ToEntero(), TxtFechaI.Text.ToDate(), TxtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 2, 0))
- {
- gvR.DataSource = ObjGeneral.DtResultados;
- }
- ObjGeneral.Dispose();
- gvR.DataBind();
- UpDatosRecoleccion.Update();
- }
-
- private void CargaDatosRecoleccionDetallePS()
- {
- if (CveEntregaAlmacen > 0)
- {
- ClsGenerales ObjGenerales = new ClsGenerales();
-
- if (ObjGenerales.GetEntregaAlmacenRutaDetalle(CveEntregaAlmacen))
- {
- GvModalPSRecoleccion.DataSource = ObjGenerales.DtResultados;
- }
- else
- {
- GvModalPSRecoleccion.DataSource = null;
- }
- ObjGenerales.Dispose();
- }
- else
- {
- GvModalPSRecoleccion.DataSource = DTRecoleccion;
- }
- GvModalPSRecoleccion.DataBind();
- UpModalRecoleccion.Update();
- }
- protected void DdlModalRecoleccionCliente_SelectedIndexChanged(object sender, EventArgs e)
- {
- ModalRecoleccionCargaDirecciones();
- }
-
- private void ModalRecoleccionCargaDirecciones()
- {
- if (DdlModalRecoleccionCliente.SelectedValue.ToEntero() > 0)
- {
- ClsClientes ObjClientes = new ClsClientes();
- if (ObjClientes.DireccionEnvioGet(-1, DdlModalRecoleccionCliente.SelectedValue.ToEntero(), -1))
- {
- DdlmodalRecoleccionDireccion.DataSource = ObjClientes.DtResultados.FiltraParametros("CveSubProyecto = " + DdlSubProyectoRecoleccion.SelectedValue.ToEntero());
- }
- ObjClientes.Dispose();
- }
-
- DdlmodalRecoleccionDireccion.DataBind();
- DdlmodalRecoleccionDireccion.Items.Insert(0, new ListItem("Seleccione", "-1"));
-
- UpModalRecoleccion.Update();
- }
-
-
- protected void LnkAgregarRecoleccion_Click(object sender, EventArgs e)
- {
-
- LtlModalRecoleccionTitulo.Text = "Agregar Recolección";
- BtnModalRecoleccionGuardar.Text = "Agregar";
-
- LimpiarModalRecoleccion();
- RegistraScript("$('#DivModalRecoleccion').modal('show');");
- CveEntregaAlmacen = -1;
- }
-
- protected void LnkGvDatosRecoleccionEditar_Click(object sender, EventArgs e)
- {
- LinkButton LnkEliminar = (LinkButton)sender;
- GridViewRow GvRow = (GridViewRow)LnkEliminar.NamingContainer;
-
- CveEntregaAlmacen = GvRow.DataKey("CveEntregaAlmacen").ToEntero();
- int CveDireccionOrigen = GvRow.DataKey("CveDireccionOrigen").ToEntero();
- int CveClienteEnvio = -1;
- string NombreCliente = "";
- ClsClientes ObjClientes = new ClsClientes();
- DataTable DtTempDirecciones = new DataTable();
-
- if (ObjClientes.DireccionEnvioGet(CveDireccionOrigen, -1, -1))
- {
+ }
+
+ }
+ private void CargaDatos()
+ {
+ ClsGenerales ObjGeneral = new ClsGenerales();
+ if (ObjGeneral.GetInvEntregaAlmacenRuta(DdlSubProyecto.SelectedValue.ToEntero(), TxtFechaI.Text.ToDate(), TxtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 1))
+ {
+ GvEntregas.DataSource = ObjGeneral.DtResultados;
+ DTDatosConsulta = ObjGeneral.DtResultados;
+ DTGenerarDocumentos = ObjGeneral.DtResultados.Clone();
+
+ }
+ ObjGeneral.Dispose();
+ GvEntregas.DataBind();
+
+ UpDatos.Update();
+ }
+ private void CargaCombos()
+ {
+
+ DdlUnidadCamion.DataSource = get_GlobalDTInvCamiones(UsuarioActual.CveEmpresa);
+ DdlUnidadCamion.Items.Insert(0, new ListItem("Seleccione", "-1"));
+ DdlUnidadCamion.DataBind();
+ DdlUnidadRec.DataSource = get_GlobalDTInvCamiones(UsuarioActual.CveEmpresa);
+ DdlUnidadRec.Items.Insert(0, new ListItem("Seleccione", "-1"));
+ DdlUnidadRec.DataBind();
+
+ TxtFechaI.Text = DateTime.Now.AddDays(-1).ToShortDateString();
+ TxtFechaF.Text = DateTime.Now.AddDays(3).ToShortDateString();
+
+ DdlChofer.DataSource = get_GlobalDTChoferes(UsuarioActual.CveEmpresa);
+ DdlChofer.DataBind();
+ DdlChofer.Items.Insert(0, new ListItem("Seleccione", "-1"));
+ DdlChoferRec.DataSource = get_GlobalDTChoferes(UsuarioActual.CveEmpresa);
+ DdlChoferRec.DataBind();
+ DdlChoferRec.Items.Insert(0, new ListItem("Seleccione", "-1"));
+
+ TxtFechaEntrega.Text = DateTime.Now.ToShortDateString();
+
+ TabRecoleccion.Visible = UsuarioActual.Empresa.Funcionalidad(531) == "1";
+ TxtFechaLimite.Text = DateTime.Now.ToShortDateString();
+
+ CargarCentrosDeCosto(null, DdlSubProyecto, null, LblSubProyecto);
+ CargarCentrosDeCosto(null, DdlSubProyectoRecoleccion, null, LblSubProyectoRecoleccion);
+
+ }
+
+ protected void LnkGenerarDocumentos_Click(object sender, EventArgs e)
+ {
+ SeleccionarGenerar(1);
+ }
+ private void SeleccionarGenerar(int Opcion)
+ {
+
+ if (SeleccionEntrega)
+ {
+ DTGenerarDocumentos.Rows.Clear();
+
+ if (Opcion == 2) //cuando es recolección
+ {
+ int CountRows = 0;
+ foreach (GridViewRow GvRow in gvR.Rows)
+ {
+
+ CheckBox ChkAsigna = GvRow.FCCheckBox("Chk");
+
+ if (ChkAsigna.Checked)
+ {
+
+ int CveMovimiento = GvRow.DataKey("Cve").ToEntero();
+
+ DataRow dRow = DTGenerarDocumentos.NewRow();
+ DataRow dRowOrigen = DTDatosConsulta.FiltraParametros($"CveMovimiento = {CveMovimiento}").Rows[0];
+
+ int IndexColun = 0;
+ foreach (DataColumn dColumn in DTDatosConsulta.Columns)
+ {
+ dRow[IndexColun] = dRowOrigen[IndexColun];
+ IndexColun++;
+ }
+
+ dRow["Num"] = CountRows + 1;
+ DTGenerarDocumentos.Rows.Add(dRow);
+ CountRows++;
+ }
+ }
+ }
+ else
+ {
+
+ int CountRows = 0;
+ foreach (GridViewRow GvRow in GvEntregas.Rows)
+ {
+
+ CheckBox ChkAsigna = GvRow.FCCheckBox("ChkAsigna");
+
+ if (ChkAsigna.Checked)
+ {
+
+ int CveMovimiento = GvRow.DataKey("CveMovimiento").ToEntero();
+
+ DataRow dRow = DTGenerarDocumentos.NewRow();
+ DataRow dRowOrigen = DTDatosConsulta.FiltraParametros($"CveMovimiento = {CveMovimiento}").Rows[0];
+
+ int IndexColun = 0;
+ foreach (DataColumn dColumn in DTDatosConsulta.Columns)
+ {
+ dRow[IndexColun] = dRowOrigen[IndexColun];
+ IndexColun++;
+ }
+
+ dRow["Num"] = CountRows + 1;
+ DTGenerarDocumentos.Rows.Add(dRow);
+ CountRows++;
+ }
+ }
+
+ DTGenerarDocumentos.AcceptChanges();
+
+ SeleccionEntrega = false;
+ LnkGenerarDocumentos.Text = "Regresar";
+ LnkGenerarDocumentos.CssClass = "btn btn-default";
+
+ OcultarmostarDatosEntrega(true);
+
+ BtnConsultar.Visible = false;
+
+ UpDatos.Update();
+ UpFiltro.Update();
+
+ if (CountRows > 0)
+ {
+ GvGenerarDocumentos.DataSource = DTGenerarDocumentos;
+ GvGenerarDocumentos.DataBind();
+
+ DVGvGenerarDocumentos.Visible = true;
+ BtnAsignar.Visible = true;
+ DVGvEntregas.Visible = false;
+
+ RegistraScript("InitOrdenamientoGvGenerarDocumentos();");
+ }
+ else
+ {
+ Alert("No hay entregas seleccionadas", ModExtensiones.TipoMensaje.MsgAdvertencia);
+ return;
+ }
+
+ }
+
+ }
+ else
+ {
+
+ BtnConsultar.Visible = true;
+ SeleccionEntrega = true;
+ LnkGenerarDocumentos.Text = "Preseleccionar";
+ LnkGenerarDocumentos.CssClass = "btn btn-primary";
+
+
+ OcultarmostarDatosEntrega(false);
+
+ BtnAsignar.Visible = false;
+ DVGvGenerarDocumentos.Visible = false;
+ DVGvEntregas.Visible = true;
+ UpDatos.Update();
+ UpFiltro.Update();
+
+ }
+ }
+
+ private void OcultarmostarDatosEntrega(bool mostrar)
+ {
+ //DVDatosEntrega1.Visible = mostrar;
+ DVDatosEntrega2.Visible = mostrar;
+ //DVDatosEntrega3.Visible = mostrar;
+ DVDatosEntrega4.Visible = mostrar;
+ //DVDatosEntrega5.Visible = mostrar;
+ DVDatosEntrega6.Visible = mostrar;
+
+ //if (mostrar)
+ //{
+ // DVDatosEntrega7.Attributes.Add("class", "col-md-1");
+ //}
+ //else
+ //{
+ // DVDatosEntrega7.Attributes.Add("class", "col-md-9");
+ //}
+
+ if (UsuarioActual.Empresa.Funcionalidad(161).ToEntero() == 1)
+ {
+ DvCartaPorte2.Visible = mostrar;
+ }
+
+
+ }
+
+
+ private void ActualizaOrdenDTGenerarDocumentos()
+ {
+ string[] OrdenMovimientos = Request.Form.GetValues("OrdenMovimientos");
+
+ int NumOrden = 1;
+ foreach (string CveMovimiento in OrdenMovimientos)
+ {
+ foreach (DataRow dRow in DTGenerarDocumentos.Rows)
+ {
+ if (CveMovimiento.ToEntero() == dRow["CveMovimiento"].ToString().ToEntero())
+ {
+ dRow["Orden"] = NumOrden;
+ }
+ }
+ DTGenerarDocumentos.AcceptChanges();
+ NumOrden++;
+ }
+
+ DataView DTview = new DataView(DTGenerarDocumentos);
+
+ // Sort by State and ZipCode column in descending order
+ DTview.Sort = "Orden ASC";
+
+ GvGenerarDocumentos.DataSource = DTview;
+ GvGenerarDocumentos.DataBind();
+ UpDatos.Update();
+
+
+
+ }
+
+ protected void BtnConsultar_Click(object sender, EventArgs e)
+ {
+ if (Tab.ActiveTabIndex == 0)
+ {
+ CargaDatos();
+ }
+ else
+ {
+ CargaDatosRecoleccion();
+ }
+
+
+ }
+
+
+ #region RECOLECCION
+
+
+ private DataTable InitDTRecoleccion()
+ {
+ DataTable DT = new DataTable();
+
+ DT.Columns.Add("CveEntregaAlmacenDetalle", System.Type.GetType("System.Int32"));
+ DT.Columns.Add("CveEntregaAlmacen", System.Type.GetType("System.Int32"));
+ DT.Columns.Add("CvePS", System.Type.GetType("System.Int32"));
+ DT.Columns.Add("Cantidad", System.Type.GetType("System.Double"));
+ DT.Columns.Add("CveUnidadMedida", System.Type.GetType("System.Int32"));
+ DT.Columns.Add("CveUsuario", System.Type.GetType("System.Int32"));
+ DT.Columns.Add("FechaIng", System.Type.GetType("System.DateTime"));
+ DT.Columns.Add("CodigoPS", System.Type.GetType("System.String"));
+ DT.Columns.Add("Abreviatura", System.Type.GetType("System.String"));
+
+ return DT;
+
+ }
+
+ private void CargaDatosRecoleccion()
+ {
+ ClsGenerales ObjGeneral = new ClsGenerales();
+ if (ObjGeneral.GetInvEntregaAlmacenRuta(DdlSubProyecto.SelectedValue.ToEntero(), TxtFechaI.Text.ToDate(), TxtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 2, 0))
+ {
+ gvR.DataSource = ObjGeneral.DtResultados;
+ }
+ ObjGeneral.Dispose();
+ gvR.DataBind();
+ UpDatosRecoleccion.Update();
+ }
+
+ private void CargaDatosRecoleccionDetallePS()
+ {
+ if (CveEntregaAlmacen > 0)
+ {
+ ClsGenerales ObjGenerales = new ClsGenerales();
+
+ if (ObjGenerales.GetEntregaAlmacenRutaDetalle(CveEntregaAlmacen))
+ {
+ GvModalPSRecoleccion.DataSource = ObjGenerales.DtResultados;
+ }
+ else
+ {
+ GvModalPSRecoleccion.DataSource = null;
+ }
+ ObjGenerales.Dispose();
+ }
+ else
+ {
+ GvModalPSRecoleccion.DataSource = DTRecoleccion;
+ }
+ GvModalPSRecoleccion.DataBind();
+ UpModalRecoleccion.Update();
+ }
+ protected void DdlModalRecoleccionCliente_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ ModalRecoleccionCargaDirecciones();
+ }
+
+ private void ModalRecoleccionCargaDirecciones()
+ {
+ if (DdlModalRecoleccionCliente.SelectedValue.ToEntero() > 0)
+ {
+ ClsClientes ObjClientes = new ClsClientes();
+ if (ObjClientes.DireccionEnvioGet(-1, DdlModalRecoleccionCliente.SelectedValue.ToEntero(), -1))
+ {
+ DdlmodalRecoleccionDireccion.DataSource = ObjClientes.DtResultados.FiltraParametros("CveSubProyecto = " + DdlSubProyectoRecoleccion.SelectedValue.ToEntero());
+ }
+ ObjClientes.Dispose();
+ }
+
+ DdlmodalRecoleccionDireccion.DataBind();
+ DdlmodalRecoleccionDireccion.Items.Insert(0, new ListItem("Seleccione", "-1"));
+
+ UpModalRecoleccion.Update();
+ }
+
+
+ protected void LnkAgregarRecoleccion_Click(object sender, EventArgs e)
+ {
+
+ LtlModalRecoleccionTitulo.Text = "Agregar Recolección";
+ BtnModalRecoleccionGuardar.Text = "Agregar";
+
+ LimpiarModalRecoleccion();
+ RegistraScript("$('#DivModalRecoleccion').modal('show');");
+ CveEntregaAlmacen = -1;
+ }
+
+ protected void LnkGvDatosRecoleccionEditar_Click(object sender, EventArgs e)
+ {
+ LinkButton LnkEliminar = (LinkButton)sender;
+ GridViewRow GvRow = (GridViewRow)LnkEliminar.NamingContainer;
+
+ CveEntregaAlmacen = GvRow.DataKey("CveEntregaAlmacen").ToEntero();
+ int CveDireccionOrigen = GvRow.DataKey("CveDireccionOrigen").ToEntero();
+ int CveClienteEnvio = -1;
+ string NombreCliente = "";
+ ClsClientes ObjClientes = new ClsClientes();
+ DataTable DtTempDirecciones = new DataTable();
+
+ if (ObjClientes.DireccionEnvioGet(CveDireccionOrigen, -1, -1))
+ {
CveClienteEnvio = ObjClientes.DtResultados.FiltroPrimeroValor("CveCliente").ToEntero();
- NombreCliente = ObjClientes.DtResultados.FiltroPrimeroValor("NombreCliente");
-
- if (ObjClientes.DireccionEnvioGet(-1, CveClienteEnvio, -1))
- {
- DdlmodalRecoleccionDireccion.DataSource = ObjClientes.DtResultados;
- }
- }
- ObjClientes.Dispose();
-
- DdlmodalRecoleccionDireccion.DataBind();
- DdlmodalRecoleccionDireccion.Items.Add(new ListItem("Seleccione una", "-1"));
- DdlmodalRecoleccionDireccion.SelectedValueExist(CveDireccionOrigen);
-
+ NombreCliente = ObjClientes.DtResultados.FiltroPrimeroValor("NombreCliente");
+
+ if (ObjClientes.DireccionEnvioGet(-1, CveClienteEnvio, -1))
+ {
+ DdlmodalRecoleccionDireccion.DataSource = ObjClientes.DtResultados;
+ }
+ }
+ ObjClientes.Dispose();
+
+ DdlmodalRecoleccionDireccion.DataBind();
+ DdlmodalRecoleccionDireccion.Items.Add(new ListItem("Seleccione una", "-1"));
+ DdlmodalRecoleccionDireccion.SelectedValueExist(CveDireccionOrigen);
+
DdlModalRecoleccionCliente.SelectedValue = CveClienteEnvio.ToString();
- DdlModalRecoleccionCliente.SelectedText = NombreCliente;
-
- DdlSubProyectoRecoleccion.SelectedValueExist(GvRow.DataKey("CveSubProyecto"));
- TxtFolioReferencia.Text = GvRow.DataKey("FolioReferencia");
- TxtReferencia.Text = GvRow.DataKey("Referencia");
-
- CargaDatosRecoleccionDetallePS();
-
-
- LtlModalRecoleccionTitulo.Text = "Actualizar Recolección";
- BtnModalRecoleccionGuardar.Text = "Actualizar";
- UpModalRecoleccion.Update();
-
- RegistraScript("$('#DivModalRecoleccion').modal('show');");
- }
-
- private void LimpiarModalRecoleccion()
- {
-
- // DdlModalRecoleccionCliente.SelectedValueExist(-1);
- DdlmodalRecoleccionDireccion.SelectedValueExist(-1);
- TxtModalRecoleccionCantidad.Text = "";
- DdlModalRecoleccionUnidad.Items.Clear();
- DdlModalRecoleccionUnidad.Items.Add(new ListItem("Seleccione una", "-1"));
- DdlProducto2.txtValue.Value = "";
+ DdlModalRecoleccionCliente.SelectedText = NombreCliente;
+
+ DdlSubProyectoRecoleccion.SelectedValueExist(GvRow.DataKey("CveSubProyecto"));
+ TxtFolioReferencia.Text = GvRow.DataKey("FolioReferencia");
+ TxtReferencia.Text = GvRow.DataKey("Referencia");
+
+ CargaDatosRecoleccionDetallePS();
+
+
+ LtlModalRecoleccionTitulo.Text = "Actualizar Recolección";
+ BtnModalRecoleccionGuardar.Text = "Actualizar";
+ UpModalRecoleccion.Update();
+
+ RegistraScript("$('#DivModalRecoleccion').modal('show');");
+ }
+
+ private void LimpiarModalRecoleccion()
+ {
+
+ // DdlModalRecoleccionCliente.SelectedValueExist(-1);
+ DdlmodalRecoleccionDireccion.SelectedValueExist(-1);
+ TxtModalRecoleccionCantidad.Text = "";
+ DdlModalRecoleccionUnidad.Items.Clear();
+ DdlModalRecoleccionUnidad.Items.Add(new ListItem("Seleccione una", "-1"));
+ DdlProducto2.txtValue.Value = "";
DdlProducto2.txtText.Value = "";
DdlSubProyectoRecoleccion.SelectedValueExist("-1");
- DdlModalRecoleccionCliente.SelectedValue = "-1";
- DdlModalRecoleccionCliente.SelectedText = "Seleccione";
-
- TxtFolioReferencia.Text = "";
- TxtReferencia.Text = "";
-
- DTRecoleccion.Rows.Clear();
- GvModalPSRecoleccion.DataSource = DTRecoleccion;
- GvModalPSRecoleccion.DataBind();
-
-
- UpModalRecoleccion.Update();
- }
-
- protected void DdlProducto_ValueChanged(object sender, EventArgs e)
- {
- ElProductoChange();
- }
-
- private void ElProductoChange()
- {
- DdlModalRecoleccionUnidad.Items.Clear();
- DdlModalRecoleccionUnidad.DataSource = get_GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero(), -1, UsuarioActual.CveEmpresa);
- DdlModalRecoleccionUnidad.DataBind();
- UpModalRecoleccion.Update();
- }
-
- protected void BtnModalRecoleccionGuardar_Click(object sender, EventArgs e)
- {
-
-
- if (DdlmodalRecoleccionDireccion.SelectedValue.ToEntero() <= 0)
- {
- Alert("Debe seleccionar la dirección de recolección", ModExtensiones.TipoMensaje.MsgAdvertencia);
- return;
- }
-
- bool ProcesoOK = false;
-
- ClsGenerales ObjGenerales = new ClsGenerales();
- ObjGenerales.IniciaTransacSQL();
-
- if (CveEntregaAlmacen == -1)
- {
- DateTime fechallegada = (TxtFechaEntrega.Text + " 23:59").ToDate();
- CveEntregaAlmacen = ObjGenerales.AddInvEntregaAlmacenRuta(DdlSubProyectoRecoleccion.SelectedValue.ToEntero(), DdlmodalRecoleccionDireccion.SelectedValue.ToEntero(), -1, -1, DdlChoferRec.SelectedValue.ToEntero(), DdlUnidadRec.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), fechallegada, "R", TxtFolioReferencia.Text, TxtReferencia.Text, TxtFechaLimite.Text.ToDate(), 1, 0, 1);
- if (CveEntregaAlmacen > 0)
- {
- //CveTimbrenuevo = ObjGenerales.AddGralTimbre("Rec", "-1", -1, "-1", TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, -1, ChkEmitirCartaPorte.Checked, CveEntregaAlmacen, -1);
-
- //if (CveTimbrenuevo > 0)
- //{
- foreach (DataRow dRow in DTRecoleccion.Rows)
- {
- if (ObjGenerales.AddEntregaAlmacenRutaDetalle(CveEntregaAlmacen, dRow["CvePS"].ToString().ToEntero(), dRow["Cantidad"].ToString().ToDecimal(), dRow["CveUnidadMedida"].ToString().ToEntero(), UsuarioActual.CveUsuario))
- {
- ProcesoOK = true;
- }
- else
- {
- ProcesoOK = false;
- break;
- }
- }
- //}
- }
- }
- else
- {
- ProcesoOK = ObjGenerales.UpdateInvEntregaAlmacenRuta(CveEntregaAlmacen, DdlmodalRecoleccionDireccion.SelectedValue.ToEntero(), -1, DdlChoferRec.SelectedValue.ToEntero(), DdlUnidadRec.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveEmpresa,FolioReferencia:TxtFolioReferencia.Text,Referencia: TxtReferencia.Text,CveSubProyecto: DdlSubProyectoRecoleccion.SelectedValue.ToEntero());
- }
-
- if (ProcesoOK)
- {
- ObjGenerales.Commit();
- Alert("Recolección Guardada correctamente.");
- RegistraScript("$('#DivModalRecoleccion').modal('hide');");
- }
- else
- {
- ObjGenerales.RollBack();
- Alert("Ocurrió un error.", ModExtensiones.TipoMensaje.MsgError);
- }
-
- ObjGenerales.Dispose();
- CargaDatosRecoleccion();
- }
-
- protected void LnkGvDatosRecoleccionEliminar_Click(object sender, EventArgs e)
- {
- LinkButton LnkEliminar = (LinkButton)sender;
- GridViewRow GvRow = (GridViewRow)LnkEliminar.NamingContainer;
-
- int CveEntregaAlmacenEliminar = GvRow.DataKey("CveEntregaAlmacen").ToEntero();
- ClsGenerales ObjGenerales = new ClsGenerales();
- if (ObjGenerales.RemoveInvEntregaAlmacenRuta(CveEntregaAlmacenEliminar, UsuarioActual.CveEmpresa))
- {
- Alert("Producto Eliminado correctamente.");
- }
-
- ObjGenerales.Dispose();
- CargaDatosRecoleccion();
- }
-
- #endregion
-
- protected void LnkModalGvModalPSRecoleccionEliminar_Click(object sender, EventArgs e)
- {
- LinkButton LnkEliminar = (LinkButton)sender;
- GridViewRow GvRow = (GridViewRow)LnkEliminar.NamingContainer;
-
- if (CveEntregaAlmacen > 0)
- {
-
- int CveEntregaAlmacenDetalleEliminar = GvRow.DataKey("CveEntregaAlmacenDetalle").ToEntero();
- ClsGenerales ObjGenerales = new ClsGenerales();
-
- if (ObjGenerales.RemoveEntregaAlmacenRutaDetalle(CveEntregaAlmacenDetalleEliminar))
- {
- Alert("Recolección Eliminada correctamente.");
- }
- ObjGenerales.Dispose();
- }
- else
- {
- int DTIndex = GvRow.RowIndex;
- DTRecoleccion.Rows[DTIndex].Delete();
- DTRecoleccion.AcceptChanges();
-
- }
- CargaDatosRecoleccionDetallePS();
- }
-
- protected void LnkModalAgregarPS_Click(object sender, EventArgs e)
- {
- if (CveEntregaAlmacen > 0)
- {
- ClsGenerales ObjGenerales = new ClsGenerales();
-
- if (ObjGenerales.AddEntregaAlmacenRutaDetalle(CveEntregaAlmacen, DdlProducto2.SelectedValue.ToEntero(), TxtModalRecoleccionCantidad.Text.ToEntero(), DdlModalRecoleccionUnidad.SelectedValue.ToEntero(), UsuarioActual.CveUsuario))
- {
-
- }
- ObjGenerales.Dispose();
- }
- else
- {
- DataRow dRow = DTRecoleccion.NewRow();
-
- dRow["CveEntregaAlmacenDetalle"] = -1;
- dRow["CveEntregaAlmacen"] = CveEntregaAlmacen;
- dRow["CvePS"] = DdlProducto2.SelectedValue.ToEntero();
- dRow["Cantidad"] = TxtModalRecoleccionCantidad.Text.ToEntero();
- dRow["CveUnidadMedida"] = DdlModalRecoleccionUnidad.SelectedValue.ToEntero();
- dRow["CveUsuario"] = UsuarioActual.CveUsuario;
- dRow["FechaIng"] = DateTime.Now;
- dRow["CodigoPS"] = DdlProducto2.txtText.Value;
- dRow["Abreviatura"] = DdlModalRecoleccionUnidad.SelectedItem.Text;
-
- DTRecoleccion.Rows.Add(dRow);
- //GvModalPSRecoleccion.DataSource = DTRecoleccion;
- }
-
- LimpiarControlesPS();
- CargaDatosRecoleccionDetallePS();
-
- }
- private void LimpiarControlesPS()
- {
- TxtModalRecoleccionCantidad.Text = "";
- DdlModalRecoleccionUnidad.Items.Clear();
- DdlProducto2.txtText.Value = "";
- DdlProducto2.txtValue.Value = "";
- UpModalRecoleccion.Update();
- }
-
- protected void Tab_ActiveTabChanged(object sender, EventArgs e)
- {
- if (Tab.ActiveTabIndex == 0)
- {
- SeleccionEntrega = false;
- SeleccionarGenerar(1);
- }
- else
- {
- OcultarmostarDatosEntrega(true);
- }
- }
-
-
- private void CargaModalCombosDirecciones(int CveCliente, int CveDireccionEnvio)
- {
-
- DdlModalDireccionEnvio.Items.Clear();
-
- DataTable dtt = new DataTable();
- ClsClientes ObjClientes = new ClsClientes();
- if (ObjClientes.DireccionEnvioGet(-1, CveCliente, -1))
- {
- dtt = ObjClientes.DtResultados;
- }
- ObjClientes.Dispose();
-
- DdlModalDireccionEnvio.DataSource = dtt;
- DdlModalDireccionEnvio.DataBind();
- DdlModalDireccionEnvio.SelectedValueExist(CveDireccionEnvio);
-
- dtt.Dispose();
- }
-
-
- protected void LnkEditarDir_Click(object sender, EventArgs e)
- {
- GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
-
- int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
- int CveDireccion = GvRow.DataKey("CveDireccionEnvio").ToEntero();
-
- HdnCveVenta.Value = GvRow.DataKey("CveVenta");
- CargaModalCombosDirecciones(CveCliente, CveDireccion);
-
- UpModalEditarentrega.Update();
- this.RegistraScript("$('#DivEditarEntrega').modal('show');");
- }
-
- protected void BtnModalEditarentrega_Click(object sender, EventArgs e)
- {
-
- bool ProcesoOK = true;
-
- ClsVentas ObjVentas = new ClsVentas();
- if (!ObjVentas.UpdateDireccionEnvioVenta(HdnCveVenta.Value.ToEntero(), DdlModalDireccionEnvio.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa))
- {
- ProcesoOK = false;
- }
- ObjVentas.Dispose();
-
- if (ProcesoOK)
- {
- this.RegistraScript("$('#DivEditarEntrega').modal('hide');");
- Alert("Dirección Actualizada correctamente.", ModExtensiones.TipoMensaje.ToastInformacion);
- CargaDatos();
- }
-
- }
-
- protected void gvR_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- LinkButton LnkEditar = e.Row.FCLinkButton("LnkGvDatosRecoleccionEditar");
- LinkButton LnkEliminar = e.Row.FCLinkButton("LnkGvDatosRecoleccionEliminar");
-
- if (e.Row.DataKey("Estatus") == "0" || e.Row.DataKey("Estatus") == "")
- {
- LnkEditar.Visible = true;
- LnkEliminar.Visible = true;
-
- }
- if (e.Row.DataKey("CveTimbre") != "")
- {
- e.Row.FCCheckBox("Chk").Visible = false;
- }
-
-
- }
- }
+ DdlModalRecoleccionCliente.SelectedValue = "-1";
+ DdlModalRecoleccionCliente.SelectedText = "Seleccione";
+
+ TxtFolioReferencia.Text = "";
+ TxtReferencia.Text = "";
+
+ DTRecoleccion.Rows.Clear();
+ GvModalPSRecoleccion.DataSource = DTRecoleccion;
+ GvModalPSRecoleccion.DataBind();
+
+
+ UpModalRecoleccion.Update();
+ }
+
+ protected void DdlProducto_ValueChanged(object sender, EventArgs e)
+ {
+ ElProductoChange();
+ }
+
+ private void ElProductoChange()
+ {
+ DdlModalRecoleccionUnidad.Items.Clear();
+ DdlModalRecoleccionUnidad.DataSource = get_GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero(), -1, UsuarioActual.CveEmpresa);
+ DdlModalRecoleccionUnidad.DataBind();
+ UpModalRecoleccion.Update();
+ }
+
+ protected void BtnModalRecoleccionGuardar_Click(object sender, EventArgs e)
+ {
+
+
+ if (DdlmodalRecoleccionDireccion.SelectedValue.ToEntero() <= 0)
+ {
+ Alert("Debe seleccionar la dirección de recolección", ModExtensiones.TipoMensaje.MsgAdvertencia);
+ return;
+ }
+
+ bool ProcesoOK = false;
+
+ ClsGenerales ObjGenerales = new ClsGenerales();
+ ObjGenerales.IniciaTransacSQL();
+
+ if (CveEntregaAlmacen == -1)
+ {
+ DateTime fechallegada = (TxtFechaEntrega.Text + " 23:59").ToDate();
+ CveEntregaAlmacen = ObjGenerales.AddInvEntregaAlmacenRuta(DdlSubProyectoRecoleccion.SelectedValue.ToEntero(), DdlmodalRecoleccionDireccion.SelectedValue.ToEntero(), -1, -1, DdlChoferRec.SelectedValue.ToEntero(), DdlUnidadRec.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), fechallegada, "R", TxtFolioReferencia.Text, TxtReferencia.Text, TxtFechaLimite.Text.ToDate(), 1, 0, 1);
+ if (CveEntregaAlmacen > 0)
+ {
+ //CveTimbrenuevo = ObjGenerales.AddGralTimbre("Rec", "-1", -1, "-1", TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, -1, ChkEmitirCartaPorte.Checked, CveEntregaAlmacen, -1);
+
+ //if (CveTimbrenuevo > 0)
+ //{
+ foreach (DataRow dRow in DTRecoleccion.Rows)
+ {
+ if (ObjGenerales.AddEntregaAlmacenRutaDetalle(CveEntregaAlmacen, dRow["CvePS"].ToString().ToEntero(), dRow["Cantidad"].ToString().ToDecimal(), dRow["CveUnidadMedida"].ToString().ToEntero(), UsuarioActual.CveUsuario))
+ {
+ ProcesoOK = true;
+ }
+ else
+ {
+ ProcesoOK = false;
+ break;
+ }
+ }
+ //}
+ }
+ }
+ else
+ {
+ ProcesoOK = ObjGenerales.UpdateInvEntregaAlmacenRuta(CveEntregaAlmacen, DdlmodalRecoleccionDireccion.SelectedValue.ToEntero(), -1, DdlChoferRec.SelectedValue.ToEntero(), DdlUnidadRec.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveEmpresa,FolioReferencia:TxtFolioReferencia.Text,Referencia: TxtReferencia.Text,CveSubProyecto: DdlSubProyectoRecoleccion.SelectedValue.ToEntero());
+ }
+
+ if (ProcesoOK)
+ {
+ ObjGenerales.Commit();
+ Alert("Recolección Guardada correctamente.");
+ RegistraScript("$('#DivModalRecoleccion').modal('hide');");
+ }
+ else
+ {
+ ObjGenerales.RollBack();
+ Alert("Ocurrió un error.", ModExtensiones.TipoMensaje.MsgError);
+ }
+
+ ObjGenerales.Dispose();
+ CargaDatosRecoleccion();
+ }
+
+ protected void LnkGvDatosRecoleccionEliminar_Click(object sender, EventArgs e)
+ {
+ LinkButton LnkEliminar = (LinkButton)sender;
+ GridViewRow GvRow = (GridViewRow)LnkEliminar.NamingContainer;
+
+ int CveEntregaAlmacenEliminar = GvRow.DataKey("CveEntregaAlmacen").ToEntero();
+ ClsGenerales ObjGenerales = new ClsGenerales();
+ if (ObjGenerales.RemoveInvEntregaAlmacenRuta(CveEntregaAlmacenEliminar, UsuarioActual.CveEmpresa))
+ {
+ Alert("Producto Eliminado correctamente.");
+ }
+
+ ObjGenerales.Dispose();
+ CargaDatosRecoleccion();
+ }
+
+ #endregion
+
+ protected void LnkModalGvModalPSRecoleccionEliminar_Click(object sender, EventArgs e)
+ {
+ LinkButton LnkEliminar = (LinkButton)sender;
+ GridViewRow GvRow = (GridViewRow)LnkEliminar.NamingContainer;
+
+ if (CveEntregaAlmacen > 0)
+ {
+
+ int CveEntregaAlmacenDetalleEliminar = GvRow.DataKey("CveEntregaAlmacenDetalle").ToEntero();
+ ClsGenerales ObjGenerales = new ClsGenerales();
+
+ if (ObjGenerales.RemoveEntregaAlmacenRutaDetalle(CveEntregaAlmacenDetalleEliminar))
+ {
+ Alert("Recolección Eliminada correctamente.");
+ }
+ ObjGenerales.Dispose();
+ }
+ else
+ {
+ int DTIndex = GvRow.RowIndex;
+ DTRecoleccion.Rows[DTIndex].Delete();
+ DTRecoleccion.AcceptChanges();
+
+ }
+ CargaDatosRecoleccionDetallePS();
+ }
+
+ protected void LnkModalAgregarPS_Click(object sender, EventArgs e)
+ {
+ if (CveEntregaAlmacen > 0)
+ {
+ ClsGenerales ObjGenerales = new ClsGenerales();
+
+ if (ObjGenerales.AddEntregaAlmacenRutaDetalle(CveEntregaAlmacen, DdlProducto2.SelectedValue.ToEntero(), TxtModalRecoleccionCantidad.Text.ToEntero(), DdlModalRecoleccionUnidad.SelectedValue.ToEntero(), UsuarioActual.CveUsuario))
+ {
+
+ }
+ ObjGenerales.Dispose();
+ }
+ else
+ {
+ DataRow dRow = DTRecoleccion.NewRow();
+
+ dRow["CveEntregaAlmacenDetalle"] = -1;
+ dRow["CveEntregaAlmacen"] = CveEntregaAlmacen;
+ dRow["CvePS"] = DdlProducto2.SelectedValue.ToEntero();
+ dRow["Cantidad"] = TxtModalRecoleccionCantidad.Text.ToEntero();
+ dRow["CveUnidadMedida"] = DdlModalRecoleccionUnidad.SelectedValue.ToEntero();
+ dRow["CveUsuario"] = UsuarioActual.CveUsuario;
+ dRow["FechaIng"] = DateTime.Now;
+ dRow["CodigoPS"] = DdlProducto2.txtText.Value;
+ dRow["Abreviatura"] = DdlModalRecoleccionUnidad.SelectedItem.Text;
+
+ DTRecoleccion.Rows.Add(dRow);
+ //GvModalPSRecoleccion.DataSource = DTRecoleccion;
+ }
+
+ LimpiarControlesPS();
+ CargaDatosRecoleccionDetallePS();
+
+ }
+ private void LimpiarControlesPS()
+ {
+ TxtModalRecoleccionCantidad.Text = "";
+ DdlModalRecoleccionUnidad.Items.Clear();
+ DdlProducto2.txtText.Value = "";
+ DdlProducto2.txtValue.Value = "";
+ UpModalRecoleccion.Update();
+ }
+
+ protected void Tab_ActiveTabChanged(object sender, EventArgs e)
+ {
+ if (Tab.ActiveTabIndex == 0)
+ {
+ SeleccionEntrega = false;
+ SeleccionarGenerar(1);
+ }
+ else
+ {
+ OcultarmostarDatosEntrega(true);
+ }
+ }
+
+
+ private void CargaModalCombosDirecciones(int CveCliente, int CveDireccionEnvio)
+ {
+
+ DdlModalDireccionEnvio.Items.Clear();
+
+ DataTable dtt = new DataTable();
+ ClsClientes ObjClientes = new ClsClientes();
+ if (ObjClientes.DireccionEnvioGet(-1, CveCliente, -1))
+ {
+ dtt = ObjClientes.DtResultados;
+ }
+ ObjClientes.Dispose();
+
+ DdlModalDireccionEnvio.DataSource = dtt;
+ DdlModalDireccionEnvio.DataBind();
+ DdlModalDireccionEnvio.SelectedValueExist(CveDireccionEnvio);
+
+ dtt.Dispose();
+ }
+
+
+ protected void LnkEditarDir_Click(object sender, EventArgs e)
+ {
+ GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
+
+ int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
+ int CveDireccion = GvRow.DataKey("CveDireccionEnvio").ToEntero();
+
+ HdnCveVenta.Value = GvRow.DataKey("CveVenta");
+ CargaModalCombosDirecciones(CveCliente, CveDireccion);
+
+ UpModalEditarentrega.Update();
+ this.RegistraScript("$('#DivEditarEntrega').modal('show');");
+ }
+
+ protected void BtnModalEditarentrega_Click(object sender, EventArgs e)
+ {
+
+ bool ProcesoOK = true;
+
+ ClsVentas ObjVentas = new ClsVentas();
+ if (!ObjVentas.UpdateDireccionEnvioVenta(HdnCveVenta.Value.ToEntero(), DdlModalDireccionEnvio.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa))
+ {
+ ProcesoOK = false;
+ }
+ ObjVentas.Dispose();
+
+ if (ProcesoOK)
+ {
+ this.RegistraScript("$('#DivEditarEntrega').modal('hide');");
+ Alert("Dirección Actualizada correctamente.", ModExtensiones.TipoMensaje.ToastInformacion);
+ CargaDatos();
+ }
+
+ }
+
+ protected void gvR_RowDataBound(object sender, GridViewRowEventArgs e)
+ {
+ if (e.Row.RowType == DataControlRowType.DataRow)
+ {
+ LinkButton LnkEditar = e.Row.FCLinkButton("LnkGvDatosRecoleccionEditar");
+ LinkButton LnkEliminar = e.Row.FCLinkButton("LnkGvDatosRecoleccionEliminar");
+
+ if (e.Row.DataKey("Estatus") == "0" || e.Row.DataKey("Estatus") == "")
+ {
+ LnkEditar.Visible = true;
+ LnkEliminar.Visible = true;
+
+ }
+ if (e.Row.DataKey("CveTimbre") != "")
+ {
+ e.Row.FCCheckBox("Chk").Visible = false;
+ }
+
+
+ }
+ }
}
\ No newline at end of file
diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx
index a66411c6f..410f079fb 100644
--- a/Ventas/Clientes.aspx
+++ b/Ventas/Clientes.aspx
@@ -453,62 +453,49 @@
-
-
-