コード例 #1
0
        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();
        }
コード例 #2
0
 protected void btn_coupon_Click(object sender, EventArgs e)
 {
     CouponFactory.CouponFactory cf = new CouponFactory.CouponFactory();
     Coupon newCoupon = cf.makeNewCoupon("Social Network");
     //retrieve all data and save to database
 }