protected void btnGrabar_Click(object sender, EventArgs e) { oIsUsuario = oWeb.GetObjUsuario(); DBConn oConn = new DBConn(); if (oConn.Open()) { AppBanner oBanner = new AppBanner(ref oConn); oBanner.CodBanner = CodBanner.Value; oBanner.NomBanner = txtTituloBanner.Text; oBanner.TipoBanner = rdCmbTipoBanner.SelectedValue; oBanner.EstBanner = rdCmbEstado.SelectedValue; oBanner.Accion = (string.IsNullOrEmpty(CodBanner.Value) ? "CREAR" : "EDITAR"); oBanner.Put(); CodBanner.Value = oBanner.CodBanner; if (string.IsNullOrEmpty(oBanner.Error)) { oConn.Commit(); StringBuilder cPath = new StringBuilder(); cPath.Append(Server.MapPath(".")).Append(@"\binary\"); oBanner.CodBanner = string.Empty; oBanner.SerializaBanner(ref oConn, cPath.ToString()); Image.Visible = true; AppImgBanner oImgBanner = new AppImgBanner(ref oConn); cPath = new StringBuilder(); cPath.Append(Server.MapPath(".")).Append(@"\binary\"); oImgBanner.SerializaImgBanner(ref oConn, cPath.ToString()); } else { oConn.Rollback(); } oConn.Close(); } rdImage.Rebind(); }
protected void rdBanners_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_banner"].ToString(); Response.Redirect(String.Format("Banner.aspx?CodBanner={0}", cParam)); break; case "cmdDelete": string pCodBanner = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cod_banner"].ToString(); DBConn oConn = new DBConn(); if (oConn.Open()) { oConn.BeginTransaction(); AppImgBanner oImgBanner = new AppImgBanner(ref oConn); oImgBanner.CodBanner = pCodBanner; oImgBanner.Accion = "ELIMINAR"; oImgBanner.Put(); if (string.IsNullOrEmpty(oImgBanner.Error)) { AppBanner oBanner = new AppBanner(ref oConn); oBanner.CodBanner = pCodBanner; oBanner.Accion = "ELIMINAR"; oBanner.Put(); if (string.IsNullOrEmpty(oBanner.Error)) { oConn.Commit(); StringBuilder cPath = new StringBuilder(); cPath.Append(Server.MapPath(".")).Append(@"\binary\"); oImgBanner.CodImgBanner = string.Empty; oImgBanner.CodBanner = string.Empty; oImgBanner.SerializaImgBanner(ref oConn, cPath.ToString()); oBanner.SerializaBanner(ref oConn, cPath.ToString()); cPath = new StringBuilder(); cPath.Append(Server.MapPath(".")); cPath.Append(@"\rps_onlineservice\"); cPath.Append(@"\banners\"); cPath.Append(@"\banner_"); cPath.Append(pCodBanner); if (Directory.Exists(cPath.ToString())) { Directory.Delete(cPath.ToString(), true); } } else { oConn.Rollback(); } } else { oConn.Rollback(); } } oConn.Close(); rdBanners.Rebind(); break; } }