public MessageReport DeleteById(string id, ref BM_Apartment_Receipt obj)
        {
            var re = new MessageReport();

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

            try
            {
                obj = GetById(id);
                if (obj != null)
                {
                    obj.IsDeleted = true;
                    _BM_Apartment_ReceiptRepository.Update(obj);

                    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);
        }
예제 #2
0
        public JsonResult Delete(string id)
        {
            var obj = new BM_Apartment_Receipt();

            var result = _BM_Apartment_ReceiptService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Code, "BM_Apartment_Receipt", ConstField.ResidentCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult Update(BM_Apartment_Receipt obj, string key = "", int page = 1)
        {
            ViewBag.keyValue = key;
            ViewBag.PN       = page;

            //Kiểm tra
            var oldObj = _BM_Apartment_ReceiptService.GetById(obj.Id);

            if (oldObj == null)
            {
                ViewBag.Error = "Bản ghi không tồn tại";
                return(View(obj));
            }

            if (!ModelState.IsValid)
            {
                return(View(oldObj));
            }

            //Gán giá trị
            oldObj.Code          = obj.Code;
            oldObj.Title         = obj.Title;
            oldObj.Description   = obj.Description;
            oldObj.UserCreatedId = obj.UserCreatedId;
            oldObj.DatePaid      = obj.DatePaid;
            oldObj.ApartmentId   = obj.ApartmentId;
            oldObj.ResidentId    = obj.ResidentId;
            oldObj.PayerName     = obj.PayerName;
            oldObj.PayerMobile   = obj.PayerMobile;
            oldObj.UserId        = obj.UserId;
            oldObj.Money         = obj.Money;
            oldObj.PayType       = obj.PayType;
            oldObj.Type          = obj.Type;
            oldObj.Status        = obj.Status;
            oldObj.Note          = obj.Note;

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Code, "BM_Apartment_Receipt", ConstField.ResidentCode, ActionConfigO.Update);

                return(RedirectToAction("Index", new { page = page, key = key }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }
예제 #4
0
        public ActionResult Create(BM_Apartment_Receipt obj, bool SaveAndCountinue = false, string key = "")
        {
            ViewBag.keyValue = key;

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


            //Gán giá trị
            obj.Id          = Guid.NewGuid().ToString();
            obj.DateCreated = DateTime.UtcNow;
            obj.IsDeleted   = false;

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Code, "BM_Apartment_Receipt", ConstField.ResidentCode, ActionConfigO.Create);

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

                return(RedirectToAction("Index", new { key = key }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(obj));
            }
        }
        public MessageReport Create(BM_Apartment_Receipt obj)
        {
            var re = new MessageReport();

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

            try
            {
                _BM_Apartment_ReceiptRepository.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);
        }