public ZaLedgerItem(DateTime date, String desc, ZaExpenseType expT, ZaSecondaryExpenseType secExpT, ZaAccount acc, Decimal price = 0) { PurchaseDate = date; Description = desc; ExpenseType = expT; SecondaryExpenseType = secExpT; Account = acc; PurchasePrice = price; }
public override void okButton_Click(object sender, EventArgs e) { try { ZaAccount Account = new ZaAccount(); Account.Name = accountName.Text; Account.OriginalBalance = Decimal.Parse(originalBalanceTextBox.Text); returnValue = Account; base.okButton_Click(sender, e); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Get the total for an account, filtered on the parameters given /// </summary> /// <param name="e"></param> /// <param name="account"></param> /// <param name="dateTo"></param> /// <param name="dateFrom"></param> /// <returns></returns> public Decimal GetTotalForAccount(ZaAccount.AccountReportingTypes e, ZaAccount account, DateTime? dateTo = null, DateTime? dateFrom = null) { Decimal returnValue = 0; try { switch (e) { case ZaAccount.AccountReportingTypes.Current: returnValue = account.OriginalBalance + (from ZaLedgerItem n in MockDb.Database.LedgerItems where n.Account == account select n.PurchasePrice).Sum(); break; case ZaAccount.AccountReportingTypes.Original: returnValue = account.OriginalBalance; break; case ZaAccount.AccountReportingTypes.WithinRange: returnValue = (from ZaLedgerItem n in MockDb.Database.LedgerItems where n.Account == account && (!dateTo.HasValue || n.PurchaseDate.CompareTo(dateTo) <= 0) && (!dateFrom.HasValue || n.PurchaseDate.CompareTo(dateFrom) >= 0) select n.PurchasePrice).Sum(); break; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return returnValue; }
public override void okButton_Click(object sender, EventArgs e) { var fullItemList = new List<ZaLedgerItem>(); var originAccount = (ZaAccount) comboOriginalAccount.SelectedItem; var throughAccount = (ZaAccount) comboThroughAccount.SelectedItem; var destinationAccount = (ZaAccount) comboDestinationAccount.SelectedItem; var amount = Decimal.Parse(textBox1.Text); var dateOfTransfer = dateTimeDateOfTransfer.Value; if (originAccount != null && destinationAccount != null && amount > 0) { var originItem = new ZaLedgerItem(); originItem.PurchaseDate = DateTime.Today; originItem.Account = originAccount; originItem.Description = "Transfer from [" + originAccount + "] to [" + (throughAccount ?? destinationAccount) + "]"; originItem.PurchasePrice = amount; originItem.PurchaseDate = dateOfTransfer; fullItemList.Add(originItem); if (throughAccount != null) { var throughItemRecieved = new ZaLedgerItem(); throughItemRecieved.PurchaseDate = DateTime.Today; throughItemRecieved.Account = throughAccount; throughItemRecieved.Description = "Transfer Recieved from [" + originAccount + "]"; throughItemRecieved.PurchasePrice = -amount; throughItemRecieved.PurchaseDate = dateOfTransfer; fullItemList.Add(throughItemRecieved); var throughItemForwarded = new ZaLedgerItem(); throughItemForwarded.PurchaseDate = DateTime.Today; throughItemForwarded.Account = throughAccount; throughItemForwarded.Description = "Forwarding Transfer to [" + destinationAccount + "]"; throughItemForwarded.PurchasePrice = amount; throughItemForwarded.PurchaseDate = dateOfTransfer; fullItemList.Add(throughItemForwarded); } var destinationItem = new ZaLedgerItem(); destinationItem.PurchaseDate = DateTime.Today; destinationItem.Account = destinationAccount; destinationItem.Description = "Transfer Recieved from [" + (throughAccount ?? destinationAccount) + "]"; destinationItem.PurchasePrice = -amount; destinationItem.PurchaseDate = dateOfTransfer; fullItemList.Add(destinationItem); returnValue = fullItemList; base.okButton_Click(sender, e); // clear all the values on the form originAccount = null; } else { MessageBox.Show("An origin account, destination account and amount are required as a minimum.", "Required Fields", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void SetOriginAccount(ZaAccount account) { originAccount = account; }