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;
        }
Пример #2
0
        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();
        }
Пример #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;
        }
Пример #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;
        }
Пример #5
0
 public async Task<bool> Delete(Transfer transfer) 
     => await Delete(transfer.Id);
Пример #6
0
 public DialogResult ShowAddDialog(Person owner)
 {
     _person = owner;
     Result = null;
     return ShowDialog();
 }