Entrega Almacen, reporte

This commit is contained in:
rakcsle
2021-11-24 22:04:38 -07:00
parent ae0566568e
commit 744929d45a
11 changed files with 3201 additions and 2207 deletions

View File

@@ -47,6 +47,27 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
}
DataTable DTRecoleccion
{
get
{
if (ViewState["DTRecoleccion"] == null)
{
ViewState["DTRecoleccion"] = InitDTRecoleccion();
}
return (DataTable)ViewState["DTRecoleccion"];
}
set
{
ViewState["DTRecoleccion"] = (DataTable)value;
}
}
bool SelecionEntrega
{
get
@@ -64,25 +85,50 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
}
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)
{
SelecionEntrega = true;
SelecionEntrega = true;
CargaCombos();
CargaDatos();
#region RECOLEECION
CargaDatosRecoleccion();
CargaModalClasificaiones();
CargaModalDdlPS();
ModalRecoleccionCargaClientes();
#endregion
}
}
protected void BtnAsignar_Click(object sender, EventArgs e)
{
{
if(DdlChofer.SelectedValue.ToEntero() <= 0)
@@ -132,7 +178,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
TieneError = true;
break;
}
int CveEntregaAlmacen = ObjGeneral.AddInvEntregaAlmacenRuta(row.DataKey("CveSubProyectoOrigen").ToEntero(), row.DataKey("CveMovimiento").ToEntero(), CveDireccionOrigen, CveDireccionDestino, DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), "E",Orden);
int CveEntregaAlmacen = ObjGeneral.AddInvEntregaAlmacenRuta(row.DataKey("CveSubProyectoOrigen").ToEntero(), row.DataKey("CveMovimiento").ToEntero(), CveDireccionOrigen, CveDireccionDestino, DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), "E",Orden,0);
CveDireccionOrigen = row.DataKey("CveDireccionEnvio").ToEntero();
if (CveEntregaAlmacen > 0)
@@ -254,7 +300,34 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
}
private void CargaModalClasificaiones()
{
DdlClasificacion.DataSource = get_GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby: "Clasificacion");
DdlClasificacion.DataBind();
UpModalRecoleccion.Update();
}
private void CargaModalDdlPS()
{
bool EsWS = UsuarioActual.Empresa.Funcionalidad(105) == "1" | UsuarioActual.Empresa.Funcionalidad(141) == "1" ? true : false;
DdlProducto2.setEsWebService(EsWS);
if (DdlProducto2.UsaWebService)
{
DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue);
}
else if (!DdlProducto2.UsaWebService && (DataTable)DdlProducto2.DataSource == null)
{
DdlProducto2.DataSource = get_GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion: DdlClasificacion.SelectedValue.ToEntero()).FiltraParametros("CveTipoPS = 2");
DdlProducto2.DataBind();
}
}
protected void LnkGenerarDocumentos_Click(object sender, EventArgs e)
{
@@ -307,22 +380,13 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
LnkGenerarDocumentos.Text = "Regresar a Preselección";
LnkGenerarDocumentos.CssClass = "btn btn-default";
DVDatosEntrega1.Visible = true;
DVDatosEntrega2.Visible = true;
DVDatosEntrega3.Visible = true;
DVDatosEntrega4.Visible = true;
DVDatosEntrega5.Visible = true;
DVDatosEntrega6.Visible = true;
DVDatosEntrega7.Attributes.Add("class", "col-md-1");
if (UsuarioActual.Empresa.Funcionalidad(161).ToEntero() == 1)
{
DvCartaPorte1.Visible = true;
DvCartaPorte2.Visible = true;
}
OcultarmostarDatosEntrega(true);
BtnConsultar.Visible = false;
UpDatos.Update();
@@ -352,21 +416,10 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
BtnConsultar.Visible = true;
SelecionEntrega = true;
LnkGenerarDocumentos.Text = "Preselección de Entregas";
LnkGenerarDocumentos.CssClass = "btn btn-primary";
DVDatosEntrega7.Attributes.Add("class", "col-md-9");
LnkGenerarDocumentos.CssClass = "btn btn-primary";
DVDatosEntrega1.Visible = false;
DVDatosEntrega2.Visible = false;
DVDatosEntrega3.Visible = false;
DVDatosEntrega4.Visible = false;
DVDatosEntrega5.Visible = false;
DVDatosEntrega6.Visible = false;
if (UsuarioActual.Empresa.Funcionalidad(161).ToEntero() == 1)
{
DvCartaPorte1.Visible = false;
DvCartaPorte2.Visible = false;
}
OcultarmostarDatosEntrega(false);
BtnAsignar.Visible = false;
DVGvGenerarDocumentos.Visible = false;
@@ -379,7 +432,33 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
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)
{
DvCartaPorte1.Visible = mostrar;
DvCartaPorte2.Visible = mostrar;
}
UpDatosEntrega.Update();
}
private void ActualizaOrdenDTGenrarDocumentos()
{
@@ -415,6 +494,409 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
protected void BtnConsultar_Click(object sender, EventArgs e)
{
CargaDatos();
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))
{
GvDatosRecoleccion.DataSource = ObjGeneral.DtResultados;
}
ObjGeneral.Dispose();
GvDatosRecoleccion.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();
}
private void ModalRecoleccionCargaClientes()
{
ClsClientes ObjCliente = new ClsClientes();
if (ObjCliente.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, 1))
{
DdlModalRecoleccionCliente.DataSource = ObjCliente.DtResultados;
}
ObjCliente.Dispose();
DdlModalRecoleccionCliente.DataBind();
DdlModalRecoleccionCliente.Items.Insert(0, new ListItem("Seleccione uno", "-1"));
}
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))
{
DdlmodalRecoleccionDirecion.DataSource = ObjClientes.DtResultados;
}
ObjClientes.Dispose();
}
else
{
DdlmodalRecoleccionDirecion.DataSource = null;
}
DdlmodalRecoleccionDirecion.DataBind();
DdlmodalRecoleccionDirecion.Items.Insert(0, new ListItem("Seleccione una", "-1"));
UpModalRecoleccion.Update();
}
protected void LnkAgregarRecoleccion_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;
}
LtlModalRecoleccionTitulo.Text = "Agregar Recoleccion";
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;
ClsClientes ObjClientes = new ClsClientes();
DataTable DtTempDirecciones = new DataTable();
if (ObjClientes.DireccionEnvioGet(CveDireccionOrigen, -1, -1))
{
CveClienteEnvio = ObjClientes.DtResultados.FiltroPrimeroValor("CveCliente").ToEntero();
if (ObjClientes.DireccionEnvioGet(-1, CveClienteEnvio, -1))
{
DdlmodalRecoleccionDirecion.DataSource = ObjClientes.DtResultados;
}
}
ObjClientes.Dispose();
DdlmodalRecoleccionDirecion.DataBind();
DdlmodalRecoleccionDirecion.Items.Add(new ListItem("Seleccione una", "-1"));
DdlmodalRecoleccionDirecion.SelectedValueExist(CveDireccionOrigen);
DdlModalRecoleccionCliente.SelectedValueExist(CveClienteEnvio);
CargaDatosRecoleccionDetallePS();
LtlModalRecoleccionTitulo.Text = "Actualizar Recolección";
BtnModalRecoleccionGuardar.Text = "Actualizar";
UpModalRecoleccion.Update();
RegistraScript("$('#DivModalRecoleccion').modal('show');");
}
private void LimpiarModalRecoleccion()
{
DdlModalRecoleccionCliente.SelectedValueExist(-1);
DdlmodalRecoleccionDirecion.SelectedValueExist(-1);
TxtModalRecoleccionCantidad.Text = "";
DdlModalRecoleccionUnidad.Items.Clear();
DdlModalRecoleccionUnidad.Items.Add(new ListItem("Seleccione una","-1"));
DdlProducto2.txtValue.Value = "";
DdlProducto2.txtText.Value = "";
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 (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;
}
int CveTimbrenuevo = -1;
bool ProcesoOK = false;
int CveSubProyectoCliente = get_GlobalDTCliente(UsuarioActual.CveEmpresa, -1, DdlModalRecoleccionCliente.SelectedValue.ToEntero()).FiltroPrimeroValor("CveSubProyecto").ToEntero();
ClsGenerales ObjGenerales = new ClsGenerales();
ObjGenerales.IniciaTransacSQL();
if( CveEntregaAlmacen == -1)
{
CveEntregaAlmacen = ObjGenerales.AddInvEntregaAlmacenRuta(CveSubProyectoCliente, -1, DdlmodalRecoleccionDirecion.SelectedValue.ToEntero(), -1, DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), "R", 1,0);
if (CveEntregaAlmacen > 0)
{
CveTimbrenuevo = ObjGenerales.AddGralTimbre("Tra", "-1", -1, "-1", new DateTime(1900, 01, 01), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, -1, ChkEmitirCartaPorte.Checked, CveEntregaAlmacen, CveSubProyectoCliente);
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
{
if(ObjGenerales.UpdateInvEntregaAlmacenRuta(CveEntregaAlmacen,DdlmodalRecoleccionDirecion.SelectedValue.ToEntero(),-1, DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(),TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveEmpresa))
{
ProcesoOK = true;
}
else
{
ProcesoOK = false;
}
}
if (ProcesoOK)
{
ObjGenerales.Commit();
Alert("Recolección Guardada correctamente.");
RegistraScript("$('#DivModalRecoleccion').modal('hide');");
}
else
{
ObjGenerales.RollBack();
}
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)
{
SelecionEntrega = false;
SeleccioanrGenrar();
}
else
{
OcultarmostarDatosEntrega(true);
}
}
}