Ejemplo n.º 1
0
    protected void btn_confirmar_Click(object sender, EventArgs e)
    {
        TrailerUltSalidaLABC tu = new TrailerUltSalidaLABC();
        string    resultado;
        TrailerBC t = new TrailerBC();

        tu.ID             = Convert.ToInt32(hf_idTrailer.Value);
        tu.PATENTE_TRACTO = txt_patenteTracto.Text;
        tu.CHOFER_RUT     = utils.formatearRut(txt_conductorRut.Text);
        tu.CHOFER_NOMBRE  = txt_conductorNombre.Text;
        tu.SITE_ID        = Convert.ToInt32(ddl_destino.SelectedValue);
        if (ddl_tipoDestino.SelectedValue == "DLPR")
        {
            tu.LOCA_ID = Convert.ToInt32(ddl_destino.SelectedValue);
        }
        else
        {
            tu.DEST_ID = Convert.ToInt32(ddl_destino.SelectedValue);
        }

        tu.COND_ID             = Convert.ToInt32(hf_idCond.Value);
        tu.CHOFER_RUT          = txt_conductorRut.Text;
        tu.CHOFER_NOMBRE       = txt_conductorNombre.Text;
        tu.ESTADO_YMS          = estado_yms.Value;
        tu.OBSERVACION         = locales_YMS.Value.ToString();
        tu.SELLO_CARGA         = txt_sello.Text;
        tu.MMPP                = txt_mmpp.Text;
        tu.GUIA                = txt_gdNro.Text;
        tu.TRUE_COD_INTERNO_IN = Convert.ToInt64(hf_trueCodInterno.Value);
        if (!string.IsNullOrEmpty(txt_cajas.Text))
        {
            tu.CAJAS = Convert.ToInt32(txt_cajas.Text);
        }
        if (!string.IsNullOrEmpty(txt_liAzules.Text))
        {
            tu.PALLET_AZUL = Convert.ToInt32(txt_liAzules.Text);
        }
        if (!string.IsNullOrEmpty(txt_liRojos.Text))
        {
            tu.PALLET_ROJO = Convert.ToInt32(txt_liRojos.Text);
        }
        if (!string.IsNullOrEmpty(txt_liBlancos.Text))
        {
            tu.PALLET_BLANCO = Convert.ToInt32(txt_liBlancos.Text);
        }
        if (!string.IsNullOrEmpty(txt_liLeña.Text))
        {
            tu.LEÑA = Convert.ToInt32(txt_liLeña.Text);
        }

        tu.VIAJE = txt_nroViaje.Text;

        bool ejecucion = tu.ProcesoSalida(tu, LlenarTableLocales(), locales_YMS.Value, usuario.ID, out resultado);

        if (ejecucion && resultado == "")
        {
            btn_limpiar_Click(null, null);
            utils.ShowMessage2(this, "confirmar", "success");
        }
        else
        {
            utils.ShowMessage(this, resultado, "error", false);
        }
    }
Ejemplo n.º 2
0
    protected void btnBuscarTrailer_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(txt_buscarPatente.Text))
        {
            TrailerBC trailer = new TrailerBC().obtenerXPlaca(txt_buscarPatente.Text);

            if (trailer.ID == 0) //Trailer nuevo, no existe
            {
                if (new TractoBC().ObtenerXPatente(txt_buscarPatente.Text).ID > 0)
                {
                    utils.ShowMessage2(this, "trailer", "warn_tracto"); return;
                }
                utils.ShowMessage2(this, "trailer", "warn_noExiste");
                limpiarTodo();
            }
            else //Trailer existente, trae datos
            {
                PreEntradaBC       p    = new PreEntradaBC();
                TrailerUltSalidaBC tusa = new TrailerUltSalidaBC();
                YMS_ZONA_BC        yms  = new YMS_ZONA_BC();
                utils.CargaDrop(this.ddl_tipo_carga, "ID", "DESCRIPCION", yms.obtenerTipoCarga(null, false, true));
                hf_idTrailer.Value              = trailer.ID.ToString();
                txt_buscarPatente.Text          = trailer.PLACA;
                ddl_transportista.SelectedValue = trailer.TRAN_ID.ToString();
                rb_propio.Checked               = !trailer.EXTERNO;
                rb_externo.Checked              = trailer.EXTERNO;
                txt_tracto.Enabled              = false;
                ddl_transportista.Enabled       = false;
                txt_tracto.Enabled              = rb_ingresoCargado.Checked;
                ddl_proveedor.Enabled           = rb_ingresoCargado.Checked;
                txt_doc.Enabled                 = rb_ingresoCargado.Checked;
                txt_idSello.Enabled             = rb_ingresoCargado.Checked;
                txt_conductorRut.Enabled        = true;
                txt_conductorNombre.Enabled     = true;
                chk_conductorExtranjero.Enabled = true;
                txt_acomRut.Enabled             = true;
                utils.ShowMessage2(this, "trailer", "success");
                p = p.CargarPreEntrada(trailer.ID, Convert.ToInt32(this.dropsite.SelectedValue));
                if (p.ID != 0)
                {
                    if (p.COND_ID != 0)
                    {
                        ConductorBC c = new ConductorBC(p.COND_ID);
                        hf_idCond.Value = c.ID.ToString();
                        chk_conductorExtranjero.Checked = c.COND_EXTRANJERO;
                        txt_conductorRut.Text           = (!c.COND_EXTRANJERO) ? utils.formatearRut(c.RUT) : c.RUT;
                        txt_conductorNombre.Text        = c.NOMBRE;
                        txt_conductorNombre.Enabled     = false;
                    }
                    txt_doc.Text                = p.DOC_INGRESO;
                    txt_tracto.Text             = p.PATENTE_TRACTO;
                    txt_acomRut.Text            = p.RUT_ACOMP;
                    ddl_proveedor.SelectedValue = p.PROV_ID.ToString();
                    txt_obs.Text                = p.Observacion;
                    if (!string.IsNullOrEmpty(p.SELLO_INGRESO))
                    {
                        txt_idSello.Text = p.SELLO_INGRESO;
                    }
                    if (!string.IsNullOrEmpty(p.SELLO_CARGA))
                    {
                        txt_idSello.Text = p.SELLO_CARGA;
                    }
                    rb_ingresoCargado.Checked = true;
                    rb_ingresoVacio.Checked   = false;
                    chk_ingresoCargado_CheckedChanged(null, null);
                    ddl_tipo_carga.SelectedValue = p.TIIC_ID.ToString();
                    tipo_carga_SelectedIndexChanged(null, null);
                    ddl_motivo.SelectedValue = p.MOIC_ID.ToString();
                    txt_doc.Enabled          = false;
                }
                else
                {
                    tusa = tusa.ObtenerXId(trailer.ID);
                    if (tusa.TRAI_ID != 0)
                    {
                        if (tusa.COND_ID != 0)
                        {
                            ConductorBC c = new ConductorBC(tusa.COND_ID);
                            hf_idCond.Value          = c.ID.ToString();
                            txt_conductorRut.Text    = c.RUT;
                            txt_conductorNombre.Text = c.NOMBRE;
                        }
                        txt_tracto.Text             = tusa.PATENTE_TRACTO;
                        txt_acomRut.Text            = tusa.ACOMP_RUT;
                        ddl_proveedor.SelectedValue = tusa.PROV_ID.ToString();
                        if (!string.IsNullOrEmpty(tusa.SELLO_INGRESO))
                        {
                            txt_idSello.Text = tusa.SELLO_INGRESO;
                        }
                        if (!string.IsNullOrEmpty(tusa.SELLO_CARGA))
                        {
                            txt_idSello.Text = tusa.SELLO_CARGA;
                        }

                        rb_ingresoCargado.Checked = true;
                        rb_ingresoVacio.Checked   = false;

                        chk_ingresoCargado_CheckedChanged(null, null);
                        ddl_tipo_carga.SelectedValue = tusa.TIIC_ID.ToString();
                        tipo_carga_SelectedIndexChanged(null, null);
                        ddl_motivo.SelectedValue = tusa.MOIC_ID.ToString();
                    }
                }
            }
            rb_posAuto.Checked   = false;
            rb_posManual.Checked = false;
            ddl_zona.Enabled     = true;
            if (txt_conductorRut.Text != "")
            {
                txt_conductorRut_TextChanged(null, null);
            }
        }
    }
Ejemplo n.º 3
0
    protected void btnBuscarTrailer_Click(object sender, EventArgs e)
    {
        TrailerBC trailer = new TrailerBC();

        ddl_playa.Enabled    = false;
        ddl_zona.Enabled     = false;
        ddl_posicion.Enabled = false;

        if (!string.IsNullOrEmpty(this.txt_buscarDoc.Text))
        {
            trailer = trailer.obtenerXDoc(this.txt_buscarDoc.Text, this.dropsite.SelectedValue);
            if (trailer.ID == 0) //Trailer nuevo, no existe
            {
                limpiarTodo();
                utils.ShowMessage2(this, "cita", "warn_noExiste");
            }
            else //Trailer existente, trae datos
            {
                ddl_zona.Enabled                = true;
                hf_idTrailer.Value              = trailer.ID.ToString();
                hf_pring_id.Value               = trailer.PRING_ID.ToString();
                txt_buscarPatente.Text          = trailer.PLACA;
                ddl_transportista.SelectedValue = trailer.TRAN_ID.ToString();
                rb_propio.Checked               = !trailer.EXTERNO;
                rb_externo.Checked              = trailer.EXTERNO;
                txt_traExtPat.Enabled           = false;
                txt_traExtPat.Enabled           = rb_ingresoCargado.Checked;
                txt_idSello.Enabled             = rb_ingresoCargado.Checked;
                ddl_transportista.Enabled       = false;
                txt_conductorRut.Enabled        = true;
                txt_conductorNombre.Enabled     = true;
                chk_conductorExtranjero.Enabled = true;
                txt_acomRut.Enabled             = true;
                utils.ShowMessage2(this, "cita", "success");
                //      }
                PreEntradaBC p = new PreEntradaBC();
                p = p.CargarPreEntrada(trailer.ID, Convert.ToInt32(dropsite.SelectedValue), txt_buscarDoc.Text);
                if (p.ID != 0)
                {
                    if (p.COND_ID != 0)
                    {
                        ConductorBC c = new ConductorBC();
                        c = c.ObtenerXId(p.COND_ID);
                        hf_idCond.Value          = c.ID.ToString();
                        txt_conductorRut.Text    = utils.formatearRut(c.RUT);
                        txt_conductorNombre.Text = c.NOMBRE;
                    }
                    hf_pring_id.Value           = p.ID.ToString();
                    txt_traExtPat.Text          = p.PATENTE_TRACTO;
                    txt_acomRut.Text            = p.RUT_ACOMP;
                    ddl_proveedor.SelectedValue = p.PROV_ID.ToString();
                    hf_idTrailer.Value          = p.TRAI_ID.ToString();
                    DateTime fechaHora = DateTime.Parse(string.Format("{0} {1}", this.txt_ingresoFecha.Text, this.txt_ingresoHora.Text));
                    if (fechaHora > p.FECHA_HORA.AddHours(2) || fechaHora < p.FECHA_HORA.AddHours(-2))
                    {
                        utils.ShowMessage2(this, "cita", "warn_fhDiferente");
                    }
                    if (!string.IsNullOrEmpty(p.SELLO_INGRESO))
                    {
                        txt_idSello.Text = p.SELLO_INGRESO;
                    }
                    if (!string.IsNullOrEmpty(p.SELLO_CARGA))
                    {
                        txt_idSello.Text = p.SELLO_CARGA;
                    }
                    rb_ingresoCargado.Checked = p.CARGADO;
                    rb_ingresoVacio.Checked   = !p.CARGADO;
                    txt_obs.Text = p.Observacion;
                    chk_ingresoCargado_CheckedChanged(null, null);

                    ddl_tipo_carga.SelectedValue = p.TIIC_ID.ToString();
                    tipo_carga_SelectedIndexChanged(null, null);
                    ddl_motivo.SelectedValue = p.MOIC_ID.ToString();
                    //  }
                }
                else
                {
                    utils.ShowMessage2(this, "cita", "warn_expirado");
                    limpiarTodo();
                }
            }
            rb_posAuto.Checked   = false;
            rb_posManual.Checked = false;
            ddl_zona.Enabled     = false;
            if (txt_conductorRut.Text != "")
            {
                txt_conductorRut_TextChanged(null, null);
            }
        }
        else
        {
            utils.ShowMessage2(this, "cita", "warn_nroVacio");
            ddl_zona.Enabled   = false;
            hf_idTrailer.Value = "";
            hf_pring_id.Value  = "";
        }
    }
Ejemplo n.º 4
0
    protected void btn_confirmar_Click(object sender, EventArgs e)
    {
        DataTable table = (DataTable)this.ViewState["table"];

        try
        {
            if (this.hf_idTrailer.Value == "")
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje2", "alert('Debe ingresar Trailer');", true);
                this.limpiarTodo();
            }
            else
            {
                PreEntradaBC p = new PreEntradaBC();
                if (this.hf_idCond.Value == "")
                {
                    ConductorBC c = new ConductorBC();
                    c.RUT             = txt_conductorRut.Text;
                    c.NOMBRE          = this.txt_conductorNombre.Text;
                    c.TRAN_ID         = Convert.ToInt32(this.ddl_transportista.SelectedValue);
                    c.COND_EXTRANJERO = chk_conductorExtranjero.Checked;
                    hf_idCond.Value   = c.AgregarIdentity().ToString();
                }
                else
                {
                    p.COND_ID = Convert.ToInt32(this.hf_idCond.Value);
                }
                p.SITE_ID       = Convert.ToInt32(this.dropsite.SelectedValue);
                p.TRAI_ID       = Convert.ToInt32(this.hf_idTrailer.Value);
                p.FECHA         = DateTime.Parse(string.Format("{0} {1}", this.txt_ingresoFecha.Text, this.txt_ingresoHora.Text));
                p.ESTADO        = 1;
                p.DOC_INGRESO   = this.txt_buscarDoc.Text;
                p.RUT_CHOFER    = utils.formatearRut(this.txt_conductorRut.Text);
                p.Observacion   = this.txt_obs.Text;
                p.NOMBRE_CHOFER = this.txt_conductorNombre.Text;
                p.RUT_ACOMP     = this.txt_acomRut.Text;
                if (this.rb_ingresoVacio.Checked)
                {
                    p.SELLO_INGRESO = this.txt_idSello.Text;
                    p.CARGADO       = false;
                }
                if (this.rb_ingresoCargado.Checked)
                {
                    p.PROV_ID        = Convert.ToInt32(this.ddl_proveedor.SelectedValue);
                    p.TIIC_ID        = Convert.ToInt32(this.ddl_tipo_carga.SelectedValue);
                    p.MOIC_ID        = Convert.ToInt32(this.ddl_motivo.SelectedValue);
                    p.SELLO_CARGA    = this.txt_idSello.Text;
                    p.PATENTE_TRACTO = this.txt_placaTracto.Text;
                    p.CARGADO        = true;
                }

                DataTable citas = table.Clone();
                foreach (DataRow drtableOld in table.Rows)
                {
                    citas.ImportRow(drtableOld);
                }

                citas.Columns.RemoveAt(5);
                citas.Columns.RemoveAt(3);
                citas.Columns.RemoveAt(1);

                citas.Columns[0].ColumnName = "tipo_carga";
                citas.Columns[1].ColumnName = "motivo_carga";
                citas.Columns[2].ColumnName = "numero_cita";

                p.citas = citas;

                string error = "";

                int       id;
                TrailerBC trailer_tracto = new TrailerBC();

                if (this.txt_placaTracto.Text != "")
                {
                    trailer_tracto = trailer_tracto.obtenerXPlaca(this.txt_placaTracto.Text);
                }

                if (utils.patentevalida(this.txt_placaTracto.Text) == false)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('patente de Tracto Invalida');"), true);
                }
                else if (trailer_tracto.ID > 0 && trailer_tracto.ID != p.TRAI_ID)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('Tracto corresponde a trailer');"), true);
                }
                else if (p.Crear(p, out id, out error) && error == "")
                {
                    if (id != 0)
                    {
                        this.hf_id.Value = id.ToString();
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Preingreso correcto.');", true);
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "generarPDF", "generaPDF();", true);
                        this.CreaDataTable();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('{0}');", error), true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('{0}');", error), true);
                }
            }
        }
        catch (Exception)
        {
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Error! No se pudo ingresar los datos.');", true);
        }
    }