protected void rdTemplate_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { switch (e.CommandName) { case "cmdEdit": string[] cParam = new string[2]; cParam[0] = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cod_template"].ToString(); Response.Redirect(String.Format("Template.aspx?CodTemplate={0}", cParam)); break; case "cmdDelete": string pCodTemplate = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cod_template"].ToString(); DBConn oConn = new DBConn(); if (oConn.Open()) { string sPath = Server.MapPath(".") + @"\binary\Template_" + pCodTemplate + ".bin"; File.Delete(sPath); CmsTemplate oTemplate = new CmsTemplate(ref oConn); oTemplate.CodTemplate = pCodTemplate; oTemplate.Accion = "ELIMINAR"; oTemplate.Put(); oConn.Close(); } rdTemplate.Rebind(); break; } }
protected void btnGrabar_Click(object sender, EventArgs e) { DBConn oConn = new DBConn(); if (oConn.Open()) { oConn.BeginTransaction(); string cPath = Server.MapPath(".") + @"\binary\"; CmsTemplate oTemplate = new CmsTemplate(ref oConn); oTemplate.CodTemplate = CodTemplate.Value; oTemplate.NomTemplate = txtTitulo.Text; oTemplate.TextoTemplate = rdDescripcion.Content; oTemplate.EstTemplate = rdCmbEstado.SelectedValue; oTemplate.Accion = (string.IsNullOrEmpty(CodTemplate.Value) ? "CREAR" : "EDITAR"); oTemplate.Put(); CodTemplate.Value = oTemplate.CodTemplate; if (string.IsNullOrEmpty(oTemplate.Error)) { oConn.Commit(); string sFile = "Template_" + oTemplate.CodTemplate + ".bin"; oTemplate.SerializaTemplate(ref oConn, cPath, sFile); } else { oConn.Rollback(); } oConn.Close(); } }