Beispiel #1
0
    protected void btn_confirmarMov_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(hf_soliId.Value) && string.IsNullOrEmpty(hf_traiId.Value))
        {
            utils.ShowMessage2(this, "modifica", "warn_trailerVacio"); return;
        }
        if (!Convert.ToBoolean(hf_ordenAndenesOk.Value))
        {
            utils.ShowMessage2(this, "nuevo", "warn_ordenAnden"); return;
        }
        DateTime fh = Convert.ToDateTime(string.Format("{0} {1}", txt_solFecha.Text, txt_solHora.Text));

        if (DateTime.Now.AddMinutes(57) > fh)
        {
            utils.ShowMessage2(this, "nuevo", "warn_horaInvalida"); return;
        }
        DataTable dtAndenes = (DataTable)ViewState["andenes"];
        DataTable dtLocales = (DataTable)ViewState["locales"];
        int       registros;

        try
        {
            registros = dtLocales.Rows.Count;
        }
        catch (NullReferenceException)
        {
            registros = 0;
        }
        if (registros == 0)
        {
            utils.ShowMessage2(this, "nuevo", "warn_andenVacio");
        }
        else
        {
            SolicitudBC s  = new SolicitudBC();
            TrailerBC   tr = new TrailerBC();
            DataSet     ds = new DataSet();
            s.ID_TIPO          = 1;
            s.ID_SITE          = Convert.ToInt32(dropsite.SelectedValue);
            s.ID_USUARIO       = usuario.ID; //Variable sesión
            s.FECHA_CREACION   = DateTime.Now;
            s.FECHA_PLAN_ANDEN = Convert.ToDateTime(string.Format("{0} {1}", txt_solFecha.Text, txt_solHora.Text));
            s.DOCUMENTO        = "";
            s.OBSERVACION      = "";
            s.RUTA             = txt_ruta.Text;
            s.ID_SHORTECK      = ddl_idShortek.SelectedValue;
            if (!String.IsNullOrEmpty(hf_traiId.Value))
            {
                s.ID_TRAILER_RESERVADO = Convert.ToInt32(hf_traiId.Value);
            }
            s.TETR_ID         = Convert.ToInt32(DDL_TEMP.SelectedValue);
            s.Pallets         = Convert.ToInt32(txt_totalPallets.Text);
            s.CARACTERISTICAS = hf_caractSolicitud.Value;
            DataView dw      = new DataView((DataTable)ViewState["trailers"]);
            string   mensaje = "";
            dtAndenes.TableName = "ANDENES";
            dtLocales.TableName = "LOCALES";
            ds.Tables.Add(dtAndenes);
            ds.Tables.Add(dtLocales);
            if (hf_soliId.Value == "0")
            {
                if (s.Carga(ds, out mensaje) && mensaje == "")
                {
                    utils.ShowMessage2(this, "nuevo", "success");
                    btn_limpiarDatos_Click(null, null);
                }
                else
                {
                    utils.ShowMessage(this, mensaje, "error", false);
                }
            }
            else
            {
                s.SOLI_ID   = Convert.ToInt32(this.hf_soliId.Value);
                s.TIMESTAMP = DateTime.Parse(this.hf_timeStamp.Value);
                if (!s.validarTimeStamp())
                {
                    utils.ShowMessage2(this, "modifica", "warn_timestamp"); return;
                }
                if (s.ModificarCarga(ds, out mensaje) && mensaje == "")
                {
                    utils.ShowMessage2(this, "modifica", "success");
                    Response.Redirect("control_carga_new.aspx");
                }
                else
                {
                    utils.ShowMessage(this, mensaje, "error", false);
                }
            }
        }
    }
Beispiel #2
0
 protected void btn_confirmarMov_Click(object sender, EventArgs e)
 {
     if (this.hf_ordenAndenesOk.Value.ToLower() == "true")
     {
         DataTable dtAndenes = (DataTable)ViewState["andenes"];
         DataTable dtLocales = (DataTable)ViewState["locales"];
         int       registros;
         try
         {
             registros = dtLocales.Rows.Count;
         }
         catch (NullReferenceException)
         {
             registros = 0;
         }
         if (registros == 0)
         {
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('No hay andenes de carga seleccionados para la solicitud');", true);
         }
         else
         {
             SolicitudBC s = new SolicitudBC();
             s.ID_TIPO          = 1;
             s.ID_SITE          = Convert.ToInt32(this.dropsite.SelectedValue);
             s.ID_USUARIO       = usuario.ID; //Variable sesión
             s.FECHA_CREACION   = DateTime.Now;
             s.FECHA_PLAN_ANDEN = Convert.ToDateTime(string.Format("{0} {1}", this.txt_solFecha.Text, this.txt_solHora.Text));
             s.DOCUMENTO        = "";
             s.OBSERVACION      = "";
             s.RUTA             = this.txt_ruta.Text;
             s.ID_SHORTECK      = this.ddl_idShortek.SelectedValue;
             if (!String.IsNullOrEmpty(this.hf_traiId.Value))
             {
                 s.ID_TRAILER_RESERVADO = Convert.ToInt32(this.hf_traiId.Value);
             }
             s.TETR_ID         = Convert.ToInt32(this.DDL_TEMP.SelectedValue);
             s.Pallets         = Convert.ToInt32(this.txt_totalPallets.Text);
             s.CARACTERISTICAS = this.hf_caractSolicitud.Value;
             DataTable dt3 = (DataTable)(this.ViewState["trailers"]);
             if (DateTime.Now.AddMinutes(57) > s.FECHA_PLAN_ANDEN)
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Se Necesita al menos una hora para colocar el Trailer en Anden.');", true);
                 return;
             }
             if (string.IsNullOrEmpty(this.hf_traiId.Value))
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('debe seleccionar trailer');", true);
                 return;
             }
             if ((dt3 != null && dt3.Select(string.Format("TRAI_ID = {0}", this.hf_traiId.Value)).Count() < 1) && (this.hf_traiId.Value != "0" || this.hf_soliId.Value != "0"))
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer Incompatible con solicitud o bloqueado');", true);
                 return;
             }
             TrailerBC tr = new TrailerBC();
             if (s.ID_TRAILER_RESERVADO != 0)
             {
                 tr = tr.obtenerXID(int.Parse(this.hf_traiId.Value));
                 if (s.ID_TRAILER_RESERVADO != 0 && (tr.SOLI_ID != 0 || tr.MOVI_ID != 0))
                 {
                     ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer asignado a Solicitud o Movimiento');", true);
                     return;
                 }
             }
             string  mensaje = "";
             DataSet ds      = new DataSet();
             dtAndenes.TableName = "ANDENES";
             dtLocales.TableName = "LOCALES";
             ds.Tables.Add(dtAndenes);
             ds.Tables.Add(dtLocales);
             if (this.hf_soliId.Value == "0")
             {
                 if (s.Carga(ds, out mensaje) && mensaje == "")
                 {
                     ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Solicitud Creada Correctamente.');", true);
                     btn_limpiarDatos_Click(null, null);
                 }
                 else
                 {
                     ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('{0}');", mensaje), true);
                 }
             }
             else
             {
                 s.TIMESTAMP = DateTime.Parse(this.hf_timeStamp.Value);
                 if (!s.validarTimeStamp())
                 {
                     ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Timestamp incorrecto.');", true);
                     return;
                 }
                 else
                 {
                     if (s.ModificarCarga(ds, out mensaje) && mensaje == "")
                     {
                         ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Todo Ok');", true);
                         Response.Redirect("control_carga_new.aspx");
                     }
                     else
                     {
                         ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('{0}');", mensaje), true);
                     }
                 }
             }
         }
     }
 }