/// <summary>
        /// Tính tiền / ngày
        /// </summary>
        /// <param name="objFee"></param>
        /// <returns></returns>
        int GetPriceOfDay(tblFee objFee)
        {
            var price = 0;

            if (objFee != null)
            {
                var arrUnit = objFee.Units.Split('_');
                switch (arrUnit[1].ToString())
                {
                case "Ngày":
                    price = objFee.FeeLevel / Convert.ToInt32(arrUnit[0]);
                    break;

                case "Tháng":
                    price = objFee.FeeLevel / (Convert.ToInt32(arrUnit[0]) * 30);
                    break;

                case "Quý":
                    price = objFee.FeeLevel / (Convert.ToInt32(arrUnit[0]) * 90);
                    break;

                case "Năm":
                    price = objFee.FeeLevel / (Convert.ToInt32(arrUnit[0]) * 365);
                    break;
                }
            }

            return(price);
        }
Пример #2
0
        public MessageReport DeleteById(int id, ref tblFee obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(id);
                if (obj != null)
                {
                    _tblFeeRepository.Delete(n => n.FeeID == id);

                    Save();

                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
Пример #3
0
        /// <summary>
        /// Xóa
        /// </summary>
        /// <modified>
        /// Author                  Date            Comments
        /// TrungNQ                 18/09/2017      Tạo mới
        /// </modified>
        /// <param name="id">Id bản ghi</param>
        /// <returns></returns>
        public JsonResult Delete(string id)
        {
            var obj = new tblFee();

            var result = _tblFeeService.DeleteById(Convert.ToInt32(id), ref obj);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "FeeID,FeeCode,FeeAmount")] tblFee tblFee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblFee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblFee));
 }
Пример #5
0
        // GET: Fee/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblFee tblFee = db.tblFees.Find(id);

            if (tblFee == null)
            {
                return(HttpNotFound());
            }
            return(View(tblFee));
        }
Пример #6
0
        public MessageReport Create(tblFee obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                _tblFeeRepository.Add(obj);

                Save();

                re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["addSuccess"];;
                re.isSuccess = true;
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
Пример #7
0
        public ActionResult Update(tblFee obj, string txtFeeLevel, string objId, string unit = "", string period = "", int pageNumber = 1)
        {
            //Danh sách sử dụng
            ViewBag.CardGroups      = GetCardGroupList();
            ViewBag.TimePeriodTypes = GetTimeList();
            ViewBag.PN = pageNumber;


            //Kiểm tra
            var oldObj = _tblFeeService.GetById(Convert.ToInt32(objId));

            if (oldObj == null)
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["card_does_not_exist_in_the_system"];
                return(View(obj));
            }

            //
            if (string.IsNullOrWhiteSpace(obj.FeeName))
            {
                ModelState.AddModelError("FeeName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["enter_name"]);
                return(View(oldObj));
            }

            var existed = _tblFeeService.GetByName_Id(obj.FeeName, Convert.ToInt32(objId));;

            if (existed != null)
            {
                ModelState.AddModelError("FeeName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["exists_name"]);
                return(View(oldObj));
            }

            //Gán giá trị
            oldObj.CardGroupID = obj.CardGroupID;
            oldObj.FeeName     = obj.FeeName;
            oldObj.IsUseExtend = obj.IsUseExtend;
            //oldObj.Units = obj.Units;

            if (!string.IsNullOrWhiteSpace(txtFeeLevel))
            {
                txtFeeLevel     = txtFeeLevel.Replace(".", "");
                oldObj.FeeLevel = Convert.ToInt32(txtFeeLevel);
            }

            if (!string.IsNullOrWhiteSpace(unit) && !string.IsNullOrWhiteSpace(period))
            {
                oldObj.Units = $"{unit}_{period}";
            }

            //Thực hiện cập nhật
            var result = _tblFeeService.Update(oldObj);

            if (result.isSuccess)
            {
                objId = oldObj.FeeID.ToString();

                if (!string.IsNullOrEmpty(url))
                {
                    return(Redirect(url));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }
Пример #8
0
        public ActionResult Create(tblFee obj, string txtFeeLevel = "", string unit = "", string period = "", bool SaveAndCountinue = false)
        {
            //Danh sách sử dụng
            ViewBag.CardGroups      = GetCardGroupList();
            ViewBag.TimePeriodTypes = GetTimeList();

            //Kiểm tra
            if (!ModelState.IsValid)
            {
                return(View(obj));
            }

            //
            if (string.IsNullOrWhiteSpace(obj.FeeName))
            {
                ModelState.AddModelError("FeeName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["enter_name"]);
                return(View(obj));
            }

            var existed = _tblFeeService.GetByName(obj.FeeName);

            if (existed != null)
            {
                ModelState.AddModelError("FeeName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["exists_name"]);
                return(View(obj));
            }

            //Gán giá trịs

            if (!string.IsNullOrWhiteSpace(txtFeeLevel))
            {
                txtFeeLevel  = txtFeeLevel.Replace(".", "");
                obj.FeeLevel = Convert.ToInt32(txtFeeLevel);
            }

            if (!string.IsNullOrWhiteSpace(unit) && !string.IsNullOrWhiteSpace(period))
            {
                obj.Units = $"{unit}_{period}";
            }

            //Thực hiện thêm mới
            var result = _tblFeeService.Create(obj);

            if (result.isSuccess)
            {
                if (SaveAndCountinue)
                {
                    TempData["Success"] = result.Message;
                    return(RedirectToAction("Create"));
                }

                if (!string.IsNullOrEmpty(url))
                {
                    return(Redirect(url));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(obj));
            }
        }