コード例 #1
0
 public override void okButton_Click(object sender, EventArgs e)
 {
     ZaSecondaryExpenseType ExpenseType = new ZaSecondaryExpenseType();
     ExpenseType.Name = expenseTypeName.Text;
     ExpenseType.dsExpenseType = (ZaExpenseType)typeComboBox.SelectedValue;
     returnValue = ExpenseType;
     base.okButton_Click(sender, e);
 }
コード例 #2
0
ファイル: ZaLedgerItem.cs プロジェクト: zediah/ZedLedger
 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;
 }
コード例 #3
0
ファイル: ZaLedger.cs プロジェクト: zediah/ZedLedger
    /// <summary>
    /// Will get the relevent view from the list of views based upon the critera given. Will create a new one if one doesn't not exist 
    /// </summary>
    /// <param name="vType">View type parameter</param>
    /// <param name="reference">Reference</param>
    /// <param name="secReference">Secondary Reference</param>
    /// <param name="eType">Expense type</param>
    /// <returns></returns>
    public ZaVExpenseType GetView(ZaVExpenseType.ViewTypes vType, ZaExpenseType reference = null, ZaSecondaryExpenseType secReference = null, ZaExpenseType.ExpenseTypes? eType = null)
    {
        ZaVExpenseType returnValue = null;
        try
        {
            var query = (from ZaVExpenseType n in ExpenseViews
                         where (reference != null ? n.ExpenseType == reference : true) &&
                               (secReference != null ? n.SecondaryExpenseType == secReference : true) &&
                               n.ViewType ==  vType &&
                               (eType != null ? n.ExpenseType.Type == eType : true)
                         select n);

            // If we didn't find the view in the list, it must be new - initalise it
            if (!query.Any())
            {
                returnValue = new ZaVExpenseType();
                if (secReference != null)
                {
                    returnValue.SecondaryExpenseType = secReference;
                }
                else if (reference != null)
                {
                    returnValue.ExpenseType = reference;
                }
                returnValue.ViewType = vType;

                // Set up blank row defaults
                switch(vType)
                {
                    case ZaVExpenseType.ViewTypes.Total:
                        returnValue.BlankRowLocation = ZaVExpenseType.BlankRowLocations.AboveAndBelow;
                        break;
                    default:
                        returnValue.BlankRowLocation = ZaVExpenseType.BlankRowLocations.None;
                        break;
                }
                ExpenseViews.Add(returnValue);
            }
            else
            {
                // The view has already been created, use it
                returnValue = query.First();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        return returnValue;
    }
コード例 #4
0
ファイル: ZaLedger.cs プロジェクト: zediah/ZedLedger
 /// <summary>
 /// Get the total for an expense type, filtered by the parameters given
 /// </summary>
 /// <param name="expenseType"></param>
 /// <param name="dateTo"></param>
 /// <param name="dateFrom"></param>
 /// <param name="type"></param>
 /// <param name="secExpense"></param>
 /// <returns></returns>
 public Decimal GetTotalForExpenseType(ZaExpenseType expenseType = null, DateTime? dateTo = null, DateTime? dateFrom = null, ZaExpenseType.ExpenseTypes? type = null, ZaSecondaryExpenseType secExpense = null, IEnumerable<ZaLedgerItem> list = null)
 {
     Decimal returnValue = 0;
     try
     {
         // Take all if null is passed through._
         returnValue = (from ZaLedgerItem n in list ?? LedgerItemList
                        where (expenseType != null ? n.ExpenseType != null ?  n.ExpenseType.Equals(expenseType) : false : true)
                            // If a type is given and the item does not have an expense type, exclude it.
                        && (type.HasValue ? n.ExpenseType != null ? n.ExpenseType.Type == type : false : true)
                        && (dateTo.HasValue ? n.PurchaseDate.CompareTo(dateTo) <= 0 : true)
                        && (dateFrom.HasValue ? n.PurchaseDate.CompareTo(dateFrom) >= 0 : true)
                        && (secExpense != null ? n.SecondaryExpenseType == secExpense : true)
                        && (expenseType != null && expenseType.Type == ZaExpenseType.ExpenseTypes.Savings ?
                          (n.Account != null && n.Account.Type == ZaAccount.AccountTypes.Savings ? true : false) : true)
                        select n.PurchasePrice).Sum();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     return returnValue;
 }