-- cambios en carta porte
This commit is contained in:
@@ -13,18 +13,18 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
{
|
||||
|
||||
|
||||
DataTable DTGenrarDocumentos
|
||||
DataTable DTGenerarDocumentos
|
||||
{
|
||||
get {
|
||||
|
||||
if(ViewState["DTGenrarDocumentos"] == null){
|
||||
ViewState["DTGenrarDocumentos"] = new DataTable();
|
||||
if(ViewState["DTGenerarDocumentos"] == null){
|
||||
ViewState["DTGenerarDocumentos"] = new DataTable();
|
||||
}
|
||||
return (DataTable)ViewState["DTGenrarDocumentos"];
|
||||
return (DataTable)ViewState["DTGenerarDocumentos"];
|
||||
|
||||
}
|
||||
set {
|
||||
ViewState["DTGenrarDocumentos"] = (DataTable)value;
|
||||
ViewState["DTGenerarDocumentos"] = (DataTable)value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,29 +62,23 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
ViewState["DTRecoleccion"] = (DataTable)value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool SelecionEntrega
|
||||
bool SeleccionEntrega
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ViewState["SelecionEntrega"] == null)
|
||||
if (ViewState["SeleccionEntrega"] == null)
|
||||
{
|
||||
ViewState["SelecionEntrega"] = false;
|
||||
ViewState["SeleccionEntrega"] = false;
|
||||
}
|
||||
return (bool) ViewState["SelecionEntrega"];
|
||||
return (bool) ViewState["SeleccionEntrega"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["SelecionEntrega"] = (bool)value;
|
||||
ViewState["SeleccionEntrega"] = (bool)value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CveEntregaAlmacen
|
||||
{
|
||||
get {
|
||||
@@ -105,23 +99,15 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
SelecionEntrega = true;
|
||||
SeleccionEntrega = true;
|
||||
CargaCombos();
|
||||
CargaDatos();
|
||||
|
||||
|
||||
|
||||
CargaDatos();
|
||||
|
||||
#region RECOLEECION
|
||||
CargaDatosRecoleccion();
|
||||
CargaModalClasificaiones();
|
||||
CargaModalDdlPS();
|
||||
|
||||
ModalRecoleccionCargaClientes();
|
||||
|
||||
// CargaDatosRecoleccion();
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -141,36 +127,26 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
{
|
||||
Alert("Debe seleccionar una unidad", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
StringBuilder SBError = new StringBuilder();
|
||||
ActualizaOrdenDTGenrarDocumentos();
|
||||
ActualizaOrdenDTGenerarDocumentos();
|
||||
List<int> ListaTimbres = new List<int>();
|
||||
|
||||
|
||||
|
||||
bool TieneError = false;
|
||||
ClsGenerales ObjGeneral = new ClsGenerales();
|
||||
ObjGeneral.IniciaTransacSQL();
|
||||
|
||||
GridViewRowCollection Grid = GvGenerarDocumentos.Rows;
|
||||
|
||||
|
||||
GridViewRowCollection Grid = GvGenerarDocumentos.Rows;
|
||||
string Usuario = DdlChofer.SelectedItem.Text;
|
||||
|
||||
|
||||
|
||||
|
||||
int CveDireccionOrigen = -1;
|
||||
foreach (GridViewRow row in Grid)
|
||||
{
|
||||
//int CvePaqueteriasGuias = row.DataKey("CvePaqueteriaGuia").ToEntero();
|
||||
int Orden = row.DataKey("Orden").ToEntero();
|
||||
|
||||
//if (ObjGeneral.AsignarEntregasPorRealizar(CvePaqueteriasGuias, CvePersonal: -1, CveAsignacionEntrega: CveAsignacionEntrega, Orden: Orden))
|
||||
//{
|
||||
|
||||
int CveDireccionDestino = row.DataKey("CveDireccionEnvio").ToEntero();
|
||||
int CveDireccionDestino = row.DataKey("CveDireccionEnvio").ToEntero();
|
||||
|
||||
if (CveDireccionDestino <= 0)
|
||||
{
|
||||
@@ -178,40 +154,162 @@ 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,0);
|
||||
int CveEntregaAlmacen = ObjGeneral.AddInvEntregaAlmacenRuta(row.DataKey("CveSubProyectoOrigen").ToEntero(), CveDireccionOrigen, CveDireccionDestino, row.DataKey("CveMovimiento").ToEntero(), DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), "E",Orden,0);
|
||||
CveDireccionOrigen = row.DataKey("CveDireccionEnvio").ToEntero();
|
||||
|
||||
if (CveEntregaAlmacen > 0)
|
||||
{
|
||||
DateTime MinFecha = new DateTime(1900, 01, 01);
|
||||
int CveTimbre = ObjGeneral.AddGralTimbre("Tra", "-1", -1, "", MinFecha, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, -1, ChkEmitirCartaPorte.Checked, CveEntregaAlmacen, row.DataKey("CveSubProyectoOrigen").ToEntero());
|
||||
{
|
||||
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;
|
||||
|
||||
TieneError = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ListaTimbres.Add(CveTimbre);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar entrega alamcen. ");
|
||||
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 <br/><br/>");
|
||||
|
||||
foreach (int cvetimbre in ListaTimbres)
|
||||
{
|
||||
Timbres ObjTimbres = new Timbres("Ent", cvetimbre, UsuarioActual);
|
||||
MensajeAlert.AppendFormat("Folio: <b>{0}</b> ", ObjTimbres.ObjFactura.SerieFolio);
|
||||
if (ObjTimbres.Timbrar())
|
||||
{
|
||||
|
||||
MensajeAlert.AppendFormat("<a class='texto' style='color:#337ab7' href='/Compras/PopUpVerFactura.aspx?P={0}' target='_blank'>XML <i class='fa fa-file'></i></i></a> ", ModExtensiones.Encripta(String.Format("OP=DesXmlTra&CveTimbre={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", cvetimbre, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto)));
|
||||
MensajeAlert.AppendFormat("<a class='texto' style='color:#337ab7' href='/Compras/PopUpVerFactura.aspx?P={0}' target='_blank'>PDF <i class='fa fa-ad-pdf'></i></i></i></a> ", ModExtensiones.Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", cvetimbre)));
|
||||
MensajeAlert.Append("<br/>");
|
||||
|
||||
Alert(MensajeAlert.ToString(), ModExtensiones.TipoMensaje.MsgInformacion);
|
||||
CargaDatos();
|
||||
DdlChofer.SelectedValueExist("-1");
|
||||
DdlUnidadCamion.SelectedValueExist("-1");
|
||||
ChkEmitirCartaPorte.Checked = false;
|
||||
|
||||
SeleccionEntrega = false;
|
||||
SeleccionarGenerar(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
MensajeAlert.AppendFormat("<ul><li>{0}</li></ul>", ObjTimbres.MsgError);
|
||||
}
|
||||
}
|
||||
UpDatos.Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjGeneral.RollBack();
|
||||
}
|
||||
ObjGeneral.Dispose();
|
||||
}else
|
||||
{
|
||||
Alert(SBError.ToString(), ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void LnkGeneraRecoleccion_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<int> ListaTimbres = new List<int>();
|
||||
|
||||
|
||||
bool TieneError = false;
|
||||
ClsGenerales ObjGeneral = new ClsGenerales();
|
||||
ObjGeneral.IniciaTransacSQL();
|
||||
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)
|
||||
{
|
||||
int CveTimbre = ObjGeneral.AddGralTimbre("Rec", row.DataKey("CveSubProyectoDestino").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 alamcen. ");
|
||||
TieneError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!TieneError)
|
||||
{
|
||||
|
||||
foreach (GridViewRow row in gvR.Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -229,16 +327,52 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
if (!TieneError)
|
||||
{
|
||||
ObjGeneral.Commit();
|
||||
Alert("Entregas asignadas correctamente");
|
||||
StringBuilder MensajeAlert = new StringBuilder();
|
||||
//recorrer para timbrar
|
||||
MensajeAlert.Append(" Entregas creadas correctamente <br/><br/>");
|
||||
foreach (int cvetimbre in ListaTimbres)
|
||||
{
|
||||
Timbres ObjTimbres = new Timbres("Rec", cvetimbre, UsuarioActual);
|
||||
|
||||
if (ObjTimbres.Timbrar())
|
||||
{
|
||||
//ClsPaginas.PdfFactura(ref ObjTimbres.ObjFactura,"0",true);
|
||||
|
||||
//MensajeAlert.Append("Emitido con éxito.");
|
||||
|
||||
////XML
|
||||
//string ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjTimbres.ObjFactura.TipoDocto, ObjTimbres.ObjFactura.SerieFolio);
|
||||
//if (System.IO.File.Exists(ArchivoXML))
|
||||
// MensajeAlert.AppendFormat("<ul><li><a class='Texto' href='/Compras/PopUpVerFactura.aspx?P={0}'>Descargar XML</a></li></ul>", ModExtensiones.Encripta(String.Format("OP=DesXmlTra&CveTimbre={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", cvetimbre, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto)));
|
||||
MensajeAlert.AppendFormat("Folio: <b>{0}</b> ", ObjTimbres.ObjFactura.SerieFolio);
|
||||
MensajeAlert.AppendFormat("<a class='texto' style='color:#337ab7' href='/Compras/PopUpVerFactura.aspx?P={0}' target='_blank'>XML <i class='fa fa-file'></i></i></a> ", ModExtensiones.Encripta(String.Format("OP=DesXmlTra&CveTimbre={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", cvetimbre, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto)));
|
||||
MensajeAlert.AppendFormat("<a class='texto' style='color:#337ab7' href='/Compras/PopUpVerFactura.aspx?P={0}' target='_blank'>PDF <i class='fa fa-ad-pdf'></i></i></i></a> ", ModExtensiones.Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", cvetimbre)));
|
||||
MensajeAlert.Append("<br/>");
|
||||
////PDF
|
||||
//string ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjTimbres.ObjFactura.TipoDocto, ObjTimbres.ObjFactura.SerieFolio);
|
||||
//if (System.IO.File.Exists(ArchivoPDF))
|
||||
// MensajeAlert.AppendFormat("<ul><li><a class='Texto' href='/Compras/PopUpVerFactura.aspx?P={0}'>Descargar PDF</a></li></ul>", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto)));
|
||||
|
||||
|
||||
//if (UsuarioActual.Empresa.Funcionalidad(161) == "1")
|
||||
// MensajeAlert.AppendFormat("<ul><li><a class='Texto' href='/Compras/PopUpVerFactura.aspx?P={0}'>Descargar Carta Porte</a></li></ul>", Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", cvetimbre)));
|
||||
//else
|
||||
// MensajeAlert.AppendFormat("<ul><li><a class='Texto' href='/Compras/PopUpVerFactura.aspx?P={0}'>Descargar Carta Porte</a></li></ul>", ModExtensiones.Encripta(String.Format("OP=CARPO&CveTimbre={0}", cvetimbre)));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MensajeAlert.AppendFormat("<ul><li>{0}</li></ul>", ObjTimbres.MsgError);
|
||||
}
|
||||
}
|
||||
Alert(MensajeAlert.ToString(), ModExtensiones.TipoMensaje.MsgInformacion);
|
||||
CargaDatos();
|
||||
DdlChofer.SelectedValueExist("-1");
|
||||
DdlUnidadCamion.SelectedValueExist("-1");
|
||||
ChkEmitirCartaPorte.Checked = false;
|
||||
|
||||
SelecionEntrega = false;
|
||||
SeleccioanrGenrar();
|
||||
|
||||
CargaDatos();
|
||||
SeleccionEntrega = false;
|
||||
SeleccionarGenerar(1);
|
||||
UpDatos.Update();
|
||||
}
|
||||
else
|
||||
@@ -246,176 +380,157 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
ObjGeneral.RollBack();
|
||||
}
|
||||
ObjGeneral.Dispose();
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert(SBError.ToString(), ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
|
||||
}
|
||||
private void CargaDatos()
|
||||
{
|
||||
ClsGenerales ObjGeneral = new ClsGenerales();
|
||||
if (ObjGeneral.GetInvEntregaAlmacenRuta(DdlSubProyecto.SelectedValue.ToEntero(), TxtFechaI.Text.ToDate(), TxtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 1))
|
||||
{
|
||||
GvPaqueteriasGuias.DataSource = ObjGeneral.DtResultados;
|
||||
GvEntregas.DataSource = ObjGeneral.DtResultados;
|
||||
DTDatosConsulta = ObjGeneral.DtResultados;
|
||||
DTGenrarDocumentos = ObjGeneral.DtResultados.Clone();
|
||||
DTGenerarDocumentos = ObjGeneral.DtResultados.Clone();
|
||||
|
||||
}
|
||||
ObjGeneral.Dispose();
|
||||
GvPaqueteriasGuias.DataBind();
|
||||
GvEntregas.DataBind();
|
||||
|
||||
UpDatos.Update();
|
||||
}
|
||||
|
||||
|
||||
private void CargaCombos()
|
||||
{
|
||||
|
||||
ClsInventarios ObjInventarios = new ClsInventarios();
|
||||
DdlUnidadCamion.DataSource = get_GlobalDTInvCamiones(UsuarioActual.CveEmpresa);
|
||||
|
||||
if(ObjInventarios.GetCamiones(-1, UsuarioActual.CveEmpresa) && ObjInventarios.DtResultados.Rows.Count > 0){
|
||||
DdlUnidadCamion.DataSource = ObjInventarios.DtResultados;
|
||||
}
|
||||
ObjInventarios.Dispose();
|
||||
DdlUnidadCamion.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||||
DdlUnidadCamion.DataBind();
|
||||
|
||||
TxtFechaI.Text = DateTime.Now.AddDays(-1).ToShortDateString();
|
||||
TxtFechaF.Text = DateTime.Now.ToShortDateString();
|
||||
|
||||
ClsAcarreos ObjAcar = new ClsAcarreos();
|
||||
|
||||
if(ObjAcar.GetChofer(-1, UsuarioActual.CveEmpresa, 1, -1) ){
|
||||
DdlChofer.DataSource = ObjAcar.DtResultados;
|
||||
DdlChofer.DataBind();
|
||||
}
|
||||
ObjAcar.Dispose();
|
||||
|
||||
DdlChofer.DataSource = get_GlobalDTChoferes(UsuarioActual.CveEmpresa);
|
||||
DdlChofer.DataBind();
|
||||
DdlChofer.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||||
|
||||
TxtFechaEntrega.Text = DateTime.Now.ToShortDateString();
|
||||
|
||||
TxtFechaEntrega.Text = DateTime.Now.ToShortDateString();
|
||||
|
||||
CargarCentrosDeCosto(null, DdlSubProyecto, null, LblSubProyecto);
|
||||
CargarCentrosDeCosto(null, DdlSubProyectoRecoleccion, null, LblSubProyectoRecoleccion);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
SeleccioanrGenrar();
|
||||
}
|
||||
SeleccionarGenerar(1);
|
||||
}
|
||||
private void SeleccionarGenerar(int Opcion ) {
|
||||
|
||||
|
||||
private void SeleccioanrGenrar() {
|
||||
|
||||
if (SelecionEntrega)
|
||||
if (SeleccionEntrega)
|
||||
{
|
||||
|
||||
DTGenrarDocumentos.Rows.Clear();
|
||||
DTGenerarDocumentos.Rows.Clear();
|
||||
|
||||
|
||||
|
||||
int CountRows = 0;
|
||||
foreach (GridViewRow GvRow in GvPaqueteriasGuias.Rows)
|
||||
if (Opcion == 2) //cuando es recolección
|
||||
{
|
||||
|
||||
CheckBox ChkAsigna = GvRow.FCCheckBox("ChkAsigna");
|
||||
|
||||
if (ChkAsigna.Checked)
|
||||
int CountRows = 0;
|
||||
foreach (GridViewRow GvRow in gvR.Rows)
|
||||
{
|
||||
|
||||
int CveMovimiento = GvRow.DataKey("CveMovimiento").ToEntero();
|
||||
CheckBox ChkAsigna = GvRow.FCCheckBox("Chk");
|
||||
|
||||
DataRow dRow = DTGenrarDocumentos.NewRow();
|
||||
DataRow dRowOrigen = DTDatosConsulta.FiltraParametros($"CveMovimiento = {CveMovimiento}").Rows[0];
|
||||
|
||||
int IndexColun = 0;
|
||||
foreach (DataColumn dColumn in DTDatosConsulta.Columns)
|
||||
if (ChkAsigna.Checked)
|
||||
{
|
||||
dRow[IndexColun] = dRowOrigen[IndexColun];
|
||||
IndexColun++;
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
dRow["Num"] = CountRows + 1;
|
||||
DTGenrarDocumentos.Rows.Add(dRow);
|
||||
CountRows++;
|
||||
}
|
||||
}
|
||||
|
||||
DTGenrarDocumentos.AcceptChanges();
|
||||
|
||||
|
||||
|
||||
|
||||
SelecionEntrega = false;
|
||||
LnkGenerarDocumentos.Text = "Regresar a Preselección";
|
||||
LnkGenerarDocumentos.CssClass = "btn btn-default";
|
||||
|
||||
|
||||
|
||||
|
||||
OcultarmostarDatosEntrega(true);
|
||||
|
||||
|
||||
|
||||
BtnConsultar.Visible = false;
|
||||
|
||||
UpDatos.Update();
|
||||
UpFiltro.Update();
|
||||
|
||||
|
||||
if (CountRows > 0)
|
||||
{
|
||||
GvGenerarDocumentos.DataSource = DTGenrarDocumentos;
|
||||
GvGenerarDocumentos.DataBind();
|
||||
|
||||
DVGvGenerarDocumentos.Visible = true;
|
||||
BtnAsignar.Visible = true;
|
||||
DVGvPaqueteriasGuias.Visible = false;
|
||||
|
||||
RegistraScript("InitOrdenamientoGvGenerarDocumentos();");
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("No hay entregas seleccionadas", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
return;
|
||||
|
||||
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;
|
||||
SelecionEntrega = true;
|
||||
LnkGenerarDocumentos.Text = "Preselección de Entregas";
|
||||
SeleccionEntrega = true;
|
||||
LnkGenerarDocumentos.Text = "Preseleccionar";
|
||||
LnkGenerarDocumentos.CssClass = "btn btn-primary";
|
||||
|
||||
|
||||
@@ -423,15 +538,13 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
|
||||
BtnAsignar.Visible = false;
|
||||
DVGvGenerarDocumentos.Visible = false;
|
||||
DVGvPaqueteriasGuias.Visible = true;
|
||||
DVGvEntregas.Visible = true;
|
||||
UpDatos.Update();
|
||||
UpFiltro.Update();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OcultarmostarDatosEntrega(bool mostrar )
|
||||
{
|
||||
DVDatosEntrega1.Visible = mostrar;
|
||||
@@ -452,34 +565,32 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
|
||||
if (UsuarioActual.Empresa.Funcionalidad(161).ToEntero() == 1)
|
||||
{
|
||||
DvCartaPorte1.Visible = mostrar;
|
||||
DvCartaPorte2.Visible = mostrar;
|
||||
}
|
||||
UpDatosEntrega.Update();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ActualizaOrdenDTGenrarDocumentos()
|
||||
private void ActualizaOrdenDTGenerarDocumentos()
|
||||
{
|
||||
string[] OrdenMovimientos = Request.Form.GetValues("OrdenMovimientos");
|
||||
|
||||
int NumOrden = 1;
|
||||
foreach (string CveMovimiento in OrdenMovimientos)
|
||||
{
|
||||
foreach(DataRow dRow in DTGenrarDocumentos.Rows)
|
||||
foreach(DataRow dRow in DTGenerarDocumentos.Rows)
|
||||
{
|
||||
if (CveMovimiento.ToEntero() == dRow["CveMovimiento"].ToString().ToEntero() )
|
||||
{
|
||||
dRow["Orden"] = NumOrden;
|
||||
}
|
||||
}
|
||||
DTGenrarDocumentos.AcceptChanges();
|
||||
DTGenerarDocumentos.AcceptChanges();
|
||||
NumOrden++;
|
||||
}
|
||||
|
||||
|
||||
DataView DTview = new DataView(DTGenrarDocumentos);
|
||||
|
||||
DataView DTview = new DataView(DTGenerarDocumentos);
|
||||
|
||||
// Sort by State and ZipCode column in descending order
|
||||
DTview.Sort = "Orden ASC";
|
||||
@@ -533,17 +644,13 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
ClsGenerales ObjGeneral = new ClsGenerales();
|
||||
if (ObjGeneral.GetInvEntregaAlmacenRuta(DdlSubProyecto.SelectedValue.ToEntero(), TxtFechaI.Text.ToDate(), TxtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, 2, 0))
|
||||
{
|
||||
GvDatosRecoleccion.DataSource = ObjGeneral.DtResultados;
|
||||
gvR.DataSource = ObjGeneral.DtResultados;
|
||||
}
|
||||
ObjGeneral.Dispose();
|
||||
GvDatosRecoleccion.DataBind();
|
||||
UpDatosRecoleccion.Update();
|
||||
|
||||
|
||||
|
||||
gvR.DataBind();
|
||||
UpDatosRecoleccion.Update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void CargaDatosRecoleccionDetallePS()
|
||||
{
|
||||
if (CveEntregaAlmacen > 0)
|
||||
@@ -564,21 +671,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
}
|
||||
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();
|
||||
@@ -591,17 +684,13 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
ClsClientes ObjClientes = new ClsClientes();
|
||||
if (ObjClientes.DireccionEnvioGet(-1, DdlModalRecoleccionCliente.SelectedValue.ToEntero(), -1))
|
||||
{
|
||||
DdlmodalRecoleccionDirecion.DataSource = ObjClientes.DtResultados;
|
||||
DdlmodalRecoleccionDireccion.DataSource = ObjClientes.DtResultados;
|
||||
}
|
||||
ObjClientes.Dispose();
|
||||
ObjClientes.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
DdlmodalRecoleccionDirecion.DataSource = null;
|
||||
}
|
||||
|
||||
DdlmodalRecoleccionDirecion.DataBind();
|
||||
DdlmodalRecoleccionDirecion.Items.Insert(0, new ListItem("Seleccione una", "-1"));
|
||||
DdlmodalRecoleccionDireccion.DataBind();
|
||||
DdlmodalRecoleccionDireccion.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||||
|
||||
UpModalRecoleccion.Update();
|
||||
}
|
||||
@@ -609,21 +698,8 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
|
||||
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";
|
||||
|
||||
LtlModalRecoleccionTitulo.Text = "Agregar Recolección";
|
||||
BtnModalRecoleccionGuardar.Text = "Agregar";
|
||||
|
||||
LimpiarModalRecoleccion();
|
||||
@@ -648,16 +724,16 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
|
||||
if (ObjClientes.DireccionEnvioGet(-1, CveClienteEnvio, -1))
|
||||
{
|
||||
DdlmodalRecoleccionDirecion.DataSource = ObjClientes.DtResultados;
|
||||
DdlmodalRecoleccionDireccion.DataSource = ObjClientes.DtResultados;
|
||||
}
|
||||
}
|
||||
ObjClientes.Dispose();
|
||||
|
||||
DdlmodalRecoleccionDirecion.DataBind();
|
||||
DdlmodalRecoleccionDirecion.Items.Add(new ListItem("Seleccione una", "-1"));
|
||||
DdlmodalRecoleccionDirecion.SelectedValueExist(CveDireccionOrigen);
|
||||
DdlmodalRecoleccionDireccion.DataBind();
|
||||
DdlmodalRecoleccionDireccion.Items.Add(new ListItem("Seleccione una", "-1"));
|
||||
DdlmodalRecoleccionDireccion.SelectedValueExist(CveDireccionOrigen);
|
||||
|
||||
DdlModalRecoleccionCliente.SelectedValueExist(CveClienteEnvio);
|
||||
//DdlModalRecoleccionCliente.SelectedValueExist(CveClienteEnvio);
|
||||
|
||||
|
||||
CargaDatosRecoleccionDetallePS();
|
||||
@@ -673,8 +749,8 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
private void LimpiarModalRecoleccion()
|
||||
{
|
||||
|
||||
DdlModalRecoleccionCliente.SelectedValueExist(-1);
|
||||
DdlmodalRecoleccionDirecion.SelectedValueExist(-1);
|
||||
// DdlModalRecoleccionCliente.SelectedValueExist(-1);
|
||||
DdlmodalRecoleccionDireccion.SelectedValueExist(-1);
|
||||
TxtModalRecoleccionCantidad.Text = "";
|
||||
DdlModalRecoleccionUnidad.Items.Clear();
|
||||
DdlModalRecoleccionUnidad.Items.Add(new ListItem("Seleccione una","-1"));
|
||||
@@ -705,72 +781,62 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
protected void BtnModalRecoleccionGuardar_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (DdlChofer.SelectedValue.ToEntero() <= 0)
|
||||
{
|
||||
Alert("Debe seleccionar un chofer.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
return;
|
||||
}
|
||||
//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;
|
||||
}
|
||||
//if (DdlUnidadCamion.SelectedValue.ToEntero() <= 0)
|
||||
//{
|
||||
// Alert("Debe seleccionar una unidad", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
if (DdlmodalRecoleccionDireccion.SelectedValue.ToEntero() <= 0)
|
||||
{
|
||||
Alert("Debe seleccionar la dirección de recolección", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
return;
|
||||
}
|
||||
int CveTimbrenuevo = -1;
|
||||
bool ProcesoOK = false;
|
||||
|
||||
bool ProcesoOK = false;
|
||||
|
||||
|
||||
|
||||
int CveSubProyectoCliente = get_GlobalDTCliente(UsuarioActual.CveEmpresa, -1, DdlModalRecoleccionCliente.SelectedValue.ToEntero()).FiltroPrimeroValor("CveSubProyecto").ToEntero();
|
||||
//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);
|
||||
CveEntregaAlmacen = ObjGenerales.AddInvEntregaAlmacenRuta(DdlSubProyectoRecoleccion.SelectedValue.ToEntero(), DdlmodalRecoleccionDireccion.SelectedValue.ToEntero(), -1,-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);
|
||||
//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 (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;
|
||||
}
|
||||
ProcesoOK = ObjGenerales.UpdateInvEntregaAlmacenRuta(CveEntregaAlmacen, DdlmodalRecoleccionDireccion.SelectedValue.ToEntero(), -1, DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveEmpresa);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (ProcesoOK)
|
||||
{
|
||||
@@ -780,6 +846,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
}
|
||||
else
|
||||
{
|
||||
CveEntregaAlmacen = -1;
|
||||
ObjGenerales.RollBack();
|
||||
}
|
||||
|
||||
@@ -880,17 +947,13 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas
|
||||
DdlProducto2.txtValue.Value = "";
|
||||
UpModalRecoleccion.Update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected void Tab_ActiveTabChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(Tab.ActiveTabIndex == 0)
|
||||
{
|
||||
SelecionEntrega = false;
|
||||
SeleccioanrGenrar();
|
||||
|
||||
SeleccionEntrega = false;
|
||||
SeleccionarGenerar(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user