Beispiel #1
0
    protected void btn_reanudar_Click(object sender, EventArgs e)
    {
        if (hf_ordenAndenesOk.Value.ToLower() == "true")
        {
            SolicitudAndenesBC sa = new SolicitudAndenesBC();
            SolicitudBC        s  = new SolicitudBC();
            bool exito            = false;
            s.SOLI_ID   = int.Parse(hf_idSolicitud.Value);
            s.TIMESTAMP = DateTime.Parse(hf_timeStamp.Value);
            if (!s.validarTimeStamp())
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Timestamp incorrecto.');", true);
                exito = false;
            }
            else
            {
                sa.SOLI_ID = s.SOLI_ID;
                bool     registros = false;
                DataView dw        = new DataView((DataTable)ViewState["datosA"]);
                dw.RowFilter = "SOES_ID = -1";
                DataTable dt  = dw.ToTable(true, "SOAN_ORDEN", "ID_ANDEN");
                DataTable dt2 = dw.ToTable();
                exito = true;

                DataView dw2 = new DataView((DataTable)ViewState["datosA"]);
                dw2.RowFilter = "SOES_ID = -1 or SOES_ID = 100";
                DataTable dt4 = dw2.ToTable();
                registros = (dt4.Rows.Count > 0);
                //    exito = registros;

                foreach (DataRow row in dt.Rows)
                {
                    exito             = true;
                    registros         = true;
                    sa.MINS_CARGA_EST = 60; //Variable calculada automáticamente
                    sa.LUGA_ID        = int.Parse(row["ID_ANDEN"].ToString());
                    sa.SOAN_ORDEN     = int.Parse(row["SOAN_ORDEN"].ToString());
                    if (sa.AgregarAnden())
                    {
                        exito = true;
                    }
                    else
                    {
                        exito = false;
                        break;
                    }
                }
                if (exito)
                {
                    foreach (DataRow row in dt2.Rows)
                    {
                        SolicitudLocalesBC sl = new SolicitudLocalesBC();
                        sl.SOLI_ID    = s.SOLI_ID;
                        sl.LUGA_ID    = int.Parse(row["ID_ANDEN"].ToString());
                        sl.LOCA_ID    = int.Parse(row["ID_LOCAL"].ToString());
                        sl.PALLETS    = int.Parse(row["PALLETS"].ToString());
                        sl.SOAN_ORDEN = int.Parse(row["SOAN_ORDEN"].ToString());
                        sl.SOLD_ORDEN = int.Parse(row["ORDEN"].ToString());
                        if (sl.AgregarLocal(sl))
                        {
                            exito = true;
                        }
                        else
                        {
                            exito = false;
                            break;
                        }
                    }

                    if (!registros)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Debe agregar al menos un andén de carga para continuar la carga.');", true);
                    }
                    else if (exito)
                    {
                        //  int nuevolugar;
                        //if (rb_nuevoSi.Checked)
                        //    nuevolugar = 0;
                        //else
                        //    nuevolugar = int.Parse(ddl_nuevoAnden.SelectedValue);
                        string resultado;
                        bool   ejecucion = sa.ReanudarCarga(sa.SOLI_ID, usuario.ID, out resultado);
                        if (resultado == "" && ejecucion)
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Se reanudó la carga correctamente.');", true);
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje2", "cerrarModal('modalReanudar');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('" + resultado + "');", true);
                        }
                        btn_buscarSolicitud_Click(null, null);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Error');", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Error');", true);
                }
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Error: Compruebe el órden de los andenes seleccionados.');", true);
        }
    }
Beispiel #2
0
    protected void btn_reanudar_Click(object sender, EventArgs e)
    {
        SolicitudAndenesBC sa = new SolicitudAndenesBC();
        SolicitudBC        s  = new SolicitudBC();
        bool exito            = false;

        s.SOLI_ID   = int.Parse(this.hf_idSolicitud.Value);
        s.TIMESTAMP = DateTime.Parse(this.hf_timeStamp.Value);
        if (!s.validarTimeStamp())
        {
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Timestamp incorrecto.');", true);
            exito = false;
        }
        else
        {
            sa.SOLI_ID = s.SOLI_ID;
            bool      registros = false;
            DataTable dt2       = this.ViewState["datosA"] as DataTable;
            foreach (DataRow row in dt2.Rows)
            {
                exito     = true;
                registros = true;
                if (row["SOES_ID"].ToString() == "100")
                {
                    registros         = true;
                    sa.MINS_CARGA_EST = 60; //Variable calculada automáticamente
                    sa.LUGA_ID        = int.Parse(row["ID_ANDEN"].ToString());
                    int orden;
                    if (sa.AgregarAnden(sa, out orden) && orden > 0)
                    {
                        DataRow[] dtLocales = dt2.Select(string.Format("ID_ANDEN = {0} and orden= {1}", sa.LUGA_ID, orden));
                        foreach (DataRow rowLocal in dtLocales)
                        {
                            SolicitudLocalesBC sl = new SolicitudLocalesBC();
                            sl.SOLI_ID    = s.SOLI_ID;
                            sl.LUGA_ID    = int.Parse(rowLocal["ID_ANDEN"].ToString());
                            sl.LOCA_ID    = int.Parse(rowLocal["ID_LOCAL"].ToString());
                            sl.PALLETS    = int.Parse(rowLocal["PALLETS"].ToString());
                            sl.SOAN_ORDEN = orden;
                            sl.SOLD_ORDEN = int.Parse(rowLocal["ORDEN"].ToString());
                            if (sl.AgregarLocal(sl))
                            {
                                exito = true;
                            }
                            else
                            {
                                exito = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        exito = false;
                        break;
                    }
                }
            }
            if (!registros)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Debe agregar al menos un andén de carga para continuar la carga.');", true);
            }
            else if (exito)
            {
                //  int nuevolugar;
                //if (rb_nuevoSi.Checked)
                //    nuevolugar = 0;
                //else
                //    nuevolugar = int.Parse(ddl_nuevoAnden.SelectedValue);
                string resultado;
                bool   ejecucion = sa.ReanudarCarga(sa.SOLI_ID, this.usuario.ID, out resultado);
                if (resultado == "" && ejecucion)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Se reanudó la carga correctamente.');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('{0}');", resultado), true);
                }
                this.btn_buscarSolicitud_Click(null, null);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Error');", true);
            }
        }
    }