protected void btn_confirmar_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txt_placaTracto.Text) && txt_placaTracto.Text.ToUpper() != txt_placaTrailer.Text.ToUpper()) { TrailerBC t = new TrailerBC(); t = t.obtenerXPlaca(this.txt_placaTracto.Text); if (t.ID > 0) { utils.ShowMessage2(this, "tracto", "warn_placaTrailer"); return; } } try { PreEntradaBC p = new PreEntradaBC(); ConductorBC c = new ConductorBC().ObtenerXRut(txt_conductorRut.Text); if (c.ID == 0) { c.RUT = txt_conductorRut.Text; c.NOMBRE = txt_conductorNombre.Text; c.TRAN_ID = Convert.ToInt32(ddl_transportista.SelectedValue); c.COND_EXTRANJERO = chk_conductorExtranjero.Checked; c.ID = c.AgregarIdentity(); } p.COND_ID = c.ID; p.RUT_CHOFER = c.RUT; p.NOMBRE_CHOFER = c.NOMBRE; p.SITE_ID = Convert.ToInt32(dropsite.SelectedValue); p.TRAI_ID = Convert.ToInt32(hf_idTrailer.Value); p.FECHA = DateTime.Parse(txt_ingresoFecha.Text + " " + txt_ingresoHora.Text); p.ESTADO = 1; p.DOC_INGRESO = txt_buscarDoc.Text; p.Observacion = txt_obs.Text; p.RUT_ACOMP = txt_acomRut.Text; p.extranjero = chk_vehiculoImportado.Checked; p.SELLO_INGRESO = txt_selloReferencia.Text; p.PRING_FONO = txt_ingresoFono.Text; if (rb_ingresoVacio.Checked) { p.CARGADO = false; } if (rb_ingresoCargado.Checked) { p.PROV_ID = Convert.ToInt32(ddl_proveedor.SelectedValue); p.TIIC_ID = Convert.ToInt32(ddl_tipo_carga.SelectedValue); p.MOIC_ID = Convert.ToInt32(ddl_motivo.SelectedValue); p.SELLO_CARGA = txt_idSello.Text; p.PATENTE_TRACTO = txt_placaTracto.Text; p.CARGADO = true; } DataTable table = (DataTable)(ViewState["listar"]); DataTable citas = table.Clone(); foreach (DataRow drtableOld in table.Rows) { citas.ImportRow(drtableOld); } p.citas = citas; string error = ""; int id; if (p.Crear(p, out id, out error) && error == "") { hf_id.Value = id.ToString(); utils.ShowMessage2(this, "confirmar", "success"); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "generarPDF", "generaPDF();", true); CreaDataTable(); } else { utils.ShowMessage(this, error, "error", false); } } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } }
protected void btn_confirmar_Click(object sender, EventArgs e) { try { if (this.hf_idTrailer.Value == "") { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje2", "alert('Debe ingresar Trailer');", true); limpiarTodo(); } else { ConductorBC c = new ConductorBC(); 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(); } PreEntradaBC p = new PreEntradaBC(); p.SITE_ID = Convert.ToInt32(dropsite.SelectedValue); p.TRAI_ID = Convert.ToInt32(hf_idTrailer.Value); p.FECHA = DateTime.Parse(txt_ingresoFecha.Text + " " + txt_ingresoHora.Text); p.ESTADO = 1; p.DOC_INGRESO = ""; p.RUT_CHOFER = utils.formatearRut(txt_conductorRut.Text); p.NOMBRE_CHOFER = txt_conductorNombre.Text; p.RUT_ACOMP = txt_acomRut.Text; p.COND_ID = Convert.ToInt32(hf_idCond.Value); if (rb_ingresoVacio.Checked) { p.SELLO_INGRESO = txt_idSello.Text; p.CARGADO = false; } if (utils.patentevalida(this.txt_placaTracto.Text) == true) { TrailerBC trailer_tracto = new TrailerBC(); trailer_tracto = trailer_tracto.obtenerXPlaca(this.txt_placaTracto.Text); if (trailer_tracto.ID > 0 && trailer_tracto.ID != p.TRAI_ID) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Tracto corresponde a trailer');", true); } else { if (rb_ingresoCargado.Checked) { p.PROV_ID = Convert.ToInt32(ddl_proveedor.SelectedValue); p.TIIC_ID = Convert.ToInt32(ddl_tipo_carga.SelectedValue); p.MOIC_ID = Convert.ToInt32(ddl_motivo.SelectedValue); p.SELLO_CARGA = txt_idSello.Text; p.PATENTE_TRACTO = txt_placaTracto.Text; p.CARGADO = true; } int id; string error; if (p.Crear(p, out id, out error)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Ingreso correcto.');", true); limpiarTodo(); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('{0}');", error), true); } } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('" + "patente de Tracto Invalida" + "');", true); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "alert('Error! No se pudo ingresar los datos.');", true); } }
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); } }