示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["usuario"] == null)
        {
            Response.Redirect("~/InicioQYMS2.aspx");
        }
        usuario = (UsuarioBC)Session["usuario"];

        if (!this.IsPostBack)
        {
            SolicitudBC sol = new SolicitudBC();
            CargaDrops();
            volver.Visible     = false;
            sol.ID_TIPO        = 1;
            sol.FECHA_CREACION = DateTime.Now;
            txt_solHora.Text   = DateTime.Now.AddMinutes(63).ToShortTimeString();

            txt_solFecha.Text = DateTime.Now.AddMinutes(63).ToShortDateString();
            ddl_solTemp.ClearSelection();
            ddl_largoMax.ClearSelection();
            LimpiarLocales();
            ddl_idShortek.Enabled = true;
            string request = Request.Params["type"];
            if (request != null && request == "edit")
            {
                CaractCargaBC      cc = new CaractCargaBC();
                SolicitudAndenesBC sa = new SolicitudAndenesBC();
                TrailerBC          trailer;
                DataTable          dsol;
                ddl_idShortek.Enabled = false;
                hf_soliId.Value       = Request.Params["id"].ToString();

                btn_limpiarDatos.Visible = false;
                txt_solNumero.Text       = this.hf_soliId.Value;

                sol = sol.ObtenerXId(Convert.ToInt32(hf_soliId.Value));
                dropsite.SelectedValue = sol.ID_SITE.ToString();
                drop_SelectedIndexChanged(null, null);
                hf_localesSeleccionados.Value = sol.LOCALES;
                txt_totalPallets.Text         = sol.Pallets.ToString();
                txt_ruta.Text = sol.RUTA;
                ddl_idShortek.SelectedValue = sol.ID_SHORTECK;
                hf_timeStamp.Value          = sol.TIMESTAMP.ToString();
                volver.Visible  = true;
                volver2.Visible = false;
                string[] caract = sol.CARACTERISTICAS.Split(",".ToCharArray());
                foreach (string c in caract)
                {
                    if (c != "")
                    {
                        cc = cc.obtenerSeleccionado(Convert.ToInt32(c));
                        switch (cc.CODIGO)
                        {
                        case "CCF":
                            chk_solFrio.Checked = true;
                            break;

                        case "CCS":
                            chk_solSeco.Checked = true;
                            break;

                        case "CCC":
                            chk_solCongelado.Checked = true;
                            break;

                        case "CCMF":
                            chk_solMultifrio.Checked = true;
                            break;

                        case "CCCP":
                            chk_plancha.Checked = true;
                            break;

                        case "CCWAY":
                            chk_solWays.Checked = true;
                            break;
                        }
                    }
                }
                chk_frio_CheckedChanged(null, null);
                chk_solMultifrio.Enabled = false;
                chk_solCongelado.Enabled = false;
                chk_solSeco.Enabled      = false;
                chk_solFrio.Enabled      = false;
                chk_solWays.Enabled      = false;
                dropsite.Enabled         = false;
                txt_solFecha.Enabled     = false;
                txt_solHora.Enabled      = false;
                ObtenerLocalesSolicitud(true);
                dsol = (DataTable)ViewState["locales"];
                carga_playas();
                ddl_solPlaya.SelectedValue = new LugarBC().obtenerXID(Convert.ToInt32(dsol.Rows[0]["LUGA_ID"])).ID_PLAYA.ToString();  // dsol.Rows[0]["id_playa"].ToString() ;
                ddl_solPlaya_SelectedIndexChanged(null, null);
                if (sol.TETR_ID != 0)
                {
                    DDL_TEMP.SelectedValue = sol.TETR_ID.ToString();
                }
                if (sol.ID_TRAILER != 0)
                {
                    trailer                    = new TrailerBC().obtenerXID(sol.ID_TRAILER);
                    hf_traiId.Value            = trailer.ID.ToString();
                    txt_trailerPatente.Text    = trailer.PLACA;
                    txt_trailerNro.Text        = trailer.NUMERO;
                    txt_trailerShortek.Text    = trailer.ID_SHORTEK;
                    txt_trailerTransporte.Text = trailer.TRANSPORTISTA;
                }
                calcula_solicitud(null, null);

                if (hf_traiId.Value != "" && sol.SOES_ID > 101)
                {
                    visiblasignamanual.Enabled = false;
                }
            }
            if (request != null && request == "new")
            {
                TrailerBC     trailer = new TrailerBC();
                CaractCargaBC cc      = new CaractCargaBC();
                string        trai_id = this.Request.Params["trai_id"];
                ddl_idShortek.Enabled         = false;
                btn_limpiarDatos.Visible      = false;
                txt_solNumero.Text            = "";
                hf_localesSeleccionados.Value = sol.LOCALES;
                txt_totalPallets.Text         = "0";
                txt_ruta.Text = "Ways";
                ddl_idShortek.SelectedValue = "0";
                hf_timeStamp.Value          = DateTime.Now.ToString();
                volver.Visible           = false;
                volver2.Visible          = true;
                chk_solWays.Checked      = true;
                chk_solMultifrio.Enabled = false;
                chk_solCongelado.Enabled = false;
                chk_solSeco.Enabled      = false;
                chk_solFrio.Enabled      = false;
                dropsite.Enabled         = false;
                string    resultado = "";
                DataTable dsol      = sol.ObtenerAndenesXNewWays(trai_id, out resultado);

                ViewState["datosA"]      = dsol;
                gv_solLocales.DataSource = dsol;
                gv_solLocales.DataBind();
                stringCaractSolicitud();
                carga_playas();
                LugarBC lugar = new LugarBC();
                lugar = lugar.obtenerXID(Convert.ToInt32(dsol.Rows[0]["luga_id"].ToString()));
                ddl_solPlaya.SelectedValue = lugar.ID_PLAYA.ToString();  // dsol.Rows[0]["id_playa"].ToString() ;
                ddl_solPlaya_SelectedIndexChanged(null, null);
                trailer = trailer.obtenerXID(Convert.ToInt32(trai_id));
                txt_trailerPatente.Text = trailer.PLACA;
                calcula_solicitud(null, null);
                ddl_trailers.Enabled       = false;
                txt_trailerNro.Enabled     = false;
                txt_trailerPatente.Enabled = false;
                btn_buscarTrailer.Enabled  = false;
                btn_buscarTrailer_Click(null, null);
            }
        }
        visibleasignamovilmanual();
    }