Ejemplo n.º 1
0
        /// <summary>
        /// Gets the latest verificate date in the database.
        /// </summary>
        /// <param name="dateType">Type of date.</param>
        /// <returns>The earliest account transaction date as a DateTime. null if no account transaction date exists.</returns>
        public DateTime?GetLatestVerificationDate(CashBoxDateType dateType)
        {
            string dateField = dateType == CashBoxDateType.TransactionDate ? "[Date]" : "[AccountingDate]";

            string sql = string.Format(@"
                select top 1 {0}
                from Verifications
                order by {0} desc", dateField);

            object transactionTime = Connection.GetScalar(sql);

            return((transactionTime == null) ? (DateTime?)null : Convert.ToDateTime(transactionTime));
        }
Ejemplo n.º 2
0
        private void LoadMonthComboBoxItems()
        {
            using (var core = new StandardBusinessLayer(DataCache))
            {
                core.Connect();

                CashBoxDateType dateType = (CashBoxDateType)dateTypeComboBox.ComboBox.SelectedValue;

                DateTime?firstAccountTransactionDate = core.GetEarliestVerificationDate(dateType);
                Date     firstDate = CurrentApplication.DateNow;

                if (firstAccountTransactionDate != null)
                {
                    firstDate = new Date((DateTime)firstAccountTransactionDate);
                }

                // Fix so that the date is the first in its month
                firstDate = new Date(firstDate.Year, firstDate.Month, 1);

                // Month
                var monthList = new List <DictionaryItem <Date, string> >();

                DateTime?lastDate = core.GetLatestVerificationDate(dateType);
                Date     date     = CurrentApplication.DateNow;

                if (lastDate != null)
                {
                    date = (DateTime)lastDate;
                    date = new Date(date.Year, date.Month, 1);
                }

                while ((Date)date >= firstDate)
                {
                    monthList.Add(new DictionaryItem <Date, string>()
                    {
                        Key = date, Value = date.ToString("yyyy-MM")
                    });
                    date = date.AddMonths(-1);
                }

                monthToolStripComboBox.ComboBox.ValueMember   = "Key";
                monthToolStripComboBox.ComboBox.DisplayMember = "Value";
                monthToolStripComboBox.ComboBox.DataSource    = monthList;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets cash book transactions by given parameters.
 /// </summary>
 /// <param name="month">A date time with month precision.</param>
 /// <param name="userNo">User number.</param>
 /// <param name="categoryNo">Category number.</param>
 /// <param name="dateType">Date Type.</param>
 /// <returns></returns>
 public CashBookTransactionCollection GetCashBookTransactions(DateTime month, int userNo, int categoryNo, CashBoxDateType dateType)
 {
     if (dateType == CashBoxDateType.TransactionDate)
     {
         return(GetCashBookTransactionsTransactionTime(month, userNo, categoryNo));
     }
     else if (dateType == CashBoxDateType.AccountingDate)
     {
         return(GetCashBookTransactionsAccountingTime(month, userNo, categoryNo));
     }
     else
     {
         throw new NotImplementedException("CashBoxDateType." + dateType + " is unknown.");
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets cash book transactions by given parameters.
 /// </summary>
 /// <param name="month">A date time with month precision.</param>
 /// <param name="userNo">User number.</param>
 /// <param name="categoryNo">Category number.</param>
 /// <param name="dateType">Date Type.</param>
 /// <returns></returns>
 public CashBookTransactionCollection GetCashBookTransactions(DateTime month, int userNo, int categoryNo, CashBoxDateType dateType)
 {
     return(Database.GetCashBookTransactions(month, userNo, categoryNo, dateType));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets the latest verificate date in the database.
 /// </summary>
 /// <param name="dateType">Type of date.</param>
 /// <returns>The earliest account transaction date as a DateTime. null if no account transaction date exists.</returns>
 public DateTime?GetLatestVerificationDate(CashBoxDateType dateType)
 {
     return(Database.GetLatestVerificationDate(dateType));
 }
Ejemplo n.º 6
0
        private void StatisticsForm_Load(object sender, EventArgs e)
        {
            List <DictionaryItem <int, string> > accountTypeList = new List <DictionaryItem <int, string> >();

            accountTypeList.Add(new DictionaryItem <int, string>()
            {
                Key = 1, Value = "Visa tillgångar"
            });
            accountTypeList.Add(new DictionaryItem <int, string>()
            {
                Key = 2, Value = "Visa skulder"
            });
            accountTypeList.Add(new DictionaryItem <int, string>()
            {
                Key = 3, Value = "Visa tillgångar och skulder"
            });

            accountTypeToolStripComboBox.ComboBox.ValueMember   = "Key";
            accountTypeToolStripComboBox.ComboBox.DisplayMember = "Value";
            accountTypeToolStripComboBox.ComboBox.DataSource    = accountTypeList;

            using (var core = new StandardBusinessLayer(DataCache))
            {
                core.Connect();

                CashBoxDateType dateType = CashBoxDateType.TransactionDate;

                DateTime?firstAccountTransactionDate = core.GetEarliestVerificationDate(dateType);
                Date     firstDate = CurrentApplication.DateNow;

                if (firstAccountTransactionDate != null)
                {
                    firstDate = new Date((DateTime)firstAccountTransactionDate);
                }

                // Fix so that the date is the first in its month
                firstDate = new Date(firstDate.Year, firstDate.Month, 1);

                // Month
                var      monthList = new List <DictionaryItem <DateTime, string> >();
                DateTime date      = CurrentApplication.DateNow;

                while ((Date)date >= firstDate)
                {
                    monthList.Add(new DictionaryItem <DateTime, string>()
                    {
                        Key = date, Value = date.ToString("yyyy-MM")
                    });
                    date = date.AddMonths(-1);
                }

                monthlyOverviewMonthToolStripComboBox.ComboBox.ValueMember   = "Key";
                monthlyOverviewMonthToolStripComboBox.ComboBox.DisplayMember = "Value";
                monthlyOverviewMonthToolStripComboBox.ComboBox.DataSource    = monthList;

                // Fix so that the date is the first in its year
                firstDate = new Date(firstDate.Year, 1, 1);

                // Year
                var yearList = new List <DictionaryItem <DateTime, string> >();
                date = CurrentApplication.DateNow;

                while ((Date)date >= firstDate)
                {
                    yearList.Add(new DictionaryItem <DateTime, string>()
                    {
                        Key = date, Value = date.ToString("yyyy")
                    });
                    date = date.AddYears(-1);
                }

                monthlyBalanceYearToolStripComboBox.ComboBox.ValueMember   = "Key";
                monthlyBalanceYearToolStripComboBox.ComboBox.DisplayMember = "Value";
                monthlyBalanceYearToolStripComboBox.ComboBox.DataSource    = yearList;

                // Fix so that the date is the first in its year
                firstDate = new Date(firstDate.Year, 1, 1);

                // Year
                yearList = new List <DictionaryItem <DateTime, string> >();
                date     = CurrentApplication.DateNow;

                while ((Date)date >= firstDate)
                {
                    yearList.Add(new DictionaryItem <DateTime, string>()
                    {
                        Key = date, Value = date.ToString("yyyy")
                    });
                    date = date.AddYears(-1);
                }

                yearlyOverviewMonthToolStripComboBox.ComboBox.ValueMember   = "Key";
                yearlyOverviewMonthToolStripComboBox.ComboBox.DisplayMember = "Value";
                yearlyOverviewMonthToolStripComboBox.ComboBox.DataSource    = yearList;
            }

            LoadMonthlyOverview();
            LoadYearlyOverview();
            LoadMonthlyBalance();
            LoadAccountBalance();
            LoadTagAccountBalance();
            LoadTotalWealth();

            FormLoading = false;
        }