Beispiel #1
0
        /// <summary>
        /// 新增-傳入 ViewModel 資料
        /// </summary>
        /// <param name="MoneyAdd"></param>
        public void Add(MoneyAddViewModels MoneyAdd)
        {
            var result = new AccountBook()
            {
                Categoryyy = MoneyAdd.Category,
                Amounttt   = MoneyAdd.Amount,
                Dateee     = MoneyAdd.BillingDate,
                Remarkkk   = MoneyAdd.Memo
            };

            Add(result);
        }
Beispiel #2
0
        /// <summary>
        /// 編輯
        /// </summary>
        /// <param name="MoneyAdd"></param>
        /// <param name="olddata"></param>
        public void Edit(MoneyAddViewModels MoneyAdd, AccountBook olddata)
        {
            var newdata = new AccountBook()
            {
                Id         = MoneyAdd.Id,
                Categoryyy = MoneyAdd.Category,
                Amounttt   = MoneyAdd.Amount,
                Dateee     = MoneyAdd.BillingDate,
                Remarkkk   = MoneyAdd.Memo
            };

            Edit(newdata, olddata);
        }
Beispiel #3
0
        /// <summary>
        /// 明細
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public MoneyAddViewModels Detail(AccountBook data)
        {
            var result = new MoneyAddViewModels()
            {
                Id          = data.Id,
                Category    = data.Categoryyy,
                Amount      = data.Amounttt,
                BillingDate = data.Dateee,
                Memo        = data.Remarkkk
            };

            return(result);
        }
Beispiel #4
0
        public ActionResult Edit([Bind(Include = "Id,Category,Amount,BillingDate,Memo")] MoneyAddViewModels MoneyAdd)
        {
            AccountBook olddata = _MoneyService.GetSingle(MoneyAdd.Id);

            if (olddata != null && ModelState.IsValid)
            {
                _MoneyService.Edit(MoneyAdd, olddata);
                _LogService.Add(olddata.Categoryyy, olddata.Amounttt, "EditBefore");
                _LogService.Add(MoneyAdd.Category, MoneyAdd.Amount, "EditAfter");
                _MoneyService.Save();
                return(RedirectToAction("List"));
            }
            return(View());
        }
        public ActionResult Add([Bind(Include = "Category,Amount,BillingDate,Memo")] MoneyAddViewModels MoneyAdd)
        {
            ViewData["CategoryList"] = new SelectList(DataDict.Category, "key", "value");

            if (ModelState.IsValid)
            {
                _MoneyService.Add(MoneyAdd);
                _LogService.Add(MoneyAdd.Category, MoneyAdd.Amount, "Add");
                _MoneyService.Save();

                //System.Threading.Thread.Sleep(3000);    //測試ajax
                //return View();
                return(PartialView("List", _MoneyService.GetDataEF())); //加入ajax
            }

            return(View());
        }