public void Edit(AccountBook old, AccountBook newAccountBook) { old.Categoryyy = newAccountBook.Categoryyy; old.Amounttt = newAccountBook.Amounttt; old.Dateee = newAccountBook.Dateee; old.Remarkkk = newAccountBook.Remarkkk; }
public ActionResult AddForAjax(AccountingViewModel pageData) { if (!ModelState.IsValid) { var errorFields = ModelState.Where(d => d.Value.Errors.Any()) .Select(x => new { x.Key, x.Value.Errors }); var errors = new List <AjaxErrorResultViewModel>(); foreach (var item in errorFields) { errors.Add(item.Errors.Select( d => new AjaxErrorResultViewModel() { ClientId = item.Key, ErrorMessage = d.ErrorMessage }).FirstOrDefault()); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(errors)); } var accountBook = new AccountBook { Amounttt = pageData.Amount, Categoryyy = (int)pageData.Type, Dateee = pageData.Date, Remarkkk = pageData.Remark, Id = Guid.NewGuid() }; this.accountDbContext.AccountBook.Add(accountBook); this.accountDbContext.SaveChanges(); return(PartialView("ShowHistory", this.GetLastAccountings(10))); }
public void Add(AccountBook model) { var repo = uow.Get <IRepository <AccountBook> >(); model.Id = Guid.NewGuid(); repo.Create(model); }
/// <summary> /// 添加数据 /// </summary> private JsonResult Create(AccountBook model) { SystemResult result = new SystemResult(); model.Id = Guid.NewGuid(); model.CreateTime = DateTime.Now; model.DataState = model.DataState ?? 0; try { if (_accountBookService.Insert(model)) { result.isSuccess = true; } else { result.isSuccess = false; result.message = "新增失败"; } } catch (Exception ex) { result.isSuccess = false; result.message = ex.Message; } return(BackData(result)); }
public bool WtrieData(BoughtItem obj) { AccountBook result; int amounttt; DateTime dateee; if (int.TryParse(obj.Price.ToString(), out amounttt) && String.IsNullOrWhiteSpace(obj.ItemCategory) == false && DateTime.TryParseExact(obj.ItemDate, "yyyy-MM-dd", DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None, out dateee) && String.IsNullOrWhiteSpace(obj.Remark) == false) { result = new AccountBook() { Categoryyy = obj.ItemCategory == "支出" ? 0 : 1, Amounttt = amounttt, Dateee = dateee, Remarkkk = obj.Remark }; if (accountBookRes.WriteData(result)) { __hmw.SaveChanges(); return(true); } } return(false); }
public void ThreadFileCheck(AccountBook f) { while (true) { if (f.InvokeRequired) { f.Invoke(new Action(delegate() { if (FileCompare(f)) { _view.nGrid.Rows.Clear(); FileGridOutput(_view.FilePath, _view.nGrid); File2 = new FileStream(f.FilePath, FileMode.Open); file2 = new byte[File2.Length]; File2.Read(file2, 0, file2.Length); File2.Close(); f.Refresh(); } })); Thread.Sleep(300); } } }
public ActionResult AjaxAction(TrackSpendingViewModel2 viewModel2) { if (ModelState.IsValid) { if (viewModel2.Id == Guid.Empty) { //create var accountBook = new AccountBook() { Amounttt = viewModel2.Amounttt, Categoryyy = viewModel2.Categoryyy, Dateee = viewModel2.Dateee, Remarkkk = viewModel2.Remarkkk }; _trackSpendingService.Add(accountBook); _trackSpendingService.Save(); return(View("ForIndexChild", _trackSpendingService.GetAll())); } else { //edit _trackSpendingService.Edit(viewModel2); _trackSpendingService.Save(); return(View("ForIndexChild", _trackSpendingService.GetAll())); } } return(View("ForIndexChild")); }
public void AddAccountBook(AccountBook entity) { SkillTreeHomeworkEntities1 _dbcontext = new SkillTreeHomeworkEntities1(); _dbcontext.AccountBook.Add(entity); _dbcontext.SaveChanges(); }
public bool ValidVoucher(VoucherViewModel voucher, out string err) { err = string.Empty; //账期校验 AccountBook accBook = _accountBook.GetCurrentBook(); if (accBook.StartYear < voucher.VoucherDate.Year || (accBook.StartYear == voucher.VoucherDate.Year && accBook.StartPeriod > voucher.VoucherDate.Month)) { err = "凭证日期无效"; return(false); } //验证凭证字号 int maxSn = _voucher.GetMaxCertWordSn(voucher.VoucherDate, voucher.CwId); if (maxSn + 1 != voucher.CertWordSN) { voucher.CertWordSN = maxSn + 1; } //验证账是否平 err = _voucher.IsVoucherBalance(voucher); return(err == string.Empty ? true : false); }
public ActionResult EditRecord(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Guid deleteGuid = new Guid(); Guid.TryParse(id, out deleteGuid); AccountBook accountBook = db.AccountBook.Find(deleteGuid); if (accountBook == null) { return(HttpNotFound()); } AssetViewModel avm = new AssetViewModel(); avm.Category = accountBook.Categoryyy; avm.Money = accountBook.Amounttt; avm.Date = accountBook.Dateee; avm.Description = accountBook.Remarkkk; return(View(avm)); }
public void Edit(AccountBook accountBook) { var oldData = _MoneyDb.AccountBook.Find(accountBook.Id); _MoneyDb.Entry(oldData).CurrentValues.SetValues(accountBook); _MoneyDb.SaveChanges(); }
public ActionResult Add(AccountBookViewModel model) { try { if (!ModelState.IsValid) { return(Json(new { success = false, errors = ModelState.Keys.SelectMany(k => ModelState[k].Errors) .Select(m => m.ErrorMessage).ToArray() })); } var addModel = new AccountBook() { Amounttt = (int)model.Amounttt, Categoryyy = (int)model.Categoryyy, Dateee = (DateTime)model.Dateee, Remarkkk = model.Remarkkk, Id = Guid.NewGuid() }; Instance.AccountBooks.Add(addModel); Instance.SaveChanges(); MemoryCache.Default.Remove("listBooks"); return(Json(new { success = true, pageIndex = model.PageIndex })); } catch (DbEntityValidationException ex) { Helpers.GetDbError(ex); return(Json(new { success = false })); } }
public void Edit(AccountBook pageData, AccountBook oldData) { oldData.Dateee = pageData.Dateee; oldData.Categoryyy = pageData.Categoryyy; oldData.Amounttt = pageData.Amounttt; oldData.Remarkkk = pageData.Remarkkk; }
/// <summary> /// 更新-EF-DB /// </summary> /// <param name="newdata"></param> /// <param name="olddata"></param> public void Edit(AccountBook newdata, AccountBook olddata) { olddata.Categoryyy = newdata.Categoryyy; olddata.Amounttt = newdata.Amounttt; olddata.Dateee = newdata.Dateee; olddata.Remarkkk = newdata.Remarkkk; }
public void editAccountData(MyAccountViewModels modifyAccountData, AccountBook accountData) { accountData.Amounttt = decimal.ToInt32(modifyAccountData.myMoney); accountData.Categoryyy = modifyAccountData.category == "支出" ? 0 : 1; accountData.Dateee = modifyAccountData.date; accountData.Remarkkk = modifyAccountData.memo; }
public ActionResult Create(BookingsViewModels model) { try { // TODO: Add insert logic here if (ModelState.IsValid) { AccountBook acct = new AccountBook() { Id = Guid.NewGuid(), Categoryyy = Convert.ToInt32(model.BookType), Amounttt = model.BookAmount, Dateee = model.BookDate, Remarkkk = model.BookMemo }; AccountBookService.AddData(acct); AccountBookService.Save(); return(RedirectToAction("Index")); } return(View(model)); } catch { return(View()); } }
public override global::System.Data.DataSet Clone() { AccountBook cln = ((AccountBook)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public ActionResult DeleteConfirmed(Guid id) { AccountBook accountBook = _service.GetSingleAccountBook(id); _service.Delete(accountBook); _unitOfWork.Commit(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(Guid id) { AccountBook accountBook = db.AccountBook.Find(id); db.AccountBook.Remove(accountBook); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(AccountBook accountbook) { if (ModelState.IsValid) { data.SaveChanges(accountbook); } return(RedirectToAction("Index")); }
static void TestLoad() { AccountBook book = new AccountBook(); //book.LoadFromFile(); //book.LoadFromFile_Stream(); book.LoadFile(); book.PrintAll(); }
public void EditData(DailyAccountViewModel dailyAccountViewModel) { AccountBook accountBook = _accountBookRepository.Query(x => x.Id == dailyAccountViewModel.Id).FirstOrDefault(); accountBook.Amounttt = dailyAccountViewModel.Money; accountBook.Dateee = dailyAccountViewModel.Date; accountBook.Remarkkk = dailyAccountViewModel.Description; accountBook.Categoryyy = dailyAccountViewModel.CategoryID; }
public ActionResult Edit([Bind(Include = "Id,Categoryyy,Amounttt,Dateee,Remarkkk")] AccountBook accountBook) { if (ModelState.IsValid) { db.Entry(accountBook).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(accountBook)); }
public void Delete(Guid id) { var entity = new AccountBook() { Id = id }; this.AccountBook.Attach(entity); this.AccountBook.Remove(entity); }
public ActionResult Edit(AccountBook accountBook) { if (ModelState.IsValid) { BookKeepingService.Update(accountBook); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Detail(Guid?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AccountBook data = _MoneyService.GetSingle(Id.Value); return(View(_MoneyService.Detail(data))); }
public void Create(BookingViewModels booking) { var thisbooking = new AccountBook(); thisbooking.Id = Guid.NewGuid(); thisbooking.Amounttt = booking.Amount; thisbooking.Categoryyy = (int)booking.Kind; thisbooking.Dateee = Convert.ToDateTime(booking.Date); thisbooking.Remarkkk = booking.Remark; accountBookRepository.Create(thisbooking); }
public ActionResult Edit(Guid?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AccountBook data = _MoneyService.GetSingle(Id.Value); ViewData["CategoryList"] = new SelectList(DataDict.Category, "key", "value"); return(View(_MoneyService.Detail(data))); }
private AccountingViewModel MapAccoutBookToAccountingViewModel(AccountBook accountBook) { return(new AccountingViewModel { Amount = accountBook.Amounttt, Date = accountBook.Dateee, Remark = accountBook.Remarkkk, Type = (AccountingType)accountBook.Categoryyy, Id = accountBook.Id }); }
private void addNewRecord(IndexViewModel model) { AccountBook acBook = new AccountBook(); acBook.Id = Guid.NewGuid(); acBook.Amounttt = model.Book.Money; acBook.Categoryyy = model.Book.Kind; acBook.Dateee = model.Book.Date; acBook.Remarkkk = model.Book.Description; _srv.AddAccountBook(acBook); }