protected void btn_guardar_Click(object sender, EventArgs e) { DestinoBC d = new DestinoBC(); d.CODIGO = this.txt_editCodigo.Text; d.NOMBRE = this.txt_editNombre.Text; d.DETI_ID = int.Parse(this.ddl_editTipo.SelectedValue); if (string.IsNullOrEmpty(this.hf_idDestino.Value)) { if (d.Agregar(d)) { this.ObtenerDestinos(true); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msj", "alert('Destino agregado correctamente');", true); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "cerrar", "cerrarModal('modalDestino');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msj", "alert('Error');", true); } } else { d.ID = int.Parse(this.hf_idDestino.Value); if (d.Modificar(d)) { this.ObtenerDestinos(true); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msj", "alert('Destino modificado correctamente');", true); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "cerrar", "cerrarModal('modalDestino');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msj", "alert('Error');", true); } } }
protected void ddl_tipoDestino_SelectedIndexChanged(object sender, EventArgs e) { if (ddl_tipoDestino.SelectedIndex > 0) { //DestinoTipoBC desti = new DestinoTipoBC(); DataTable dt; //desti = desti.ObtenerSeleccionado(Convert.ToInt32(ddl_tipoDestino.SelectedValue), null); if (ddl_tipoDestino.SelectedValue == "DLPR") { LocalBC l = new LocalBC(); dt = l.obtenerTodoLocal(); utils.CargaDrop(ddl_destino, "ID", "DESCRIPCION", dt); } else { DestinoBC d = new DestinoBC(); dt = d.ObtenerXTipo(ddl_tipoDestino.SelectedValue); utils.CargaDrop(ddl_destino, "ID", "NOMBRE", dt); } if (dt.Rows.Count > 0) { ddl_destino.Enabled = true; } else { ddl_destino.Enabled = false; } } }
protected void btn_Eliminar_Click(object sender, EventArgs e) { DestinoBC d = new DestinoBC(); if (d.Eliminar(int.Parse(this.hf_idDestino.Value))) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msj", "alert('Destino eliminado correctamente');", true); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "cerrar", "cerrarModal('modalConfirmar');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msj", "alert('Error');", true); } this.ObtenerDestinos(true); }
private void ObtenerDestinos(bool forzarBD) { if (this.ViewState["lista"] == null || forzarBD) { DestinoBC d = new DestinoBC(); string nombre = txt_buscarNombre.Text; DataTable dt = d.ObtenerXParametros(nombre); this.ViewState["lista"] = dt; } DataView dw = new DataView((DataTable)this.ViewState["lista"]); 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 gv_listar_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EDITAR") { DestinoBC d = new DestinoBC(); this.hf_idDestino.Value = e.CommandArgument.ToString(); d = d.ObtenerSeleccionado(int.Parse(this.hf_idDestino.Value), null); this.txt_editCodigo.Text = d.CODIGO; this.txt_editNombre.Text = d.NOMBRE; this.ddl_editTipo.SelectedValue = d.DETI_ID.ToString(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "modal", "modalDestino();", true); } if (e.CommandName == "ELIMINAR") { this.hf_idDestino.Value = e.CommandArgument.ToString(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "modal", "modalConfirmar();", true); } }
public bool Modificar(DestinoBC d) { return(tran.Destino_Modificar(d)); }
public bool Agregar(DestinoBC d) { return(tran.Destino_Agregar(d)); }