protected void btnBuscarTrailer_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_placaTrailer.Text)) { utils.ShowMessage2(this, "buscarTrailer", "warn_placaVacia"); return; } if (!chk_vehiculoImportado.Checked && !utils.patentevalida(txt_placaTrailer.Text)) { utils.ShowMessage2(this, "buscarTrailer", "warn_placaInvalida"); return; } TrailerBC trailer = new TrailerBC(); trailer = trailer.obtenerXPlaca(txt_placaTrailer.Text); if (trailer.ID == 0) //Trailer nuevo, no existe { TractoBC tracto = new TractoBC(); if (txt_placaTrailer.Text != "") { tracto = tracto.ObtenerXPatente(txt_placaTrailer.Text); } if (tracto.ID > 0) { utils.ShowMessage2(this, "buscarTrailer", "warn_placaTracto"); } else { utils.AbrirModal(this, "modalConfirmar"); } this.chk_vehiculoImportado.Enabled = false; } else //Trailer existente, trae datos { hf_idTrailer.Value = trailer.ID.ToString(); txt_placaTrailer.Text = trailer.PLACA; ddl_transportista.SelectedValue = trailer.TRAN_ID.ToString(); rb_propio.Checked = !trailer.EXTERNO; rb_externo.Checked = trailer.EXTERNO; ddl_tipo_carga.Enabled = true; txt_placaTracto.Enabled = true; txt_idSello.Enabled = true; txt_conductorRut.Enabled = true; chk_conductorExtranjero.Enabled = true; txt_conductorNombre.Enabled = true; txt_acomRut.Enabled = true; txt_doc2.Enabled = true; chk_vehiculoImportado.Enabled = false; txt_selloReferencia.Enabled = chk_vehiculoImportado.Checked; txt_conductorRut_TextChanged(null, null); utils.ShowMessage2(this, "buscarTrailer", "success"); } }
private void ObtenerUltEstados(bool forzarBD) { if (this.ViewState["listar"] == null || forzarBD) { TrailerBC trailer = new TrailerBC(); if (!string.IsNullOrEmpty(this.txt_nroFlota.Text) || !string.IsNullOrEmpty(this.txt_placa.Text)) { if (!string.IsNullOrEmpty(this.txt_nroFlota.Text)) { trailer = trailer.obtenerXNro(this.txt_nroFlota.Text); } else if (utils.patentevalida(this.txt_placa.Text) == true) { trailer = trailer.obtenerXPlaca(this.txt_placa.Text); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Patente Invalida.');", true); return; } if (trailer.ID != 0) { ReportBC r = new ReportBC(); int site_id = Convert.ToInt32(this.ddl_site.SelectedValue); DateTime desde = Convert.ToDateTime(this.txt_desde.Text); DateTime hasta = Convert.ToDateTime(this.txt_hasta.Text); this.ViewState["listar"] = r.TrailerUltEstado(site_id, trailer.ID, desde, hasta); } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Debe seleccionar un trailer');", true); return; } } DataView dw = new DataView((DataTable)this.ViewState["listar"]); if (this.ViewState["sortExpresion"] != null && this.ViewState["sortExpresion"].ToString() != "") { dw.Sort = (String)this.ViewState["sortExpresion"]; } this.gv_listar.DataSource = dw; this.gv_listar.DataBind(); }
protected void btn_buscar_Click(object sender, EventArgs e) { TrailerBC trailer = new TrailerBC(); if (txt_nroViaje.Text != "") { trailer = trailer.obtenerXviaje(txt_nroViaje.Text); } else if (txt_NroFlota.Text != "") { trailer = trailer.obtenerXNro(txt_NroFlota.Text); } else if (utils.patentevalida(txt_Patente.Text) == true) { trailer = trailer.obtenerXPlaca(txt_Patente.Text); } else { btn_limpiar_Click(null, null); utils.ShowMessage2(this, "trailer", "warn_placaInvalida"); } if (trailer.ID == 0) { btn_limpiar_Click(null, null); utils.ShowMessage2(this, "trailer", "warn_noExiste"); return; } DataSet datos = trailer.obtenerDatosSalida(trailer.PLACA, trailer.NUMERO); if (datos.Tables.Count == 0) { btn_limpiar_Click(null, null); utils.ShowMessage2(this, "trailer", "warn_noExiste"); return; } DataTable dt = datos.Tables[0]; string site = dt.Rows[0]["SITE_ID"].ToString(); if (!Convert.ToBoolean(dt.Rows[0]["TRUE_SITE_IN"])) { utils.ShowMessage2(this, "trailer", "warn_fueraSite"); btn_limpiar_Click(null, null); return; } if (site != dropsite.SelectedValue || string.IsNullOrEmpty(site)) { utils.ShowMessage2(this, "trailer", "warn_otroSite"); btn_limpiar_Click(null, null); return; } hf_idTrailer.Value = dt.Rows[0]["TRAI_ID"].ToString(); hf_idTran.Value = dt.Rows[0]["TRAN_ID"].ToString(); hf_trueCodInterno.Value = dt.Rows[0]["TRUE_COD_INTERNO_IN"].ToString(); lblPlacaTrailer.Text = dt.Rows[0]["PLACA"].ToString(); lblFlotaTrailer.Text = dt.Rows[0]["FLOTA"].ToString(); lblFechaDatos.Text = dt.Rows[0]["FECHA_MODIFICACION"].ToString(); lblFechaDatos2.Text = dt.Rows[0]["FECHA_MODIFICACION"].ToString(); lblEstado.Text = dt.Rows[0]["TRAILER_ESTADO"].ToString(); lblTransportista.Text = dt.Rows[0]["TRANSPORTISTA"].ToString(); lblTipo.Text = dt.Rows[0]["TIPO_TRAILER"].ToString(); lblauditoria.Text = "En Construcción"; lblEstadoSol.Text = dt.Rows[0]["ESTADO_SOL"].ToString(); dv_contenido.Attributes.Add("style", "display:block"); lblUbicacion.Text = dt.Rows[0]["UBICACION"].ToString(); txt_obs.Text = dt.Rows[0]["TRUE_OBS"].ToString(); txt_patenteTracto.Text = dt.Rows[0]["PATENTE_TRACTO"].ToString(); if (!string.IsNullOrEmpty(dt.Rows[0]["COND_ID"].ToString())) { int cond_id = Convert.ToInt32(dt.Rows[0]["COND_ID"].ToString()); ConductorBC c = new ConductorBC(cond_id); txt_conductorRut.Text = utils.rutANumero(c.RUT); txt_conductorNombre.Text = c.NOMBRE; chk_conductorExtranjero.Checked = c.COND_EXTRANJERO; hf_idCond.Value = cond_id.ToString(); } string estado = dt.Rows[0]["TRES_ID"].ToString().ToLower(); estado_yms.Value = ""; if (site == "10") { try { DataTable dt3 = datos.Tables[4]; if (dt3.Rows[0]["Cargado"].ToString() == "NO" && txt_nroViaje.Text == "") { lblEstado.Text = "VACIO"; estado = "100"; estado_yms.Value = "1"; } else { lblEstado.Text = "CARGADO"; estado = "400"; estado_yms.Value = "0"; } } catch (Exception ex) { estado = dt.Rows[0]["TRES_ID"].ToString().ToLower(); } } locales_YMS.Value = ""; if (estado == "400") { ObtenerLocales(); } else { gilllocal.DataSource = null; gilllocal.DataBind(); dv_locales.Visible = false; dv_destino.Visible = true; } try { DataTable dtviaje = datos.Tables[2]; Gridviajes.DataSource = dtviaje; Gridviajes.DataBind(); } catch (Exception) { } try { DataTable dttracto = datos.Tables[3]; txt_gpsActivoTracto.Text = dttracto.Rows[0]["STATUS"].ToString(); lbl_tran.Text = dttracto.Rows[0]["TRANSPORTE"].ToString(); } catch (Exception ex) { } try { DataTable dttrailerGPS = datos.Tables[1]; lblTemperatura.Text = dttrailerGPS.Rows[0]["TEMPERATURA"].ToString(); lblGPS.Text = dttrailerGPS.Rows[0]["STATUS"].ToString(); lblauditoria.Text = dttrailerGPS.Rows[0]["AU"].ToString(); lblFechaDatos2.Text = dttrailerGPS.Rows[0]["fh_dato"].ToString(); } catch (Exception) { } }
protected void btnBuscarTrailer_Click(object sender, EventArgs e) { TrailerBC trailer = new TrailerBC(); if (this.txt_buscarNro.Text != "" || this.txt_placaTrailer.Text != "") { if (this.txt_buscarNro.Text != "") { trailer = trailer.obtenerXNro(txt_buscarNro.Text); } else if (utils.patentevalida(txt_placaTrailer.Text) == true) { trailer = trailer.obtenerXPlaca(txt_placaTrailer.Text); } else { this.hf_idTrailer.Value = "0"; this.ddl_transportista.ClearSelection(); this.txt_conductorRut.Text = ""; this.txt_conductorNombre.Text = ""; this.txt_acomRut.Text = ""; this.txt_buscarNro.Text = ""; this.ddl_proveedor.ClearSelection(); this.rb_externo.Checked = false; this.rb_propio.Checked = false; this.ddl_transportista.Enabled = true; this.txt_conductorRut.Enabled = true; this.txt_conductorNombre.Enabled = true; this.txt_acomRut.Enabled = true; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Patente Invalida.');", true); } if (trailer.ID == 0 || trailer.ID == null) //Trailer nuevo, no existe { this.hf_idTrailer.Value = "0"; this.ddl_transportista.ClearSelection(); this.txt_conductorRut.Text = ""; this.txt_conductorNombre.Text = ""; this.txt_acomRut.Text = ""; this.txt_buscarNro.Text = ""; this.ddl_proveedor.ClearSelection(); this.rb_externo.Checked = false; this.rb_propio.Checked = false; this.ddl_transportista.Enabled = true; this.txt_conductorRut.Enabled = true; this.txt_conductorNombre.Enabled = true; this.txt_acomRut.Enabled = true; TractoBC tracto = new TractoBC(); if (txt_placaTrailer.Text != "") { tracto = tracto.ObtenerXPatente(txt_placaTrailer.Text); } if (tracto.ID > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Placa Corresponde a tracto');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer no existe en la base de datos. Debe Crearlo.');", true); } } else //Trailer existente, trae datos { if (trailer.SITE_IN) { if (trailer.SITE_ID == Convert.ToInt32(this.dropsite.SelectedValue)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer ya registrado en el CD. No es posible reingresar');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer registrado en otro CD. No es posible reingresar');", true); } this.txt_placaTracto.Enabled = false; this.ddl_transportista.Enabled = false; this.txt_conductorRut.Enabled = false; this.txt_conductorNombre.Enabled = false; this.txt_acomRut.Enabled = false; } else { this.hf_idTrailer.Value = trailer.ID.ToString(); this.txt_placaTrailer.Text = trailer.PLACA; this.txt_buscarNro.Text = trailer.NUMERO; this.ddl_transportista.SelectedValue = trailer.TRAN_ID.ToString(); if (trailer.EXTERNO) { this.rb_propio.Checked = false; this.rb_externo.Checked = true; } else { this.rb_propio.Checked = true; this.rb_externo.Checked = false; } this.txt_placaTracto.Enabled = false; this.ddl_transportista.Enabled = false; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Se cargaron los datos del trailer seleccionado.');", true); if (this.rb_ingresoCargado.Checked) { this.txt_placaTracto.Enabled = true; this.ddl_proveedor.Enabled = true; this.txt_doc.Enabled = true; this.txt_idSello.Enabled = true; } else { this.txt_placaTracto.Enabled = false; this.ddl_proveedor.Enabled = false; this.txt_doc.Enabled = false; this.txt_idSello.Enabled = false; } this.txt_conductorRut.Enabled = true; this.txt_conductorNombre.Enabled = true; this.txt_acomRut.Enabled = true; } txt_conductorRut_TextChanged(null, null); } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Debe ingresar un numero de flota o patente');", true); this.hf_idTrailer.Value = ""; } }
protected void btn_confirmar_Click(object sender, EventArgs e) { try { ConductorBC c = new ConductorBC(); MovimientoBC mov = new MovimientoBC(); TrailerUltEstadoBC trailerUE = new TrailerUltEstadoBC(); TrailerBC trailer = new TrailerBC(); if (string.IsNullOrEmpty(hf_idCond.Value)) { c.RUT = utils.formatearRut(txt_conductorRut.Text); c.NOMBRE = txt_conductorNombre.Text; c.TRAN_ID = Convert.ToInt32(ddl_transportista.SelectedValue); c.COND_EXTRANJERO = chk_conductorExtranjero.Checked; hf_idCond.Value = c.AgregarIdentity().ToString(); } mov.FECHA_CREACION = DateTime.Now; mov.ID_ESTADO = 10; mov.OBSERVACION = txt_obs.Text; mov.FECHA_ORIGEN = Convert.ToDateTime(string.Format("{0} {1}", txt_ingresoFecha.Text, txt_ingresoHora.Text)); mov.ID_DESTINO = Convert.ToInt32(ddl_posicion.SelectedValue); mov.FECHA_DESTINO = mov.FECHA_ORIGEN.AddMinutes(30); if (utils.patentevalida(txt_traExtPat.Text) == true) { mov.PATENTE_TRACTO = txt_traExtPat.Text; if (rb_mantExterno.Checked) { mov.MANT_EXTERNO = true; } else { trailerUE.COND_ID = Convert.ToInt32(hf_idCond.Value); mov.MANT_EXTERNO = false; mov.ID_TRAILER = Convert.ToInt32(hf_idTrailer.Value); trailer.ID = Convert.ToInt32(hf_idTrailer.Value); trailer.PLACA = txt_buscarPatente.Text; trailer.CODIGO = string.Format("{0}_{1}", ddl_transportista.SelectedItem.Text, txt_buscarPatente.Text); trailer.EXTERNO = (rb_externo.Checked || rb_proveedor.Checked || rb_mantExterno.Checked); trailer.TRAN_ID = Convert.ToInt32(ddl_transportista.SelectedValue); trailerUE.SITE_ID = Convert.ToInt32(dropsite.SelectedValue); // 1; // Cambiar después de introducir variables de sesión trailerUE.CHOFER_RUT = utils.formatearRut(txt_conductorRut.Text); trailerUE.CHOFER_NOMBRE = txt_conductorNombre.Text; trailerUE.ACOMP_RUT = txt_acomRut.Text; trailerUE.PROV_ID = Convert.ToInt32(ddl_proveedor.SelectedValue); trailerUE.DOC_INGRESO = txt_buscarDoc.Text; trailerUE.SELLO_INGRESO = txt_idSello.Text; trailerUE.TIPO_INGRESO_CARGA = ddl_tipo_carga.SelectedValue; trailerUE.motivo_TIPO_INGRESO_CARGA = ddl_motivo.SelectedValue; trailerUE.pring_id = hf_pring_id.Value.ToString(); // p.CargarPreEntrada( //p.CargarPreEntrada(mov.ID_TRAILER, Convert.ToInt32(dropsite.SelectedValue)).ID.ToString(); trailerUE.CARGADO = rb_ingresoCargado.Checked; } UsuarioBC usuario = (UsuarioBC)this.Session["USUARIO"]; if (trailer.ID == 0) { utils.ShowMessage(this, "Debe ingresar Trailer", "warn", true); limpiarTodo(); } else { string resultado; bool ejecucion = mov.ProcesoEntrada(mov, trailerUE, trailer, usuario.ID, out resultado); if (ejecucion && resultado == "") { utils.ShowMessage(this, "Ingreso correcto", "success", true); limpiarTodo(); } else { utils.ShowMessage(this, resultado, "error", false); } } } else { utils.ShowMessage(this, "Patente de Tracto Invalida", "warn", false); } } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } }
protected void btn_buscarTrailer_Click(object sender, EventArgs e) { TrailerBC trailer = new TrailerBC(); if (this.txt_buscarNro.Text != "" || this.txt_buscarPatente.Text != "") { if (this.txt_buscarNro.Text != "") { trailer = trailer.obtenerXNro(txt_buscarNro.Text); } else if (utils.patentevalida(txt_buscarPatente.Text)) { trailer = trailer.obtenerXPlaca(txt_buscarPatente.Text); } else { limpiar(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Patente Invalida.');", true); } SolicitudBC soli = new SolicitudBC(); if (trailer.SOLI_ID != 0 && trailer.SOLI_ID != null) { soli = soli.ObtenerXId(trailer.SOLI_ID); } if (trailer.ID == 0 || trailer.ID == null) //Trailer no existe { limpiar(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer no existe en la base de datos.');", true); } else //Trailer existente, trae datos { if (trailer.SITE_ID == null || trailer.SITE_ID == 0 || !trailer.SITE_IN) { limpiar(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer en ruta.');", true); } else if (trailer.SITE_ID != int.Parse(this.dropsite.SelectedValue)) { limpiar(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer no se encuentra en el site.');", true); } else if (trailer.SOLI_ID != null && trailer.SOLI_ID != 0 && soli.SOES_ID != 150) { limpiar(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer tiene solicitud pendiente.');", true); } else if (trailer.MOVI_ID != null && trailer.MOVI_ID != 0) { limpiar(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer tiene movimiento pendiente.');", true); } else if (trailer.BLOQUEADO == "True") { limpiar(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Trailer bloqueado.');", true); } else { drop_SelectedIndexChanged(null, null); this.hf_idTrailer.Value = trailer.ID.ToString(); dibujo(trailer.LUGAR_ID); this.txt_buscarPatente.Text = trailer.PLACA; this.txt_buscarNro.Text = trailer.NUMERO; this.ddl_transportista.SelectedValue = trailer.TRAN_ID.ToString(); if (trailer.EXTERNO) { this.rb_trailerPropio.Checked = false; this.rb_trailerExterno.Checked = true; } else { this.rb_trailerPropio.Checked = true; this.rb_trailerExterno.Checked = false; } this.ddl_destinoZona.Enabled = true; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Se cargaron los datos del trailer seleccionado.');", true); petroleo_checked(null, null); } } } else { limpiar(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Debe ingresar un numero de flota o patente');", true); ddl_destinoZona.Enabled = false; this.hf_idTrailer.Value = ""; } }
protected void btnBuscarTrailer_Click(object sender, EventArgs e) { TrailerBC trailer = new TrailerBC(); trailer = trailer.obtenerXPlaca(this.txt_placaTrailer.Text); if (utils.patentevalida(this.txt_placaTrailer.Text) == false) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Patente Invalida.');", true); } else if (trailer.ID == 0 || trailer.ID == null) //Trailer nuevo, no existe { TractoBC tracto = new TractoBC(); if (this.txt_placaTrailer.Text != "") { tracto = tracto.ObtenerXPatente(this.txt_placaTrailer.Text); } if (tracto.ID > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Placa Corresponde a tracto');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "modal", "modalConfirmar();", true); } //this.hf_idTrailer.Value = "0"; //this.ddl_transportista.ClearSelection(); //this.txt_conductorRut.Text = ""; //this.txt_conductorNombre.Text = ""; //this.txt_acomRut.Text = ""; //this.ddl_proveedor.ClearSelection(); //this.rb_externo.Checked = false; //this.rb_propio.Checked = false; //this.ddl_transportista.Enabled = true; //this.txt_conductorRut.Enabled = true; //this.txt_conductorNombre.Enabled = true; //this.txt_acomRut.Enabled = true; } else //Trailer existente, trae datos { hf_idTrailer.Value = trailer.ID.ToString(); txt_placaTrailer.Text = trailer.PLACA; ddl_transportista.SelectedValue = trailer.TRAN_ID.ToString(); if (trailer.EXTERNO) { rb_propio.Checked = false; rb_externo.Checked = true; } else { rb_propio.Checked = true; rb_externo.Checked = false; } ddl_tipo_carga.Enabled = true; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "showAlert('Se cargaron los datos del trailer seleccionado.');", true); txt_placaTracto.Enabled = true; // this.ddl_proveedor.Enabled = true; // this.txt_doc.Enabled = true; txt_idSello.Enabled = true; txt_conductorRut.Enabled = true; chk_conductorExtranjero.Enabled = true; txt_conductorNombre.Enabled = true; txt_acomRut.Enabled = true; txt_doc2.Enabled = true; txt_conductorRut_TextChanged(null, null); } }