public void Edit(PRODUCT_PROMOTION item)
 {
     using (var ctx = new SPWEntities())
     {
         if (item.Action == ActionEnum.Update)
         {
             var obj = ctx.PRODUCT_PROMOTION.Where(x => x.PROMOTION_ID == item.PROMOTION_ID).FirstOrDefault();
             if (obj != null)
             {
                 obj.PRODUCT_CONDITION_QTY = item.PRODUCT_CONDITION_QTY;
                 obj.PRODUCT_FREE_QTY = item.PRODUCT_FREE_QTY;
                 obj.ZONE_ID = item.ZONE_ID;
                 obj.UPDATE_DATE = item.UPDATE_DATE;
                 obj.UPDATE_EMPLOYEE_ID = item.UPDATE_EMPLOYEE_ID;
             }
         }
         ctx.SaveChanges();
     }
 }
 public ProductPromotionService(PRODUCT_PROMOTION item)
 {
     _item = item;
 }
Exemple #3
0
 protected void btnAddPromotion_Click(object sender, EventArgs e)
 {
     if (ViewState["PromotionId"] != null)
     {
         var cmd = new ProductPromotionService();
         PRODUCT_PROMOTION item = new PRODUCT_PROMOTION();
         item.PROMOTION_ID = Convert.ToInt32(ViewState["PromotionId"].ToString());
         item.PRODUCT_CONDITION_QTY = Convert.ToInt32(txtQty.Text);
         item.PRODUCT_FREE_QTY = Convert.ToInt32(txtFreeQty.Text);
         item.ZONE_ID = Convert.ToInt32(ddlZonePromotion.SelectedValue);
         item.UPDATE_DATE = DateTime.Now;
         item.UPDATE_EMPLOYEE_ID = 0;
         cmd.Edit(item);
     }
     else
     {
         var cmdZonePromotion = new ZoneService();
         PRODUCT_PROMOTION item = new PRODUCT_PROMOTION();
         item.Action = ActionEnum.Create;
         item.PRODUCT_CONDITION_QTY = Convert.ToInt32(txtQty.Text);
         item.PRODUCT_FREE_QTY = Convert.ToInt32(txtFreeQty.Text);
         item.ZONE_ID = Convert.ToInt32(ddlZonePromotion.SelectedValue);
         item.CREATE_DATE = DateTime.Now;
         item.CREATE_EMPLOYEE_ID = 0;
         item.UPDATE_DATE = DateTime.Now;
         item.UPDATE_EMPLOYEE_ID = 0;
         item.SYE_DEL = true;
         listPromotion.Add(item);
     }
     InitialDataPopup();
     this.popup.Show();
 }