} //EndOnUpdating protected void GVCamiones_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { string IdCamion = GVCamiones.DataKeys[e.RowIndex].Values["IdCamion"].ToString(); string Resultado = BLLCamiones.DelCamion(int.Parse(IdCamion)); RefrescarGrid(); string msj = ""; string clase = ""; if (Resultado == "Camión Eliminado") { msj = "Ok"; clase = "success"; } else { msj = "Atención!"; clase = "danger"; } //Creamos el log de borrado string[] args = new string[3]; args[0] = msj; args[1] = Resultado; // sub; args[2] = DateTime.Now.ToShortDateString(); WriteLog(args); Util.Library.UtilControls.SweetBox(msj, Resultado, clase, this.Page, this.GetType()); } catch (Exception ex) { Util.Library.UtilControls.SweetBox("Error!", ex.Message, "danger", this.Page, this.GetType()); } }
protected void btnGuardar_Click(object sender, EventArgs e) { try { int IdCamion = int.Parse(lblIdCamion.Text); string Matricula = txtMatricula.Text; string TipoCamion = DDLTipoCamion.SelectedValue; int Modelo = int.Parse(DDLModelo.SelectedValue); string Marca = DDLMarca.SelectedValue; int Capacidad = int.Parse(txtCapacidad.Text); float Kilometraje = float.Parse(txtKilometraje.Text); string urlfoto = UrlFoto.InnerText; bool Disponibilidad = chkDisponibilidad.Checked; string Resultado = BLLCamiones.UpdCamion(IdCamion, Matricula, TipoCamion, Modelo, Marca, Capacidad, Kilometraje, Disponibilidad, urlfoto); if (Resultado.IndexOf("Camión actualizado correctamente") > -1) { Util.Library.UtilControls.SweetBoxConfirm("OK!", Resultado, "success", "ListaCamiones.aspx", this.Page, this.GetType()); } else { //Mensaje de error Util.Library.UtilControls.SweetBox("Atención!", Resultado, "warning", this.Page, this.GetType()); } } catch (Exception ex) { Util.Library.UtilControls.SweetBox("ERROR!", ex.Message, "danger", this.Page, this.GetType()); } }
protected void GVCamiones_RowUpdating(object sender, GridViewUpdateEventArgs e) { string IdCamion = GVCamiones.DataKeys[e.RowIndex].Values["IdCamion"].ToString(); string Matricula = e.NewValues["Matricula"].ToString(); string Modelo = e.NewValues["Modelo"].ToString(); string Marca = e.NewValues["Marca"].ToString(); int Capacidad = Convert.ToInt32(e.NewValues["Capacidad"].ToString()); float Kilometraje = float.Parse(e.NewValues["Kilometraje"].ToString()); DropDownList TipoCamionAux = (DropDownList)GVCamiones.Rows[e.RowIndex].FindControl("DDLTipoCamion"); string Tipocamion = TipoCamionAux.SelectedValue; bool Disponibilidad = bool.Parse(e.NewValues["Disponibilidad"].ToString()); try { string Resultado = BLLCamiones.UpdCamion(int.Parse(IdCamion), Matricula, Tipocamion, int.Parse(Modelo), Marca, Capacidad, Kilometraje, Disponibilidad, null); GVCamiones.EditIndex = -1; RefrescarGrid(); Util.Library.UtilControls.SweetBox(Resultado, "", "success", this.Page, this.GetType()); } catch (Exception ex) { Util.Library.UtilControls.SweetBox("Error!", ex.Message, "danger", this.Page, this.GetType()); } } //EndOnUpdating
} //EndLlenarModelo protected void btnGuardar_Click(object sender, EventArgs e) { try { string Matricula = txtMatricula.Text; string TipoCamion = DDLTipoCamion.SelectedItem.Value; int Modelo = int.Parse(DDLModelo.SelectedItem.Value); string Marca = DDLMarca.SelectedItem.Value; int Capacidad = int.Parse(txtCapacidad.Text); float Kilometraje = float.Parse(txtKilometraje.Text); string urlFoto = UrlFoto.InnerText; string Resultado = BLLCamiones.InsCamion(Matricula, TipoCamion, Modelo, Marca, Capacidad, Kilometraje, urlFoto); if (Resultado.IndexOf("Camión agregado") > -1) { Util.Library.UtilControls.SweetBoxConfirm("OK!", Resultado, "success", "/Catalogos/Camiones/ListaCamiones.aspx", this.Page, this.GetType()); } else { Util.Library.UtilControls.SweetBox("Atención!", Resultado, "warning", this.Page, this.GetType()); } } catch (Exception ex) { //Enviar Mensaje de error Util.Library.UtilControls.SweetBox("ERROR!", ex.Message, "danger", this.Page, this.GetType()); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Llenamos los combos de camión y chofer UtilControls.FillDropDownList(DDLChofer, "IdChofer", "Nombre", BLLChofer.GetChoferes(true), "", "Selecciona Chofer"); UtilControls.FillDropDownList(DDLCamion, "IdCamion", "Matricula", BLLCamiones.GetlistCamiones(true), "", "Selecciona Camión"); Session["CargaRuta"] = null; } }
protected void DDLCamion_SelectedIndexChanged(object sender, EventArgs e) { //Obtenemos la capacidad del camión seleccionado if (DDLCamion.SelectedValue != "") { //Traemos la capacidad y la asignamos a txtCapCamion CamionVO Camion = BLLCamiones.GetCamionById(int.Parse(DDLCamion.SelectedValue)); txtCapCamion.Text = Camion.Capacidad.ToString(); } else { txtCapCamion.Text = ""; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) //Primera carga de la página { Util.Library.UtilControls.EnumToListBox(typeof(Marca), DDLMarca, false); Util.Library.UtilControls.EnumToListBox(typeof(Tipo), DDLTipoCamion, false); LlenarModelo(); DDLMarca.Items.Insert(0, new ListItem("Selecciona Marca", "")); DDLTipoCamion.Items.Insert(0, new ListItem("Selecciona Modelo", "")); DDLMarca.SelectedIndex = 0; DDLModelo.SelectedIndex = 0; DDLTipoCamion.SelectedIndex = 0; string Id = Request.QueryString["Id"]; if ((string.IsNullOrEmpty(Id)) || (!IsNumeric(Id))) { Response.Redirect("ListaCamiones.aspx"); } else { CamionVO Camion = BLLCamiones.GetCamionById(int.Parse(Id)); if (Camion.IdCamion == int.Parse(Id)) { lblIdCamion.Text = Camion.IdCamion.ToString(); txtMatricula.Text = Camion.Matricula; txtCapacidad.Text = Camion.Capacidad.ToString(); txtKilometraje.Text = Camion.Kilometraje.ToString(); DDLTipoCamion.SelectedValue = Camion.TipoCamion; DDLMarca.SelectedValue = Camion.Marca; DDLModelo.SelectedValue = Camion.Modelo.ToString(); imgFotoCamion.ImageUrl = Camion.UrlFoto; UrlFoto.InnerText = Camion.UrlFoto; chkDisponibilidad.Checked = Camion.Disponibilidad; } else { Response.Redirect("ListaCamiones.aspx"); } } } }
private void RefrescarGrid() { GVCamiones.DataSource = BLLCamiones.GetlistCamiones(null); GVCamiones.DataBind(); }