protected void LoadTreeApps() { RadTreeNode oNode; DBConn oConn = new DBConn(); if (oConn.Open()) { AppBanner oBanner = new AppBanner(ref oConn); oBanner.EstBanner = "V"; DataTable dBanner = oBanner.Get(); if (dBanner != null) { if (dBanner.Rows.Count > 0) { foreach (DataRow oRow in dBanner.Rows) { oNode = new RadTreeNode(oRow["nom_banner"].ToString(), "banners_" + oRow["cod_banner"].ToString()); rdTreeApps.Nodes.Add(oNode); } } } dBanner = null; } oConn.Close(); }
protected void Page_Load(object sender, EventArgs e) { oWeb.ValidaSessionAdm(); if (!IsPostBack) { CodBanner.Value = oWeb.GetData("CodBanner"); if (!string.IsNullOrEmpty(CodBanner.Value)) { DBConn oConn = new DBConn(); if (oConn.Open()) { AppBanner oBanner = new AppBanner(ref oConn); oBanner.CodBanner = CodBanner.Value; DataTable dBanner = oBanner.Get(); if (dBanner != null) { if (dBanner.Rows.Count > 0) { txtTituloBanner.Text = dBanner.Rows[0]["nom_banner"].ToString(); rdCmbTipoBanner.Items.FindItemByValue(dBanner.Rows[0]["tipo_banner"].ToString()).Selected = true; rdCmbEstado.Items.FindItemByValue(dBanner.Rows[0]["est_banner"].ToString()).Selected = true; Image.Visible = true; } } dBanner = null; } oConn.Close(); } } }
protected void rdBanners_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { DBConn oConn = new DBConn(); if (oConn.Open()) { GridColumn oGridColumn; oGridColumn = rdBanners.MasterTableView.Columns.FindByUniqueName("NomBanner"); oGridColumn.HeaderText = oCulture.GetResource("Banner", "NomBanner"); oGridColumn = rdBanners.MasterTableView.Columns.FindByUniqueName("EstBanner"); oGridColumn.HeaderText = oCulture.GetResource("Banner", "Estado"); AppBanner oBanner = new AppBanner(ref oConn); rdBanners.DataSource = oBanner.Get(); oConn.Close(); } }
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(); }
public ActionResponse UploadAppBanner() { int LanguageId = 1; Dictionary <Extensions.SystemInfo, string> setting = this.query.GetSystemSettings; ActionResponse response = new ActionResponse(); TemporaryImageLocation tmp = new TemporaryImageLocation(); try { HttpRequestMessage request = base.Request; HttpRequest httpRequest = HttpContext.Current.Request; NameValueCollection data = httpRequest.Form; if (data.Get("LocationID") == null) { response.success = false; response.code = HttpStatusCode.BadRequest.ToString(); response.message = "Location ID is required."; return(response); } HttpFileCollection data_files = httpRequest.Files; if (data_files.Get("Banner") == null) { response.success = false; response.code = HttpStatusCode.BadRequest.ToString(); response.message = "Banner is required."; return(response); } AspNetUser user = this.query.GetCurrentUserInfoByID(IdentityExtensions.GetUserId(base.User.Identity)); AppBanner banner = new AppBanner(); banner.AndroidEnabled = data.Get("AndroidEnabled") == null ? true : bool.Parse(data.Get("AndroidEnabled")); banner.BannerLocation = ""; banner.EntryTime = DateTime.Now; banner.IOSEnabled = data.Get("IOSEnabled") == null ? true : bool.Parse(data.Get("IOSEnabled")); banner.IsActive = true; banner.ModifiedBy = user.UserSequence; banner.ModifiedTime = DateTime.Now; banner.StoreID = int.Parse(data.Get("LocationID")); banner.UserID = user.UserSequence; foreach (object obj in data_files) { string fileName = (string)obj; if (fileName == "Banner" || fileName == "Logo") { HttpPostedFile file = httpRequest.Files[fileName]; string fileExt = Path.GetExtension(file.FileName).ToLower(); if (!(fileExt.ToLower() == ".jpg") && !(fileExt.ToLower() == ".png") && !(fileExt.ToLower() == ".jpeg")) { response.success = false; response.message = ((LanguageId == 1) ? "png, jgp, JPEG format are Allowed" : "png, jgp, JPEG الصيغ المسموح بها"); response.code = HttpStatusCode.BadRequest.ToString(); return(response); } this.query.SaveTxtLog("extention:" + fileExt); DirectoryInfo originalDirectory = new DirectoryInfo(string.Format("{0}{1}", HttpContext.Current.Server.MapPath("~\\"), setting[Extensions.SystemInfo.TempGalleryPath])); string pathString = originalDirectory.ToString(); string fileName2 = Path.GetFileName(file.FileName); string pre_fix = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss_"); string file_to_save = string.Format("{0}-{1}", pre_fix, fileName2); string file_to_save_thumbnail = string.Format("{0}-{1}", pre_fix + "logothumbnail", fileName2); string file_to_save_gallery = string.Format("{0}-{1}", pre_fix + "gallery", fileName2); string file_to_save_medium = string.Format("{0}-{1}", pre_fix + "med", fileName2); if (!Directory.Exists(pathString)) { Directory.CreateDirectory(pathString); } string path = string.Format("{0}\\{1}", pathString, file_to_save); this.query.SaveTxtLog("path:" + path); string new_path_thumbnail = string.Format("{0}\\{1}", pathString, file_to_save_thumbnail); string new_path_gallery = string.Format("{0}\\{1}", pathString, file_to_save_gallery); string new_path_medium = string.Format("{0}\\{1}", pathString, file_to_save_medium); file.SaveAs(path); this.query.SaveTxtLog("save as:"); new ImageJob(file, new_path_thumbnail, new Instructions("mode=pad;format=jpg;width=" + 1027.ToString() + ";height=" + 530.ToString())) { CreateParentDirectory = true }.Build(); string MediumSize = string.Concat(new string[] { "mode=pad;format=jpg;width=", 513.ToString(), ";height=", 265.ToString(), ";" }); new ImageJob(file, new_path_medium, new Instructions(MediumSize)) { CreateParentDirectory = true }.Build(); tmp.OrignalFileLocation = file_to_save; tmp.ThumbnailLocation = file_to_save_thumbnail; tmp.MediamFileLocation = file_to_save_medium; tmp.EntryTime = DateTime.Now; this.db.TemporaryImageLocations.Add(tmp); this.db.SaveChanges(); string x = this.ReplaceImage(tmp.ID); banner.BannerLocation = file_to_save; this.query.SaveTxtLog("saved"); response.success = true; response.code = HttpStatusCode.OK.ToString(); } } response.success = true; response.message = "Banner Saved"; response.code = HttpStatusCode.OK.ToString(); this.db.AppBanners.Add(banner); this.db.SaveChanges(); } catch (Exception ex) { this.query.SaveTxtLog("Expection (UploadTemp):" + ex.ToString()); response.code = HttpStatusCode.ExpectationFailed.ToString(); response.success = false; response.message = "Error Creating Shop Error-Code:20EXPD"; } return(response); }
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; } }