예제 #1
0
        public static string Update(tbl_DiscountGroup data)
        {
            using (var con = new inventorymanagementEntities())
            {
                var discount = con.tbl_DiscountGroup
                               .Where(a => a.ID == data.ID)
                               .FirstOrDefault();

                if (discount != null)
                {
                    discount.DiscountName             = data.DiscountName;
                    discount.DiscountAmount           = data.DiscountAmount;
                    discount.QuantityProduct          = data.QuantityProduct;
                    discount.DiscountAmountPercent    = data.DiscountAmountPercent;
                    discount.FeeRefund                = data.FeeRefund;
                    discount.NumOfDateToChangeProduct = data.NumOfDateToChangeProduct;
                    discount.NumOfProductCanChange    = data.NumOfProductCanChange;
                    discount.RefundQuantityNoFee      = data.RefundQuantityNoFee;
                    discount.DiscountNote             = data.DiscountNote;
                    discount.IsHidden         = data.IsHidden;
                    discount.ModifiedBy       = data.ModifiedBy;
                    discount.ModifiedDate     = data.ModifiedDate;
                    discount.PermittedRead    = data.PermittedRead;
                    discount.QuantityRequired = data.QuantityRequired;
                    int kq = con.SaveChanges();

                    return(kq.ToString());
                }
                else
                {
                    return(null);
                }
            }
        }
 public static string Update(int ID, string DiscountName, double DiscountAmount, double DiscountAmountPercent, string DiscountNote, bool IsHidden,
                             DateTime ModifiedDate, string ModifiedBy, double FeeRefund, double NumOfDateToChangeProduct, double NumOfProductCanChange)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_DiscountGroup ui = dbe.tbl_DiscountGroup.Where(a => a.ID == ID).SingleOrDefault();
         if (ui != null)
         {
             ui.DiscountName          = DiscountName;
             ui.DiscountAmount        = DiscountAmount;
             ui.DiscountAmountPercent = DiscountAmountPercent;
             ui.DiscountNote          = DiscountNote;
             ui.IsHidden  = IsHidden;
             ui.FeeRefund = FeeRefund;
             ui.NumOfDateToChangeProduct = NumOfDateToChangeProduct;
             ui.NumOfProductCanChange    = NumOfProductCanChange;
             ui.ModifiedBy   = ModifiedBy;
             ui.ModifiedDate = ModifiedDate;
             int kq = dbe.SaveChanges();
             return(kq.ToString());
         }
         else
         {
             return(null);
         }
     }
 }
예제 #3
0
        public static string Insert(tbl_DiscountGroup data)
        {
            using (var con = new inventorymanagementEntities())
            {
                con.tbl_DiscountGroup.Add(data);
                con.SaveChanges();

                return(data.ID.ToString());
            }
        }
 public static tbl_DiscountGroup GetByID(int ID)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_DiscountGroup ai = dbe.tbl_DiscountGroup.Where(a => a.ID == ID).FirstOrDefault();
         if (ai != null)
         {
             return(ai);
         }
         else
         {
             return(null);
         }
     }
 }
예제 #5
0
        protected void btnUpdateDiscountGroup_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    int id = ViewState["ID"].ToString().ToInt(0);
                    if (id > 0)
                    {
                        var now = DateTime.Now;

                        var data = new tbl_DiscountGroup()
                        {
                            ID                       = id,
                            DiscountName             = txtDiscountName.Text,
                            DiscountAmount           = pDiscountAmount.Value.HasValue ? pDiscountAmount.Value.Value : 0,
                            DiscountAmountPercent    = 0,
                            QuantityProduct          = pQuantityProduct.Value.HasValue ? Convert.ToInt32(pQuantityProduct.Value.Value) : 0,
                            FeeRefund                = rRefundGoods.Value.HasValue ? rRefundGoods.Value.Value : 0,
                            NumOfDateToChangeProduct = pNumOfDateToChangeProduct.Value.HasValue ? pNumOfDateToChangeProduct.Value.Value : 0,
                            NumOfProductCanChange    = pNumOfProductCanChange.Value.HasValue ? pNumOfProductCanChange.Value.Value : 0,
                            RefundQuantityNoFee      = pRefundQuantityNoFee.Value.HasValue ? Convert.ToInt32(pRefundQuantityNoFee.Value.Value) : 0,
                            DiscountNote             = pDiscountNote.Content,
                            IsHidden                 = chkIsHidden.Checked,
                            ModifiedBy               = username,
                            ModifiedDate             = now,
                            PermittedRead            = hdfPermittedRead.Value,
                            QuantityRequired         = pQuantityRequired.Value.HasValue ? Convert.ToInt32(pQuantityRequired.Value.Value) : 0,
                        };


                        var result = DiscountGroupController.Update(data);

                        if (!String.IsNullOrEmpty(result))
                        {
                            PJUtils.ShowMessageBoxSwAlert("Cập nhật nhóm khách hàng thành công", "s", true, Page);
                        }
                    }
                }
            }
        }
 public static string Insert(string DiscountName, double DiscountAmount, double DiscountAmountPercent, string DiscountNote, bool IsHidden,
                             DateTime CreatedDate, string CreatedBy, double FeeRefund, double NumOfDateToChangeProduct, double NumOfProductCanChange)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_DiscountGroup ui = new tbl_DiscountGroup();
         ui.DiscountName          = DiscountName;
         ui.DiscountAmount        = DiscountAmount;
         ui.DiscountAmountPercent = DiscountAmountPercent;
         ui.DiscountNote          = DiscountNote;
         ui.IsHidden    = IsHidden;
         ui.CreatedDate = CreatedDate;
         ui.CreatedBy   = CreatedBy;
         ui.FeeRefund   = FeeRefund;
         ui.NumOfDateToChangeProduct = NumOfDateToChangeProduct;
         ui.NumOfProductCanChange    = NumOfProductCanChange;
         dbe.tbl_DiscountGroup.Add(ui);
         dbe.SaveChanges();
         int kq = ui.ID;
         return(kq.ToString());
     }
 }
예제 #7
0
        protected void btnCreateDiscountGroup_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    var now  = DateTime.Now;
                    var data = new tbl_DiscountGroup()
                    {
                        DiscountName             = txtDiscountName.Text,
                        DiscountAmount           = pDiscountAmount.Value.HasValue ? pDiscountAmount.Value.Value : 0,
                        DiscountAmountPercent    = 0,
                        QuantityProduct          = pQuantityProduct.Value.HasValue ? Convert.ToInt32(pQuantityProduct.Value.Value) : 0,
                        FeeRefund                = rRefundGoods.Value.HasValue ? rRefundGoods.Value.Value : 0,
                        NumOfDateToChangeProduct = pNumOfDateToChangeProduct.Value.HasValue ? pNumOfDateToChangeProduct.Value.Value : 0,
                        NumOfProductCanChange    = pNumOfProductCanChange.Value.HasValue ? pNumOfProductCanChange.Value.Value : 0,
                        RefundQuantityNoFee      = pRefundQuantityNoFee.Value.HasValue ? Convert.ToInt32(pRefundQuantityNoFee.Value.Value) : 0,
                        DiscountNote             = pDiscountNote.Content,
                        IsHidden         = chkIsHidden.Checked,
                        CreatedBy        = username,
                        CreatedDate      = now,
                        ModifiedBy       = username,
                        ModifiedDate     = now,
                        PermittedRead    = hdfPermittedRead.Value,
                        QuantityRequired = pQuantityRequired.Value.HasValue ? Convert.ToInt32(pQuantityRequired.Value.Value) : 0
                    };

                    DiscountGroupController.Insert(data);

                    Response.Redirect("/danh-sach-nhom-khach-hang.aspx");
                    PJUtils.ShowMessageBoxSwAlert("Tạo mới thành công", "s", true, Page);
                }
            }
        }