protected void btnUpdate_Click(object sender, EventArgs e) { u.Email = tbEmail.Text; Membership.UpdateUser(u); Int32 day = Int32.Parse(ddlDay.SelectedValue); Int32 month = Int32.Parse(ddlMonth.SelectedValue); Int32 year = Int32.Parse(ddlYear.SelectedValue); Int32 Age = DateTime.Now.Year - year; DateTime DOB = new DateTime(year, month, day); if (artist != null) { artist.ContactNo = tbContact.Text; artist.Name = tbName.Text; artist.Address = tbAddress.Text; artist.Age = Age; artist.DateOfBirth = DOB; _db.ARTISTs.Attach(artist); _db.Entry(artist).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else { customer.ContactNo = tbContact.Text; customer.Name = tbName.Text; customer.Address = tbAddress.Text; customer.Age = Age; customer.DateOfBirth = DOB; _db.CUSTOMERs.Attach(customer); _db.Entry(customer).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } Response.Redirect("~/UpdateProfile.aspx"); }
protected void btnAddToCart_Click(object sender, EventArgs e) { //Get the reference of the clicked button. Button button = (sender as Button); //Get the command argument string[] commandArgument = button.CommandArgument.ToString().Split(';'); int wishlistId = Convert.ToInt32(commandArgument[0]); int productId = Convert.ToInt32(commandArgument[1]); //System.Diagnostics.Debug.WriteLine(wishlistId + "," + productId); ShoppingCart sc = new ShoppingCart(); sc.AddToCart(productId); GalleryEntities1 db = new GalleryEntities1(); var item = new WISHLIST { WishlistId = wishlistId }; db.Entry(item).State = EntityState.Deleted; try { db.SaveChanges(); Response.Redirect("~/Wishlistaspx.aspx"); } catch (DbUpdateConcurrencyException) { ModelState.AddModelError("", String.Format("Item with id {0} no longer exists in the database.", wishlistId)); } }
protected void DeleteButton_Click(object sender, ImageClickEventArgs e) { //Get the reference of the clicked button. ImageButton button = (sender as ImageButton); //Get the command argument string commandArgument = button.CommandArgument; int wishlistid = int.Parse(commandArgument); GalleryEntities1 db = new GalleryEntities1(); var item = new WISHLIST { WishlistId = wishlistid }; db.Entry(item).State = EntityState.Deleted; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { ModelState.AddModelError("", String.Format("Item with id {0} no longer exists in the database.", wishlistid)); } }