protected void gvWallpaper_RowCommand(object sender, GridViewCommandEventArgs e) { int index = Convert.ToInt32(e.CommandArgument); if (e.CommandName == "Preview") { Preview(gvWallpaper.Rows[index].Cells[1].Text); strScript = "window.open('/preview.asp');"; } else if (e.CommandName == "Publish") { dsWallpaperTableAdapters.wallpaperTableAdapter wpTA = new dsWallpaperTableAdapters.wallpaperTableAdapter(); wpTA.uspWallpaerResetActive(); wpTA.uspSelectWallpaperByID(Convert.ToInt32(gvWallpaper.DataKeys[index]["ID"].ToString())); UpdateGrid(); Preview(gvWallpaper.Rows[index].Cells[1].Text); StreamReader sr = new StreamReader(Server.MapPath("./css/preview.css")); StreamWriter sw = new StreamWriter(Server.MapPath("./css/mlb.css")); //Read the first line of text string line = sr.ReadLine(); while (line != null) { sw.WriteLine(line); line = sr.ReadLine(); } sr.Close(); sw.Close(); strScript = "window.open('/');"; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { UpdateGrid(); } else { if (Request.Form["uploadPost"] != null) { string[] filenames = Request.Form["filenames"].ToString().Split(',');//From the hidden values manually inserted in jquery.uploadify.v2.1.4.js dsWallpaperTableAdapters.wallpaperTableAdapter wpTA = new dsWallpaperTableAdapters.wallpaperTableAdapter(); dsWallpaper.wallpaperDataTable wpDT = wpTA.GetAllWallpaper(); foreach (string filename in filenames) { dsWallpaper.wallpaperRow wpRow = wpDT.NewwallpaperRow(); wpRow.Filename = filename; wpRow.DateUploaded = DateTime.Now; wpRow.Active = false; wpDT.AddwallpaperRow(wpRow); } wpTA.Update(wpDT); Response.Redirect("./wallpaper.aspx"); } } }
public static string CheckFileExists(string filename) { bool exist = false; string[] aFilenames = filename.Split(','); string badFilename = string.Empty; foreach (string f in aFilenames) { dsWallpaperTableAdapters.wallpaperTableAdapter wpTA = new dsWallpaperTableAdapters.wallpaperTableAdapter(); if (Convert.ToInt32(wpTA.uspGetWallpaperByFilename(f)) == 1) { exist = true; badFilename = f; break; } } if (exist) { return(badFilename); } else { return(""); } }
private void UpdateGrid() { dsWallpaperTableAdapters.wallpaperTableAdapter wpTA = new dsWallpaperTableAdapters.wallpaperTableAdapter(); dsWallpaper.wallpaperDataTable wpDT = new dsWallpaper.wallpaperDataTable(); wpDT = wpTA.GetAllWallpaper(); gvWallpaper.DataSource = wpDT; gvWallpaper.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //Reset the session variables to make it sense Session["legacyusersDT"] = null; dsWallpaperTableAdapters.wallpaperTableAdapter wpTA = new dsWallpaperTableAdapters.wallpaperTableAdapter(); dsWallpaper.wallpaperDataTable wpDT = wpTA.GetActiveWallpaper(); hlWallPaper.NavigateUrl = "./images/wallpaper/" + wpDT.Rows[0]["filename"].ToString(); imgWallpaper.ImageUrl = "./images/wallpaper/" + wpDT.Rows[0]["filename"].ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { dsWallpaperTableAdapters.wallpaperTableAdapter wpTA = new dsWallpaperTableAdapters.wallpaperTableAdapter(); dsWallpaper.wallpaperDataTable wpDT = wpTA.GetWallpaperByID(Convert.ToInt32(Request.QueryString["id"])); File.Delete(Server.MapPath("~/images/wallpaper/" + wpDT.Rows[0]["filename"].ToString())); wpTA.uspDeleteWallpaperByID(Convert.ToInt32(Request.QueryString["id"])); Response.Redirect("./wallpaper.aspx"); } }
protected void cvFileCheck_ServerValidate(object source, ServerValidateEventArgs args) { dsWallpaperTableAdapters.wallpaperTableAdapter wpTA = new dsWallpaperTableAdapters.wallpaperTableAdapter(); if (Convert.ToInt32(wpTA.uspGetWallpaperByFilename(FileUpload1.FileName)) > 0) { args.IsValid = false; } else { args.IsValid = true; } }
protected void btnUpload_Click(object sender, EventArgs e) { if (Page.IsValid) { string tempPath = Server.MapPath("~/images/wallpaper/" + FileUpload1.FileName); FileUpload1.SaveAs(tempPath); dsWallpaperTableAdapters.wallpaperTableAdapter wpTA = new dsWallpaperTableAdapters.wallpaperTableAdapter(); dsWallpaper.wallpaperDataTable wpDT = wpTA.GetAllWallpaper(); dsWallpaper.wallpaperRow wpRow = wpDT.NewwallpaperRow(); wpRow.Filename = FileUpload1.FileName; wpRow.DateUploaded = DateTime.Now; wpRow.Active = false; wpDT.AddwallpaperRow(wpRow); wpTA.Update(wpDT); Response.Redirect("./wallpaper.aspx"); } }