protected void btn_rutaNuevo_Click(object sender, EventArgs e) { try { PreRutaBC pre_ruta = new PreRutaBC(); pre_ruta.HORARIO.HORA_ID = Convert.ToInt32(ddl_buscarHorario.SelectedValue); pre_ruta.FECHA_DESPACHOEXP = Convert.ToDateTime(txt_buscarFecha.Text); List <OrigenBC> arrOrigen = new OrigenBC().ObtenerArray(); pre_ruta.ORIGEN = arrOrigen[0]; pre_ruta.FH_CREACION = DateTime.Now; var random = new Random(); var color = String.Format("#{0:X6}", random.Next(0x1000000)); pre_ruta.RUTA_COLOR = color; pre_ruta.Guardar(); hf_idRuta.Value = pre_ruta.ID.ToString(); //hf_jsonRuta.Value = JsonConvert.SerializeObject(pre_ruta.ObtenerXId(pre_ruta.ID)); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "nuevaruta", string.Format("nuevaRuta('{0}');", JsonConvert.SerializeObject(pre_ruta.ObtenerXId(pre_ruta.ID))), true); var debug = ""; } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } }
public string NuevaRuta(int hora_id, string fecha_despacho) { try { PreRutaBC pre_ruta = new PreRutaBC(); pre_ruta.HORARIO.HORA_ID = hora_id; pre_ruta.FECHA_DESPACHOEXP = Convert.ToDateTime(fecha_despacho); List <OrigenBC> arrOrigen = new OrigenBC().ObtenerArray(); pre_ruta.ORIGEN = arrOrigen[0]; pre_ruta.FH_CREACION = DateTime.Now; var random = new Random(); var color = String.Format("#{0:X6}", random.Next(0x1000000)); pre_ruta.RUTA_COLOR = color; pre_ruta.Guardar(); pre_ruta = pre_ruta.ObtenerXId(); //hf_jsonRuta.Value = JsonConvert.SerializeObject(pre_ruta.ObtenerXId(pre_ruta.ID)); var debug = ""; return(JsonConvert.SerializeObject(pre_ruta)); } catch (Exception ex) { Context.Response.StatusDescription = ex.Message; return(null); } }
protected void btn_eliminar_todos_click(object sender, EventArgs e) { PreRutaBC gd = new PreRutaBC(); String mimeType = ""; try { // DataTable excel = gd.CrearEnvio(hseleccionado.Value.ToString(), user.USUA_ID, chk_archivar.Checked); // ViewState["lista"] = excel; // ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "exp", "exportar();", true); if (hseleccionado.Value == "") { utils.ShowMessage(this, "Seleccione al menos un viaje", "error", false); return; } hf_idRuta.Value = ""; lbl_confTitulo.Text = "Eliminar Multiple Propuesta"; lbl_confMensaje.Text = "Se eliminará la propuesta de ruta seleccionada ¿Desea continuar?"; btn_confEliminar.Visible = false; btn_confEliminarTodos.Visible = true; utils.AbrirModal(this, "modalConf"); } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } finally { } }
protected void btn_nuevo_Click(object sender, EventArgs e) { Limpiar(); dv_detalle.Visible = false; utils.AbrirModal(this, "modalPuntos"); ddl_puntosCambiarPreruta.Visible = false; OrigenBC o = new OrigenBC().ObtenerXId(1); hf_origen.Value = JsonConvert.SerializeObject(o); // DataTable dt = new PreRutaBC().ObtenerPuntos(); // hf_jsonRuta.Value = JsonConvert.SerializeObject(dt); DateTime fh = Convert.ToDateTime(txt_buscarFecha.Text); // dt = new PedidoBC().ObtenerTodo(desde: fh, hasta: fh, solo_sin_ruta: true); DataTable dt = new PedidoBC().ObtenerTodo(desde: fh, hasta: fh, hora_id: int.Parse(ddl_buscarHorario.SelectedValue), regi_id: 0, ciud_id: 0, comu_id: null, usua_id: 0, peru_numero: null, solo_sin_ruta: true, id_ruta: 0); hf_jsonPedidos.Value = JsonConvert.SerializeObject(dt); utils.CargaDrop(ddl_puntoNombre, "PERU_ID", "PERU_NUMERODROP", dt); PreRutaBC p = new PreRutaBC(); p.FECHA_DESPACHOEXP = DateTime.Parse(txt_buscarFecha.Text); p.FH_CREACION = DateTime.Now; p.HORARIO.HORA_COD = ddl_buscarHorario.SelectedItem.Text; p.HORARIO.HORA_ID = int.Parse(ddl_buscarHorario.SelectedItem.Value); var random = new Random(); var color = String.Format("#{0:X6}", random.Next(0x1000000)); p.RUTA_COLOR = color; hf_jsonRuta.Value = JsonConvert.SerializeObject(p); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "map_cargar", "mapa(true);", true); }
private void ObtenerPuntosRuta(bool forzarBD) { DateTime fh = Convert.ToDateTime(txt_buscarFecha.Text); int hora_id = Convert.ToInt32(ddl_buscarHorario.SelectedValue); PreRutaBC p = new PreRutaBC().ObtenerXId(Convert.ToInt32(hf_idRuta.Value), true); hf_jsonRuta.Value = JsonConvert.SerializeObject(p); hf_circular.Value = p.RETORNO; DataTable dt; dt = new PedidoBC().ObtenerTodo(desde: fh, hasta: fh, solo_sin_ruta: true, id_ruta: p.ID); utils.CargaDrop(ddl_puntoNombre, "PERU_ID", "PERU_NUMERODROP", dt); ddl_puntosCambiarPreruta.Visible = true; ddl_puntosCambiarPreruta.SelectedValue = p.ID.ToString(); hf_origen.Value = JsonConvert.SerializeObject(p.ORIGEN); ddl_vehiculoTipo.SelectedValue = p.TRAILER.TRAILER_TIPO.TRTI_ID.ToString(); ddl_vehiculoTipo_SelectedIndexChanged(null, null); ddl_vehiculoTrailer.SelectedValue = p.TRAILER.TRAI_ID.ToString(); lbl_puntoTracto.Text = (string.IsNullOrEmpty(p.TRACTO.TRAC_PLACA)) ? "Sin tracto" : "Tracto: " + p.TRACTO.TRAC_PLACA; lbl_puntoTrailer.Text = (string.IsNullOrEmpty(p.TRAILER.TRAI_PLACA)) ? "Sin trailer" : "Trailer: " + p.TRAILER.TRAI_PLACA; lbl_puntoConductor.Text = (string.IsNullOrEmpty(p.CONDUCTOR.COND_NOMBRE)) ? "Sin conductor" : "Conductor: " + p.CONDUCTOR.COND_NOMBRE; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "map_cargar", "abrirModal('modalPuntos'); mapa(false);", true); ddl_vehiculoTracto.Items.Clear(); ddl_vehiculoTracto.Items.Add(new RadComboBoxItem("Sin Tracto", "0")); dt = new TractoBC().ObtenerTodo(fecha: fh, hora_id: hora_id); foreach (DataRow dr in dt.Rows) { RadComboBoxItem cb = new RadComboBoxItem(dr["TRAC_PLACA"].ToString(), dr["TRAC_ID"].ToString()); if (dr["ID_RUTA"] != DBNull.Value) { long id_ruta = Convert.ToInt32(dr["ID_RUTA"]); cb.Enabled = (id_ruta.ToString() == hf_idRuta.Value); } ddl_vehiculoTracto.Items.Add(cb); } ddl_vehiculoTracto.SelectedValue = p.TRACTO.TRAC_ID.ToString(); txt_editNombre.Text = p.NUMERO; ddl_vehiculoConductor.Items.Clear(); ddl_vehiculoConductor.Items.Add(new RadComboBoxItem("Sin Conductor", "0")); dt = new ConductorBC().ObtenerTodo(fecha: fh, hora_id: hora_id, cond_activo: true, cond_bloqueado: false); foreach (DataRow dr in dt.Rows) { RadComboBoxItem cb = new RadComboBoxItem((dr["COND_RUT"].ToString() + " - " + dr["COND_NOMBRE"].ToString()), dr["COND_ID"].ToString()); if (dr["ID_RUTA"] != DBNull.Value) { long id_ruta = Convert.ToInt32(dr["ID_RUTA"]); cb.Enabled = (id_ruta.ToString() == hf_idRuta.Value); } ddl_vehiculoConductor.Items.Add(cb); } ddl_vehiculoConductor.SelectedValue = p.CONDUCTOR.COND_ID.ToString(); }
protected void ddl_puntosCambiarPreruta_SelectedIndexChanged(object sender, EventArgs e) { Limpiar(); int id_ruta = Convert.ToInt32(ddl_puntosCambiarPreruta.SelectedValue); hf_idRuta.Value = id_ruta.ToString(); PreRutaBC p = new PreRutaBC().ObtenerXId(id_ruta); hf_origen.Value = JsonConvert.SerializeObject(p.ORIGEN); ObtenerPuntosRuta(true); }
protected void btn_detalleAbrir_Click(object sender, EventArgs e) { DateTime fecha = Convert.ToDateTime(txt_buscarFecha.Text); int hora_id = Convert.ToInt32(ddl_buscarHorario.SelectedValue); DataTable dt; ddl_editTracto.Items.Clear(); ddl_editConductor.Items.Clear(); ddl_editTracto.Items.Add(new RadComboBoxItem("Sin Tracto", "0")); ddl_editConductor.Items.Add(new RadComboBoxItem("Sin Conductor", "0")); dt = new TractoBC().ObtenerTodo(fecha: fecha, hora_id: hora_id); foreach (DataRow dr in dt.Rows) { RadComboBoxItem cb = new RadComboBoxItem(dr["TRAC_PLACA"].ToString(), dr["TRAC_ID"].ToString()); if (dr["ID_RUTA"] != DBNull.Value) { long id_ruta = Convert.ToInt32(dr["ID_RUTA"]); if (id_ruta.ToString() != hf_idRuta.Value) { cb.Enabled = false; } } ddl_editTracto.Items.Add(cb); } dt = new ConductorBC().ObtenerTodo(fecha: fecha, hora_id: hora_id, cond_activo: true, cond_bloqueado: false); foreach (DataRow dr in dt.Rows) { RadComboBoxItem cb = new RadComboBoxItem((dr["COND_RUT"].ToString() + "/" + dr["COND_NOMBRE"].ToString()), dr["COND_ID"].ToString()); if (dr["ID_RUTA"] != DBNull.Value) { long id_ruta = Convert.ToInt32(dr["ID_RUTA"]); if (id_ruta.ToString() != hf_idRuta.Value) { cb.Enabled = false; } } ddl_editConductor.Items.Add(cb); } ddl_editTracto.SelectedIndex = 0; ddl_editConductor.SelectedIndex = 0; PreRutaBC p = new PreRutaBC().ObtenerXId(Convert.ToInt64(hf_idRuta.Value)); ddl_editTipo.SelectedValue = p.TRAILER.TRAILER_TIPO.TRTI_ID.ToString(); ddl_vehiculoTipo_SelectedIndexChanged(null, null); ddl_editConductor.SelectedValue = p.CONDUCTOR.COND_ID.ToString(); ddl_editTracto.SelectedValue = p.TRACTO.TRAC_ID.ToString(); ddl_editTrailer.SelectedValue = p.TRAILER.TRAI_ID.ToString(); }
protected void btn_confEliminarRuta_Click(object sender, EventArgs e) { try { PreRutaBC p = new PreRutaBC(); p.ID = Convert.ToInt64(hf_idRuta.Value); p.Eliminar(); utils.ShowMessage2(this, "eliminar", "success"); utils.CerrarModal(this, "modalConf"); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "elimina2", "eliminarRuta2();", true); } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } }
private void ObtenerRutas() { DateTime fecha = Convert.ToDateTime(txt_buscarFecha.Text); int hora_id = Convert.ToInt32(ddl_buscarHorario.SelectedValue); List <OrigenBC> arrOrigen = new OrigenBC().ObtenerArray(); List <PreRutaBC> arrRuta = new PreRutaBC().ObtenerArray(desde: fecha, hasta: fecha, hora_id: hora_id, puntos_ruta: true); List <PedidoBC> arrPedido = new PedidoBC().ObtenerArray(desde: fecha, hasta: fecha, hora_id: hora_id, solo_sin_ruta: true); ScriptManager.RegisterStartupScript(this.Page , this.GetType() , "mapilla" , string.Format("jsonPedidos = {0};" + "jsonOrigenes = {1};" + "jsonRutas = {2};" + "mapa();" , JsonConvert.SerializeObject(arrPedido) , JsonConvert.SerializeObject(arrOrigen) , JsonConvert.SerializeObject(arrRuta)) , true); }
protected void btn_colorGuardar_Click(object sender, EventArgs e) { try { PreRutaBC p = new PreRutaBC(); p.ID = Convert.ToInt32(hf_idRuta.Value); p.RUTA_COLOR = txt_editColor.Text; p.Guardar(); utils.ShowMessage2(this, "guardar", "success_modificar"); } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } finally { utils.CerrarModal(this, "modalColor"); ObtenerRutas(true, false); } }
protected void btn_confEnviar_Click(object sender, EventArgs e) { PreRutaBC gd = new PreRutaBC(); try { DataTable excel = gd.CrearEnvio(hseleccionado.Value.ToString(), user.USUA_ID, chk_archivar.Checked); ViewState["lista"] = excel; utils.CerrarModal(this.Page, "modalenviar"); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "exp", "exportar();", true); } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } finally { ObtenerRutas(true); } }
public void GuardarRuta(string jsonRuta) { Context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); Context.Response.AppendHeader("Content-type", "application/json"); try { PreRutaBC pre_ruta = JsonConvert.DeserializeObject <PreRutaBC>(jsonRuta); pre_ruta.Guardar(); DataTable dt = new DataTable(); dt.Columns.Add("ID_DESTINO", typeof(int)); dt.Columns.Add("SECUENCIA", typeof(int)); dt.Columns.Add("FH_LLEGADA", typeof(DateTime)); dt.Columns.Add("FH_SALIDA", typeof(DateTime)); dt.Columns.Add("TIEMPO", typeof(int)); DateTime fechaRelativa = pre_ruta.FECHA_DESPACHOEXP; string[] temp = pre_ruta.PEDIDOS[0].HORA_SALIDA.HORA_COD.Split(":".ToCharArray()); fechaRelativa = fechaRelativa.Date.AddHours(Convert.ToInt32(temp[0])).AddMinutes(Convert.ToInt32(temp[1])); foreach (PedidoBC p in pre_ruta.PEDIDOS) { p.RUTA_PEDIDO.tiempo = Convert.ToInt32(p.RUTA_PEDIDO.FH_LLEGADA.Subtract(fechaRelativa).TotalMinutes); fechaRelativa = p.RUTA_PEDIDO.FH_SALIDA; DataRow dr = dt.NewRow(); dr["ID_DESTINO"] = p.PERU_ID; dr["SECUENCIA"] = p.RUTA_PEDIDO.SECUENCIA; dr["FH_LLEGADA"] = p.RUTA_PEDIDO.FH_LLEGADA; dr["FH_SALIDA"] = p.RUTA_PEDIDO.FH_SALIDA; dr["TIEMPO"] = p.RUTA_PEDIDO.tiempo; dt.Rows.Add(dr); } pre_ruta.GuardarPuntos(); var debug = ""; } catch (Exception ex) { Context.Response.StatusDescription = ex.Message; } }
private void ObtenerRutas(bool forzarBD, bool refrescar_combo = true) { if (ViewState["listar"] == null || forzarBD) { DateTime desde = (string.IsNullOrEmpty(txt_buscarFecha.Text)) ? DateTime.MinValue : Convert.ToDateTime(txt_buscarFecha.Text); DateTime hasta = (string.IsNullOrEmpty(txt_buscarFecha.Text)) ? DateTime.MinValue : Convert.ToDateTime(txt_buscarFecha.Text); int regi_id = Convert.ToInt32(ddl_buscarRegion.SelectedValue); int ciud_id = Convert.ToInt32(ddl_buscarCiudad.SelectedValue); int comu_id = Convert.ToInt32(ddl_buscarComuna.SelectedValue); int hora_id = Convert.ToInt32(ddl_buscarHorario.SelectedValue); string envio = txt_buscaenvio.Text; ViewState["listar"] = new PreRutaBC().ObtenerTodo(desde: desde , hasta: hasta , regi_id: regi_id , ciud_id: ciud_id , comu_id: comu_id , usua_id: user.USUA_ID , peru_numero: txt_buscarNro.Text , hora_id: hora_id , envio: envio); } DataView dw = new DataView((DataTable)ViewState["listar"]); if (ViewState["sortExpresion"] != null && ViewState["sortExpresion"].ToString() != "") { dw.Sort = (String)ViewState["sortExpresion"]; } if (refrescar_combo == true) { utils.CargaDropNormal(ddl_puntosCambiarPreruta, "ID", "NUMERO", dw.ToTable()); } DateTime fh = Convert.ToDateTime(txt_buscarFecha.Text); List <PedidoBC> cosa = new PedidoBC().ObtenerArray(desde: fh, hasta: fh, solo_sin_ruta: true); hf_jsonPedidos.Value = JsonConvert.SerializeObject(cosa); gv_listar.DataSource = dw; gv_listar.DataBind(); }
protected void btn_vehiculoGuardar_Click(object sender, EventArgs e) { try { PreRutaBC p = new PreRutaBC(); p.ID = Convert.ToInt32(hf_idRuta.Value); p.TRAILER.TRAI_ID = Convert.ToInt32(ddl_vehiculoTrailer.SelectedValue); p.TRACTO.TRAC_ID = Convert.ToInt32(ddl_vehiculoTracto.SelectedValue); p.CONDUCTOR.COND_ID = Convert.ToInt32(ddl_vehiculoConductor.SelectedValue); p.NUMERO = txt_editNombre.Text; p.Guardar(); utils.ShowMessage2(this, "guardar", "success_modificar"); ddl_puntosCambiarPreruta.Items.FindByValue(p.ID.ToString()).Text = p.NUMERO; } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } finally { utils.CerrarModal(this, "modalVehiculo"); ObtenerRutas(true, false); } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsCallback) { return; } else { PreRutaBC preruta = new PreRutaBC(); string procesos; procesos = muestraproceso(preruta.obtenerultimosprocesos()); if (procesos != "") { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "muestraproceso", "ClientNameCallback('" + procesos + "');", true); } } if (Session["Usuario"] == null) { Response.Redirect("~/Inicio.aspx"); } UsuarioBC user = (UsuarioBC)Session["Usuario"]; bool autorizado = false; string nombrepag = this.Page.AppRelativeVirtualPath; nombrepag = nombrepag.Substring(nombrepag.LastIndexOf("/") + 1); //if (nombrepag.ToLower() != "inicio.aspx") //{ // foreach (MenuBC m in user.USUARIO_TIPO.MENU) // { // if (m.MENU_LINK == nombrepag) // { // autorizado = true; // break; // } // } // if (!autorizado) // Response.Redirect("~/Inicio.aspx"); //} // txtClientID.Attributes.Add("onchange", "GetClientNameById('id|' + this.value, 'id');"); if (IsPostBack == false) { ParametroBC param = new ParametroBC(); DataTable datos = param.ObtenerTodo(); Session["parametros"] = datos; int contador = 0; while (contador < datos.Rows.Count) { HiddenField hf = new HiddenField(); hf.ID = "param_" + datos.Rows[contador]["para_nombre"].ToString(); hf.Value = datos.Rows[contador]["para_valor"].ToString(); this.parametros.ContentTemplateContainer.Controls.Add(hf); contador = contador + 1; } } string callBackClientID = Page.ClientScript.GetCallbackEventReference(this, "arg", "ClientNameCallback", "context", "ClientNameCallbackError", true); string clientIDfunction = "function GetClientNameById(arg,context) { " + callBackClientID + "; }"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "GetClientNameById", clientIDfunction, true); // txtClientName.Attributes.Add("onchange", "GetClientIdByName('name|' + this.value, 'name');"); //string callBackClientName = Page.ClientScript.GetCallbackEventReference(this, "arg", "ClientIdCallback", "context", "ClientIdCallbackError", true); //string clientNamefunction = "function GetClientIdByName(arg, context) { " + callBackClientName + "; }"; //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "GetClientIdByName", clientNamefunction, true); }
protected void gv_listar_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "COLOR") { hf_idRuta.Value = e.CommandArgument.ToString(); PreRutaBC p = new PreRutaBC().ObtenerXId(Convert.ToInt32(hf_idRuta.Value)); txt_editColor.Text = p.RUTA_COLOR; utils.AbrirModal(this.Page, "modalColor"); } if (e.CommandName == "PUNTOS") { Limpiar(); dv_detalle.Visible = false; //utils.AbrirModal(this.Page, "modalPuntos"); gv_listar.SelectedIndex = Convert.ToInt32(e.CommandArgument); int id_preruta = Convert.ToInt32(gv_listar.SelectedDataKey.Values[0]); int id_origen = Convert.ToInt32(gv_listar.SelectedDataKey.Values[1]); hf_idRuta.Value = id_preruta.ToString(); ObtenerPuntosRuta(true); //lbl_puntoSalida.Text = "Tiempo de viaje: "; } if (e.CommandName == "DETALLE") { Limpiar(); hf_idRuta.Value = e.CommandArgument.ToString(); PreRutaBC p = new PreRutaBC().ObtenerXId(Convert.ToInt32(hf_idRuta.Value)); DateTime fecha = Convert.ToDateTime(txt_buscarFecha.Text); int hora_id = Convert.ToInt32(ddl_buscarHorario.SelectedValue); DataTable dt; ddl_vehiculoTracto.Items.Clear(); ddl_vehiculoConductor.Items.Clear(); txt_editNombre.Text = ""; ddl_vehiculoTracto.Items.Add(new RadComboBoxItem("Sin Tracto", "0")); ddl_vehiculoConductor.Items.Add(new RadComboBoxItem("Sin Conductor", "0")); dt = new TractoBC().ObtenerTodo(fecha: fecha, hora_id: hora_id); foreach (DataRow dr in dt.Rows) { RadComboBoxItem cb = new RadComboBoxItem(dr["TRAC_PLACA"].ToString(), dr["TRAC_ID"].ToString()); if (dr["ID_RUTA"] != DBNull.Value) { long id_ruta = Convert.ToInt32(dr["ID_RUTA"]); if (id_ruta.ToString() != hf_idRuta.Value) { cb.Enabled = false; } } ddl_vehiculoTracto.Items.Add(cb); } dt = new ConductorBC().ObtenerTodo(fecha: fecha, hora_id: hora_id, cond_activo: true, cond_bloqueado: false); foreach (DataRow dr in dt.Rows) { RadComboBoxItem cb = new RadComboBoxItem((dr["COND_RUT"].ToString() + " - " + dr["COND_NOMBRE"].ToString()), dr["COND_ID"].ToString()); if (dr["ID_RUTA"] != DBNull.Value) { long id_ruta = Convert.ToInt32(dr["ID_RUTA"]); if (id_ruta.ToString() != hf_idRuta.Value) { cb.Enabled = false; } } ddl_vehiculoConductor.Items.Add(cb); } ddl_vehiculoTipo.SelectedValue = p.TRAILER.TRAILER_TIPO.TRTI_ID.ToString(); ddl_vehiculoTipo_SelectedIndexChanged(null, null); ddl_vehiculoConductor.SelectedValue = p.CONDUCTOR.COND_ID.ToString(); ddl_vehiculoTracto.SelectedValue = p.TRACTO.TRAC_ID.ToString(); txt_editNombre.Text = p.NUMERO.ToString(); ddl_vehiculoTrailer.SelectedValue = p.TRAILER.TRAI_ID.ToString(); dv_detalle.Visible = true; utils.AbrirModal(this.Page, "modalVehiculo"); } if (e.CommandName == "ELIMINAR") { hf_idRuta.Value = e.CommandArgument.ToString(); lbl_confTitulo.Text = "Eliminar Propuesta"; lbl_confMensaje.Text = "Se eliminará la propuesta de ruta seleccionada ¿Desea continuar?"; utils.AbrirModal(this, "modalConf"); btn_confEliminar.Visible = true; btn_confEliminarTodos.Visible = false; } }
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument) { PreRutaBC preruta = new PreRutaBC(); callbackReturnValue = muestraproceso(preruta.obtenerultimosprocesos()); }
protected void btn_pdf_click(object sender, EventArgs e) { PreRutaBC gd = new PreRutaBC(); String mimeType = ""; try { // DataTable excel = gd.CrearEnvio(hseleccionado.Value.ToString(), user.USUA_ID, chk_archivar.Checked); // ViewState["lista"] = excel; // ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "exp", "exportar();", true); if (hseleccionado.Value == "") { utils.ShowMessage(this, "Seleccione al menos un viaje", "error", false); return; } this.pnlReport.Visible = true; ReportBC report = new ReportBC(); // VIAJEBC v = new VIAJEBC().ObtenerXID(Convert.ToInt32(this.tbidviajed.Text)); List <int> ids = hseleccionado.Value.ToString().Split(',').Select(int.Parse).ToList(); string zip = GenerateFileNamezipPDF("hr_", ".zip"); int contador = 0; if (ids.Count == 1) { try { // DataTable excel = gd.CrearEnvio(hseleccionado.Value.ToString(), user.USUA_ID, chk_archivar.Checked); // ViewState["lista"] = excel; // ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "exp", "exportar();", true); this.pnlReport.Visible = true; DataTable datos = report.obrenerReporteDespachoViaje(ids[0].ToString()); ReportDataSource dataSource = new ReportDataSource("Datos", datos); this.ReportViewer1.LocalReport.DataSources.Clear(); this.ReportViewer1.LocalReport.DataSources.Add(dataSource); Warning[] warnings; string[] streamids; string encoding; string extension; //Word byte[] bytes = this.ReportViewer1.LocalReport.Render( "PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); //byte[] renderedBytes = this.ReportViewer1.LocalReport.Render("PDF"); this.Response.Clear(); this.Response.ContentType = mimeType; this.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}{1}{2}", datos.Rows[0]["numero"].ToString(), '.', extension)); this.Response.BinaryWrite(bytes); this.Response.End(); } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } finally { ObtenerRutas(true); } } else { while (contador < ids.Count) { DataTable datos = report.obrenerReporteDespachoViaje(ids[contador].ToString()); ReportDataSource dataSource = new ReportDataSource("Datos", datos); this.ReportViewer1.LocalReport.DataSources.Clear(); this.ReportViewer1.LocalReport.DataSources.Add(dataSource); Warning[] warnings; string[] streamids; string encoding; string extension; //Word byte[] bytes = this.ReportViewer1.LocalReport.Render( "PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); //byte[] renderedBytes = this.ReportViewer1.LocalReport.Render("PDF"); Stream stream = new MemoryStream(bytes); UtilsWeb.AddStreamToZip(zip, stream, GenerateFileNamezipPDF("hr_" + datos.Rows[0]["numero"].ToString(), ".pdf")); contador = contador + 1; } //this.Response.Clear(); //this.Response.ContentType = mimeType; //this.Response.AddHeader("content-disposition", string.Format("attachment; filename=Hoja_Ruta_{0}{1}{2}", 'a', '.', extension)); //this.Response.BinaryWrite(bytes); //this.Response.End(); Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + "descarga_multiple.zip"); Response.BinaryWrite(File.ReadAllBytes(zip)); // File.Delete(Server.MapPath("./cargadefotos/Output.zip")); File.Delete(zip); Response.End(); } } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } finally { ObtenerRutas(true); } }
private bool LeerArchivoExcel(string RutaCompleta, string Hoja, string extension) { try { string ConexionString = string.Format("Data Source={0}", RutaCompleta); if (extension == ".xls") { ConexionString += string.Format(";Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;HDR=NO;IMEX=1'"); } else { ConexionString += string.Format(";Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1'"); } using (OleDbConnection Conexion = new OleDbConnection(ConexionString)) { string Sql = string.Format("SELECT * FROM [{0}$]", Hoja); OleDbDataAdapter Adapter = new OleDbDataAdapter(Sql, Conexion); DataTable DT = new DataTable("Excel"); Adapter.Fill(DT); DataTable dtIn = new DataTable(); int y = 0; while (y < DT.Columns.Count) //Definir columnas datatable y sus nombres { if (String.IsNullOrWhiteSpace(DT.Rows[0][y].ToString())) { break; } dtIn.Columns.Add(DT.Rows[0][y].ToString(), Type.GetType("System.String")); if (!string.IsNullOrEmpty(DT.Rows[0][y].ToString())) { DT.Columns[y].ColumnName = DT.Rows[0][y].ToString(); } else { break; } y++; } DT.Rows.RemoveAt(0); foreach (DataRow dr in DT.Rows) { int x = 0; while (x < y) { if (!String.IsNullOrWhiteSpace(dr[x].ToString())) { dtIn.ImportRow(dr); break; } x++; } } DataTable dtOut = new PreRutaBC().IngresarExcel(dtIn, user.USUA_ID); gv_listar.DataSource = dtOut; gv_listar.DataBind(); btn_procesar.Enabled = true; return(true); } } catch (Exception ex) { btn_procesar.Enabled = false; utils.ShowMessage(this, ex.Message, "error", false); return(false); } }
protected void btn_puntosGuardar_Click(object sender, EventArgs e) { try { bool nuevo = false; if (hf_idRuta.Value == "") { nuevo = true; } PreRutaBC pre_ruta = JsonConvert.DeserializeObject <PreRutaBC>(hf_jsonRuta.Value); pre_ruta.NUMERO = txt_editNombre.Text; pre_ruta.Guardar(); hf_idRuta.Value = pre_ruta.ID.ToString(); DataTable dt = new DataTable(); dt.Columns.Add("ID_DESTINO", typeof(int)); dt.Columns.Add("SECUENCIA", typeof(int)); dt.Columns.Add("FH_LLEGADA", typeof(DateTime)); dt.Columns.Add("FH_SALIDA", typeof(DateTime)); dt.Columns.Add("TIEMPO", typeof(int)); DateTime fechaRelativa = pre_ruta.FECHA_DESPACHOEXP; string[] temp = pre_ruta.PEDIDOS[0].HORA_SALIDA.HORA_COD.Split(":".ToCharArray()); fechaRelativa = fechaRelativa.Date.AddHours(Convert.ToInt32(temp[0])).AddMinutes(Convert.ToInt32(temp[1])); foreach (PedidoBC p in pre_ruta.PEDIDOS) { p.RUTA_PEDIDO.tiempo = Convert.ToInt32(p.RUTA_PEDIDO.FH_LLEGADA.Subtract(fechaRelativa).TotalMinutes); fechaRelativa = p.RUTA_PEDIDO.FH_SALIDA; DataRow dr = dt.NewRow(); dr["ID_DESTINO"] = p.PERU_ID; dr["SECUENCIA"] = p.RUTA_PEDIDO.SECUENCIA; dr["FH_LLEGADA"] = p.RUTA_PEDIDO.FH_LLEGADA; dr["FH_SALIDA"] = p.RUTA_PEDIDO.FH_SALIDA; dr["TIEMPO"] = p.RUTA_PEDIDO.tiempo; dt.Rows.Add(dr); } pre_ruta.GuardarPuntos(); var debug = ""; if (nuevo) { utils.ShowMessage2(this, "guardar", "success_nuevo"); } else { utils.ShowMessage2(this, "guardar", "success_modificar"); } ObtenerRutas(true, false); ListItem yo = ddl_puntosCambiarPreruta.Items.FindByValue(pre_ruta.ID.ToString()); if (yo != null) { yo.Text = pre_ruta.NUMERO; } else { ddl_puntosCambiarPreruta.Items.Add(new ListItem(pre_ruta.NUMERO, pre_ruta.ID.ToString())); ddl_puntosCambiarPreruta.SelectedValue = pre_ruta.ID.ToString(); } } catch (Exception ex) { utils.ShowMessage(this, ex.Message, "error", false); } finally { ObtenerPuntosRuta(true); } }