Entregas por realizar ordenamiento, carta porte correciones
This commit is contained in:
@@ -11,24 +11,83 @@ using System.Text;
|
||||
|
||||
public partial class Inventarios_EntregasPorRealizar : ClsPaginas
|
||||
{
|
||||
|
||||
|
||||
|
||||
DataTable DTGenrarDocumentos
|
||||
{
|
||||
get {
|
||||
|
||||
if(ViewState["DTGenrarDocumentos"] == null){
|
||||
ViewState["DTGenrarDocumentos"] = new DataTable();
|
||||
}
|
||||
return (DataTable)ViewState["DTGenrarDocumentos"];
|
||||
|
||||
}
|
||||
set {
|
||||
ViewState["DTGenrarDocumentos"] = (DataTable)value;
|
||||
}
|
||||
}
|
||||
|
||||
DataTable DTDatosConsulta
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (ViewState["DTDatosConsulta"] == null)
|
||||
{
|
||||
ViewState["DTDatosConsulta"] = new DataTable();
|
||||
}
|
||||
return (DataTable)ViewState["DTDatosConsulta"];
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["DTDatosConsulta"] = (DataTable)value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SelecionEntrega
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (ViewState["SelecionEntrega"] == null)
|
||||
{
|
||||
ViewState["SelecionEntrega"] = false;
|
||||
}
|
||||
return (bool) ViewState["SelecionEntrega"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["SelecionEntrega"] = (bool)value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
SelecionEntrega = true;
|
||||
CargarEntregas();
|
||||
CargarPersonal();
|
||||
}
|
||||
}
|
||||
|
||||
protected void BtnAsignar_Click(object sender,EventArgs e)
|
||||
protected void BtnAsignar_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
ActualizaOrdenDTGenrarDocumentos();
|
||||
|
||||
|
||||
if (DdlUsuario.SelectedValue.ToEntero() > 0)
|
||||
{
|
||||
bool TieneError = false;
|
||||
ClsGenerales ObjGeneral = new ClsGenerales();
|
||||
ObjGeneral.IniciaTransacSQL();
|
||||
GridViewRowCollection Grid = GvPaqueteriasGuias.Rows;
|
||||
|
||||
GridViewRowCollection Grid = GvGenerarDocumentos.Rows;
|
||||
|
||||
int CvePersonal = DdlUsuario.SelectedValue.ToEntero();
|
||||
long CveAsignacionEntrega = DateTime.Now.Ticks;
|
||||
@@ -37,66 +96,68 @@ public partial class Inventarios_EntregasPorRealizar : ClsPaginas
|
||||
string LigaPopUpVerFactura = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", ModExtensiones.Encripta(String.Format("OP=ENTREGAS&CVEASIGNACIONENTREGA={0}&USUARIOENTREGA={1}", CveAsignacionEntrega, Usuario)));
|
||||
foreach (GridViewRow row in Grid)
|
||||
{
|
||||
if (row.FCCheckBox("ChkAsigna").Checked)
|
||||
int CvePaqueteriasGuias = row.DataKey("CvePaqueteriaGuia").ToEntero();
|
||||
int Orden = row.DataKey("Orden").ToEntero();
|
||||
|
||||
if (!ObjGeneral.AsignarEntregasPorRealizar(CvePaqueteriasGuias, CvePersonal:CvePersonal, CveAsignacionEntrega: CveAsignacionEntrega, Orden: Orden))
|
||||
{
|
||||
int CvePaqueteriasGuias = row.DataKey("CvePaqueteriaGuia").ToEntero();
|
||||
|
||||
if(!ObjGeneral.AsignarEntregasPorRealizar(CvePaqueteriasGuias, CvePersonal, CveAsignacionEntrega)){
|
||||
TieneError = true;
|
||||
}else
|
||||
{
|
||||
try
|
||||
{
|
||||
MandarNotificacionCorreo(row);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TieneError = true;
|
||||
ModExtensiones.GuardaLog(ex.Message);
|
||||
}
|
||||
//string CobranzaCorreo = row.DataKey("CobranzaCorreo");
|
||||
//string CorreoEntregaAlmacen = row.DataKey("CorreoEntregaAlmacen");
|
||||
//string CorreoEntregaCompras = row.DataKey("CorreoEntregaCompras");
|
||||
//string CorreoVendedor = row.DataKey("Correo");
|
||||
//string CorreoAdicionalNotificacionesVendedor = row.DataKey("CorreoAdicionalNotificaciones");
|
||||
|
||||
//string CorreosCC = string.Format("{0};{1};{2};{3}", CorreoVendedor, CorreoAdicionalNotificacionesVendedor, CobranzaCorreo, CorreoEntregaCompras);
|
||||
//string LogCorreo = string.Format("{0} -- {1} --- {2}", "Tipo de entrega", CorreoEntregaAlmacen, CorreosCC);
|
||||
//LogCorreo.GuardaLog();
|
||||
|
||||
//ClsSisMail MailCls = new ClsSisMail();
|
||||
//MailCls.SendMail(ClsPaginas.EmpresaNotificaciones, CorreoVendedor, "Se enviara la compra a su dirección", "Pendiente", CorreosCC);
|
||||
//MailCls = null;
|
||||
}
|
||||
TieneError = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!TieneError)
|
||||
{
|
||||
ObjGeneral.Commit();
|
||||
Alert(String.Format("Entregas asignadas correctamente <br/><br/><a style='color:#23527c' href='{0}'>Imprimir Reporte de Entregas Asignadas</a>", LigaPopUpVerFactura));
|
||||
CargarEntregas();
|
||||
UpDatos.Update();
|
||||
|
||||
foreach (GridViewRow row in Grid)
|
||||
{
|
||||
try
|
||||
{
|
||||
MandarNotificacionCorreo(row);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TieneError = true;
|
||||
ModExtensiones.GuardaLog(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!TieneError)
|
||||
{
|
||||
ObjGeneral.Commit();
|
||||
Alert(String.Format("Entregas asignadas correctamente <br/><br/><a style='color:#23527c' href='{0}'>Imprimir Reporte de Entregas Asignadas</a>", LigaPopUpVerFactura));
|
||||
|
||||
SelecionEntrega = false;
|
||||
SeleccioanrGenrar();
|
||||
|
||||
CargarEntregas();
|
||||
UpDatos.Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjGeneral.RollBack();
|
||||
}
|
||||
ObjGeneral.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjGeneral.RollBack();
|
||||
Alert("Seleccione a alguien del personal", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
ObjGeneral.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("Seleccione a alguien del personal",ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
}
|
||||
|
||||
private void CargarEntregas()
|
||||
{
|
||||
ClsGenerales ObjGeneral = new ClsGenerales();
|
||||
if (ObjGeneral.GetEntregasPorRealizar(UsuarioActual.CveEmpresa))
|
||||
{
|
||||
GvPaqueteriasGuias.DataSource = ObjGeneral.DtResultados;
|
||||
|
||||
DTDatosConsulta = ObjGeneral.DtResultados;
|
||||
DTGenrarDocumentos = ObjGeneral.DtResultados.Clone();
|
||||
|
||||
}
|
||||
ObjGeneral.Dispose();
|
||||
GvPaqueteriasGuias.DataBind();
|
||||
@@ -227,4 +288,137 @@ public partial class Inventarios_EntregasPorRealizar : ClsPaginas
|
||||
MailCls.SendMail(ClsPaginas.EmpresaNotificaciones, Para, "Entrega en camino", body, Para);
|
||||
MailCls = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void LnkGenerarDocumentos_Click(object sender, EventArgs e)
|
||||
{
|
||||
SeleccioanrGenrar();
|
||||
}
|
||||
|
||||
|
||||
private void SeleccioanrGenrar() {
|
||||
|
||||
if (SelecionEntrega)
|
||||
{
|
||||
|
||||
|
||||
if (DdlUsuario.SelectedValue.ToEntero() <= 0)
|
||||
{
|
||||
Alert("Debe seleccionar entregas", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
return;
|
||||
}
|
||||
|
||||
DTGenrarDocumentos.Rows.Clear();
|
||||
|
||||
|
||||
|
||||
int CountRows = 0;
|
||||
foreach (GridViewRow GvRow in GvPaqueteriasGuias.Rows)
|
||||
{
|
||||
|
||||
CheckBox ChkAsigna = GvRow.FCCheckBox("ChkAsigna");
|
||||
|
||||
if (ChkAsigna.Checked)
|
||||
{
|
||||
|
||||
int CvePaqueteriaGuia = GvRow.DataKey("CvePaqueteriaGuia").ToEntero();
|
||||
|
||||
DataRow dRow = DTGenrarDocumentos.NewRow();
|
||||
DataRow dRowOrigen = DTDatosConsulta.FiltraParametros($"CvePaqueteriaGuia = {CvePaqueteriaGuia}").Rows[0];
|
||||
|
||||
int IndexColun = 0;
|
||||
foreach (DataColumn dColumn in DTDatosConsulta.Columns)
|
||||
{
|
||||
dRow[IndexColun] = dRowOrigen[IndexColun];
|
||||
IndexColun++;
|
||||
}
|
||||
|
||||
dRow["Num"] = CountRows + 1;
|
||||
DTGenrarDocumentos.Rows.Add(dRow);
|
||||
CountRows++;
|
||||
}
|
||||
}
|
||||
|
||||
DTGenrarDocumentos.AcceptChanges();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
SelecionEntrega = false;
|
||||
LnkGenerarDocumentos.Text = "Regresa a selección";
|
||||
|
||||
BtnAsignar.Visible = true;
|
||||
|
||||
UpDatos.Update();
|
||||
UpFiltro.Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SelecionEntrega = true;
|
||||
LnkGenerarDocumentos.Text = "Generar Documentos";
|
||||
BtnAsignar.Visible = true;
|
||||
DVGvGenerarDocumentos.Visible = false;
|
||||
DVGvPaqueteriasGuias.Visible = true;
|
||||
UpDatos.Update();
|
||||
UpFiltro.Update();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void GvGenerarDocumentos_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
if(e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
// e.Row.CssClass = $"{e.Row.CssClass} RowOrdenamiento";
|
||||
// e.Row.Attributes.Add("onmouseup ", "alert('boton liberado')");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ActualizaOrdenDTGenrarDocumentos()
|
||||
{
|
||||
string[] OrdenCvePaqueteriaGuia = Request.Form.GetValues("OrdenCvePaqueteriaGuia");
|
||||
|
||||
int NumOrden = 1;
|
||||
foreach (string CvePaqueteriaGuia in OrdenCvePaqueteriaGuia)
|
||||
{
|
||||
foreach(DataRow dRow in DTGenrarDocumentos.Rows)
|
||||
{
|
||||
if (CvePaqueteriaGuia.ToEntero() == dRow["CvePaqueteriaGuia"].ToString().ToEntero() )
|
||||
{
|
||||
dRow["Orden"] = NumOrden;
|
||||
}
|
||||
}
|
||||
DTGenrarDocumentos.AcceptChanges();
|
||||
NumOrden++;
|
||||
}
|
||||
|
||||
GvGenerarDocumentos.DataSource = DTGenrarDocumentos;
|
||||
GvGenerarDocumentos.DataBind();
|
||||
UpDatos.Update();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user