protected void btnGrabar1_Click(object sender, EventArgs e) { DBConn oConn = new DBConn(); if (oConn.Open()) { cAppMensaje oAppMensaje = new cAppMensaje(ref oConn); oAppMensaje.CodMensaje = CodMensaje.Value; oAppMensaje.DescMensaje = txt_nombre.Text; //oAppMensaje.TextoMensaje = txtMensaje.Text; oAppMensaje.TextoMensaje = rdMensaje.Content; oAppMensaje.EstMensaje = oCmbEstado.SelectedValue.ToString(); oAppMensaje.Accion = (string.IsNullOrEmpty(CodMensaje.Value) ? "CREAR" : "EDITAR"); oAppMensaje.Put(); if (!string.IsNullOrEmpty(oAppMensaje.Error)) { Response.Write("Error : " + oAppMensaje.Error + "<br>"); Response.End(); } CodMensaje.Value = oAppMensaje.CodMensaje; trMsjsView.Visible = true; ListBox1.Items.Clear(); ListBox2.Items.Clear(); Load_ListBox(); oConn.Close(); } }
protected void Page_Load(object sender, EventArgs e) { oWeb.ValidaSessionAdm(); if (!IsPostBack) { CodMensaje.Value = oWeb.GetData("CodMensaje"); if (!string.IsNullOrEmpty(CodMensaje.Value)) { DBConn oConn = new DBConn(); if (oConn.Open()) { //btnGrabar1.Visible = false; cAppMensaje oAppMensaje = new cAppMensaje(ref oConn); oAppMensaje.CodMensaje = CodMensaje.Value; DataTable dtMensaje = oAppMensaje.Get(); if (dtMensaje != null) { if (dtMensaje.Rows.Count > 0) { txt_nombre.Text = dtMensaje.Rows[0]["desc_mensaje"].ToString(); //txtMensaje.Text = dtMensaje.Rows[0]["texto_mensaje"].ToString(); rdMensaje.Content = dtMensaje.Rows[0]["texto_mensaje"].ToString(); oCmbEstado.Items.FindByValue(dtMensaje.Rows[0]["est_mensaje"].ToString()).Selected = true; } } dtMensaje = null; trMsjsView.Visible = true; Load_ListBox(); oConn.Close(); } } } }
protected void LoadGrid() { DBConn oConn = new DBConn(); if (oConn.Open()) { cAppMensaje oAppMensaje = new cAppMensaje(ref oConn); gridMensajes.DataSource = oAppMensaje.Get(); gridMensajes.DataBind(); oConn.Close(); } }
protected void gridMensajes_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { DBConn oConn = new DBConn(); if (oConn.Open()) { string pCodMensaje = gridMensajes.DataKeys[e.RowIndex].Value.ToString(); cAptMonitorMensaje oAptMonitorMensaje = new cAptMonitorMensaje(ref oConn); oAptMonitorMensaje.CodMensaje = pCodMensaje; oAptMonitorMensaje.Accion = "ELIMINAR"; oAptMonitorMensaje.Put(); if (!string.IsNullOrEmpty(oAptMonitorMensaje.Error)) { Response.Write(oAptMonitorMensaje.Error); Response.End(); } cAppMensaje oAppMensaje = new cAppMensaje(ref oConn); oAppMensaje.CodMensaje = pCodMensaje; oAppMensaje.Accion = "ELIMINAR"; oAppMensaje.Put(); if (!string.IsNullOrEmpty(oAppMensaje.Error)) { Response.Write(oAppMensaje.Error); Response.End(); } oConn.Close(); } } catch (Exception ex) { Response.Write(ex.Message + "; " + ex.InnerException.ToString()); } LoadGrid(); }