protected void createCoupon_Click(object sender, EventArgs e) { //Create Coupon according to its type Coupon newCoupon = new Coupon(); CouponFactory.CouponFactory cf = new CouponFactory.CouponFactory(); string type = couponType_dropDownList.SelectedValue; /* if (type.Equals("Social Network")) newCoupon = cf.makeNewCoupon(type); else newCoupon = cf.makeNewCoupon("Regular"); */ //Retreive other information and save it in the database int disPrice = Int32.Parse(dis_price.Text); newCoupon.DiscountPrice = disPrice; int orgPrice = Int32.Parse(org_price.Text); newCoupon.OriginalPrice = orgPrice; string desc = description.Text; newCoupon.Description = desc; //category int categoryid = Int32.Parse(category_dropDownList.SelectedValue); newCoupon.CategoryID = categoryid; string name = name_txt.Text; newCoupon.Name = name; int busID = Int32.Parse(business_dropDownList.SelectedValue); DateTime lastUse = DateTime.Parse(last_Use.Text); newCoupon.LastUseDate = lastUse; couponsEntities ce = new couponsEntities(); newCoupon.BusinessID = busID; ce.Coupons.Add(newCoupon); ce.SaveChanges(); }
protected void submit_edit_Click(object sender, EventArgs e) { couponsEntities ce = new couponsEntities(); Business b = ce.Businesses.Find(Int32.Parse(Label6.Text.Substring(4))); b.Name = txt_Name.Text; b.Description = txt_Description.Text; b.Address = txt_Address.Text; b.City = txt_City.Text; editBusinessDiv.Visible = false; ce.Entry(b).State = System.Data.Entity.EntityState.Modified; //check!!!! ce.SaveChanges(); }
protected void submit_edit_Click(object sender, EventArgs e) { couponsEntities ce = new couponsEntities(); Coupon c = ce.Coupons.Find(Int32.Parse(Label8.Text.Substring(4))); c.Name = txt_Name.Text; c.Type = Convert.ToInt32(txt_Type.Text); c.OriginalPrice = Convert.ToInt32(txt_OriginalPrice.Text); c.DiscountPrice = Convert.ToInt32(txt_DiscountPrice.Text); c.Description = txt_Description.Text; editCouponDiv.Visible = false; ce.Entry(c).State = System.Data.Entity.EntityState.Modified; //check!!!! ce.SaveChanges(); }
protected void btn_Submit_Click(object sender, EventArgs e) { Business b = new Business(); b.Name = txt_name.Text; b.Address = txt_Address.Text; b.City = txt_city.Text; b.Description = txt_description.Text; b.Long = Convert.ToDouble(txt_long.Text); b.Lat = Convert.ToDouble(txt_Lat.Text); //business manager couponsEntities ce = new couponsEntities(); ce.Businesses.Add(b); ce.SaveChanges(); }