protected void AddBtn_Click(object sender, EventArgs e) { if (Prod_ImgValidation.IsValid && NameValidator.IsValid && DescValidator.IsValid && QtyEmptyValidator.IsValid && QtyValidator.IsValid && PriceEmptyValidator.IsValid && PriceValidator.IsValid) { Product p = new Product { Id = Security.GenerateNewID('P'), Name = Name.Text, Description = LineBreaksConvert.LineBreaksTextToDB(Description.Text), Quantity = int.Parse(Qty.Text), Price = decimal.Parse(Price.Text), Active = true, Seller_Id = UserInfo.Id }; Global.db.Products.InsertOnSubmit(p); Global.db.SubmitChanges(); var path = MapPath("~/Broadcaster/Product_Image/"); var img = new SimpleImage(Img_File.FileContent); img.SaveAs(path + p.Id + ".jpg"); Response.RedirectPermanent("~/Broadcaster/ProductInfo.aspx?id=" + p.Id); } }
protected void btnUpload_Click(object sender, EventArgs e) { if (Page.IsValid) { int randomId = 0; Random random = new Random(); bool repeatId = false; var path = MapPath("~/pic/slideshow/"); do { randomId = random.Next(10000, 9999999); var pro = db.slideshows.SingleOrDefault( b => b.S_Id == randomId); if (pro == null) { repeatId = true; } } while (repeatId == false); var img = new SimpleImage(fuPicture.FileContent); img.SaveAs(path + randomId + ".jpg"); slideshow s = new slideshow { S_Id = randomId, S_Title = txtTitle.Text, S_link = txtLink.Text }; db.slideshows.InsertOnSubmit(s); db.SubmitChanges(); } }
protected void btnRegister_Click(object sender, EventArgs e) { if (Page.IsValid) { string email = txtEmail.Text; admin f = db.admins.SingleOrDefault(x => x.A_email == email); if (f != null) { int id = f.A_Id; var path = MapPath("~/pic/profile/"); string password = txtPassword.Text; if (fuImage.HasFile) { File.Delete(path + id + ".jpg"); var img = new SimpleImage(fuImage.FileContent); img.SaveAs(path + id + ".jpg"); } f.A_Nickname = txtname.Text; f.A_hash = Security.GetHash(password); //f.A_email = email; f.A_gender = Char.Parse(rblGender.SelectedValue); db.SubmitChanges(); } ; Response.Redirect("../home.aspx"); } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (Page.IsValid) { string email = txtEmail.Text; ComicCreator f = db.ComicCreators.SingleOrDefault(x => x.CC_email == email); if (f != null) { int id = f.CC_Id; string name = txtname.Text; string password = txtPassword.Text; var path = MapPath("~/pic/profile/"); string phone = txtPhoneNumber.Text; int n = Convert.ToInt32(phone); if (fuImage.HasFile) { File.Delete(path + id + ".jpg"); var img = new SimpleImage(fuImage.FileContent); img.SaveAs(path + id + ".jpg"); } f.CC_NickName = txtname.Text; f.CC_hash = Security.GetHash(password); //f.CC_email = email; f.CC_phone = phone; db.SubmitChanges(); } ; Response.Redirect("~/home.aspx"); } }
protected void btnAdd_Click(object sender, EventArgs e) { int randomId; Random random = new Random(); bool repeatId = false; string email = HttpContext.Current.User.Identity.Name; ComicCreator f = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email); int id = f.CC_Id; if (Page.IsValid) { do { randomId = random.Next(100000, 99999999); var b = db.Comics.SingleOrDefault( cc => cc.C_Id == randomId); if (b == null) { repeatId = true; } } while (repeatId == false); string p = "~/pic/comic/" + randomId + "/"; var folder = Server.MapPath(p); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var img = new SimpleImage(fuImage.FileContent); img.SaveAs(folder + randomId + ".jpg"); Comic c = new Comic { C_Id = randomId, C_Title = txtTitle.Text, C_Description = txtDescription.Text, C_Price = decimal.Parse(txtPrice.Text), C_Publish_Date = DateTime.Now, C_Status = 'U', C_category = ddlCategory.SelectedValue, C_AgeRestrict = int.Parse(ddlAgeRestrt.SelectedValue), C_IsForVip = bool.Parse(rblVipView.SelectedValue), CC_Id = id }; db.Comics.InsertOnSubmit(c); db.SubmitChanges(); Response.Redirect("~/Comic.aspx"); } }
protected void btnInsert_Click(object sender, EventArgs e) { string foodname = txtfood.Text; decimal foodprice = decimal.Parse(txtfoodprice.Text); string id; int randomId; bool repeatId = false; Random random = new Random(); string path = MapPath("~/Photos/"); string filename = Guid.NewGuid().ToString("N") + ".jpeg"; do { randomId = random.Next(10000, 999999); id = "F" + randomId; var p = OneDB.Food_Lists.SingleOrDefault( b => b.foodID == id); if (p == null) { repeatId = true; } } while (repeatId == false); var img = new SimpleImage(FileUpload1.FileContent); img.Square(); img.Resize(150); img.SaveAs(path + filename); Food_List fl = new Food_List { foodID = id, foodName = foodname, foodPrice = foodprice, foodPhoto = filename, foodStatus = "available" }; OneDB.Food_Lists.InsertOnSubmit(fl); OneDB.SubmitChanges(); displaystatus.Text = "The food has been added to food menu"; }
protected void btnUpdate_Click(object sender, EventArgs e) { string email = HttpContext.Current.User.Identity.Name; ComicCreator f = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email); string cid = Request.QueryString["cId"]; if (Page.IsValid) { if (!string.IsNullOrEmpty(cid)) { int cId = Int32.Parse(cid); string p = "~/pic/comic/" + cid + "/"; var folder = Server.MapPath(p); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } if (fuImage.HasFile) { File.Delete(folder + cid + ".jpg"); var img = new SimpleImage(fuImage.FileContent); img.SaveAs(folder + cid + ".jpg"); } Comic c = db.Comics.SingleOrDefault(a => a.C_Id == cId); c.C_Title = txtTitle.Text; c.C_Description = txtDescription.Text; c.C_Price = decimal.Parse(txtPrice.Text); c.C_category = ddlCategory.SelectedValue; c.C_AgeRestrict = Int32.Parse(ddlAgeRestrt.SelectedValue); c.C_IsForVip = bool.Parse(rblVipView.SelectedValue); db.SubmitChanges(); Response.Redirect("~/DisplayComic.aspx?cId=" + cid); } else { Response.Redirect("~/error.aspx?err=The result cant be found"); //redirect to the error page } } }