public async Task<AddUpdateCheckBankStatus> UpdateAsync(CheckBank checkBank) { var old = await FindByNumber(checkBank.Number); if (old?.Id != checkBank.Id) return AddUpdateCheckBankStatus.DuplicateCheckNumber; if (checkBank.ExpiredDateTime < checkBank.ReceiptDateTime) return AddUpdateCheckBankStatus.InvalidDates; if (checkBank.Value < 1) return AddUpdateCheckBankStatus.InvalidValue; return AddUpdateCheckBankStatus.Success; }
protected override DataGridViewRow FillRow(CheckBank entity, DataGridViewRow rowToAdd) { rowToAdd.Cells.Add(new DataGridViewTextBoxCell { Value = entity.ReceiptDateTime.ToPersianDateString() }); rowToAdd.Cells.Add(new DataGridViewTextBoxCell { Value = entity.Value.ToString("##,###") }); rowToAdd.Cells.Add(new DataGridViewTextBoxCell { Value = entity.Number }); rowToAdd.Cells.Add(new DataGridViewTextBoxCell { Value = entity.BankInfo }); rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.Person.Name}); rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.ExpiredDateTime.ToPersianDateString()}); rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.CashDateTime?.ToPersianDateString() ?? "وصول نشده"}); rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.Comment}); rowToAdd.Tag = entity; return rowToAdd; }
public async Task<AddUpdateCheckBankStatus> AddAsync(CheckBank checkBank) { if (await IsExistByNumber(checkBank.Number)) return AddUpdateCheckBankStatus.DuplicateCheckNumber; if (checkBank.ExpiredDateTime < checkBank.ReceiptDateTime) return AddUpdateCheckBankStatus.InvalidDates; if (checkBank.Value < 1) return AddUpdateCheckBankStatus.InvalidValue; _checkBanks.Add(checkBank); return AddUpdateCheckBankStatus.Success; }
protected override void OnSaveButtonClicked() { if (_result.Person == null) { SetError(personCombo, "Cannot leave empty."); return; } var entity = new CheckBank { Person = _result.Person, Number = numberBox.Text, BankInfo = bankNameCombo.Text, Value = valueNum.Value, Comment = commentBox.Text, ReceiptDateTime = recieptDatePicker.Date, ExpiredDateTime = expiredDatePicker.Date, CashDateTime = null, }; if (!Validation(entity)) return; var old = _repository.FirstOrDefault(x => x.Id == _result.Id); if (old == null) { _repository.Add(entity); } else { old.Person = _result.Person; old.Number = numberBox.Text; old.BankInfo = bankNameCombo.Text; old.Value = valueNum.Value; old.Comment = commentBox.Text; old.ReceiptDateTime = recieptDatePicker.Date; old.ExpiredDateTime = expiredDatePicker.Date; } SaveAndExit(); }