示例#1
0
        protected void btnGrabar_Click(object sender, EventArgs e)
        {
            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                oConn.BeginTransaction();
                string  cPath = Server.MapPath(".") + @"\binary\";
                CmsZona oZona = new CmsZona(ref oConn);
                oZona.CodZona     = CodZona.Value;
                oZona.NomZona     = txtTitulo.Text;
                oZona.TextoZona   = rdDescripcion.Content;
                oZona.EstZona     = rdCmbEstado.SelectedValue;
                oZona.IndDespCont = (chk_despliegue.Checked == true ? "V" : "N");
                oZona.Accion      = (string.IsNullOrEmpty(CodZona.Value) ? "CREAR" : "EDITAR");
                oZona.Put();
                CodZona.Value = oZona.CodZona;
                if (string.IsNullOrEmpty(oZona.Error))
                {
                    oConn.Commit();
                    string sFile = "Zona_" + oZona.CodZona + ".bin";
                    oZona.SerializaZona(ref oConn, cPath, sFile);
                }
                else
                {
                    oConn.Rollback();
                }

                oConn.Close();
            }
        }
示例#2
0
        protected void rdZona_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_zona"].ToString();
                Response.Redirect(String.Format("Zona.aspx?CodZona={0}", cParam));
                break;

            case "cmdDelete":
                string pCodZona = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cod_zona"].ToString();
                DBConn oConn    = new DBConn();
                if (oConn.Open())
                {
                    string sPath = Server.MapPath(".") + @"\binary\Zona_" + pCodZona + ".bin";
                    File.Delete(sPath);

                    CmsZona oZona = new CmsZona(ref oConn);
                    oZona.CodZona = pCodZona;
                    oZona.Accion  = "ELIMINAR";
                    oZona.Put();

                    oConn.Close();
                }
                rdZona.Rebind();
                break;
            }
        }