protected override DataGridViewRow FillRow(Transfer entity, DataGridViewRow rowToAdd)
        {
            _sumMoneyTransfer += entity.Money*(entity.IsBestankar ? 1M : -1M);

            rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.DateTime.ToPersianDateString()});
            rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.Comment});
            rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.BillNumber});

            rowToAdd.Cells.Add(new DataGridViewTextBoxCell
            {
                Value =
                    entity.IsBestankar
                        ? "-"
                        : entity.Money.ToString("C0")
                            .Replace(CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol, "")
            });
            rowToAdd.Cells.Add(new DataGridViewTextBoxCell
            {
                Value =
                    !entity.IsBestankar
                        ? "-"
                        : entity.Money.ToString("C0")
                            .Replace(CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol, "")
            });

            var vaz = _sumMoneyTransfer > 0 ? "بس" : _sumMoneyTransfer < 0 ? "بد" : "-";
            rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = vaz});
            rowToAdd.Cells.Add(new DataGridViewTextBoxCell
            {
                Value =
                    _sumMoneyTransfer.ToString("C0").Replace(CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol, "")
            });

            return rowToAdd;
        }
        protected override void OnSaveButtonClicked()
        {
            var entity = new Transfer
            {
                DateTime = dataTimePickerBox.Date,
                BillNumber = billNumberBox.Text,
                IsBestankar = bestankarRadio.Checked,
                Money = valueNumBox.Value,
                Comment = commentBox.Text
            };

            if (!Validation(entity)) return;

            var old = _repository.FirstOrDefault(x => x.Id == _result.Id);
            if (old == null)
            {
                entity.Person = _person;
                _repository.Add(entity);
            }
            else
            {
                old.DateTime = entity.DateTime;
                old.BillNumber = entity.BillNumber;
                old.IsBestankar = entity.IsBestankar;
                old.Money = entity.Money;
                old.Comment = entity.Comment;
            }
            SaveAndExit();
        }
Beispiel #3
0
        public async Task<AddUpdateTransferStatus> AddAsync(Transfer transfer)
        {
            if (transfer.Money < 1)
                return AddUpdateTransferStatus.InvalidMoney;
            if (await IsExistBillNumberAsync(transfer.BillNumber))
                return AddUpdateTransferStatus.DuplicateBillNumber;

            _transfers.Add(transfer);
            return AddUpdateTransferStatus.Success;
        }
Beispiel #4
0
        public async Task<AddUpdateTransferStatus> UpdateAsync(Transfer transfer)
        {
            if (transfer.Money < 1)
                return AddUpdateTransferStatus.InvalidMoney;

            var old = await FindByBillNumberAsync(transfer.BillNumber);
            if (old?.Id != transfer.Id)
                return AddUpdateTransferStatus.DuplicateBillNumber;

            return AddUpdateTransferStatus.Success;
        }
Beispiel #5
0
 public async Task<bool> Delete(Transfer transfer) 
     => await Delete(transfer.Id);
 public DialogResult ShowAddDialog(Person owner)
 {
     _person = owner;
     Result = null;
     return ShowDialog();
 }