Exemplo n.º 1
0
 //---------------------------------------------------------------------
 // Intializes the form
 //---------------------------------------------------------------------
 public originalTransactionDate(TransactionHistory transHis, int index, User user, Handler handler)
 {
     InitializeComponent();
     editTrans      = transHis.getTransaction(index);
     transactionKey = databaseManager.getTransactionPrimaryKey(editTrans);
     if (editTrans.getPrice() > 0)
     {
         originalTransactionDisplay.Text = editTrans.getPrice().ToString();
     }
     else
     {
         originalTransactionDisplay.Text = (-1 * editTrans.getPrice()).ToString();
     }
     originalTransactionDateDisplay.Text        = editTrans.getDate().ToString();
     originalTransactionDescriptionDisplay.Text = editTrans.getDesc().ToString();
     this.currentUser    = user;
     this.commandHandler = handler;
 }
Exemplo n.º 2
0
        //---------------------------------------------------------------------
        // Creates a monthly report based on the transaction of the
        // previous month. Generates at the first day of every new month
        // params: none
        //---------------------------------------------------------------------
        private void GenerateMonthlyReport()
        {
            double      monthlyrevenuetotal = 0;
            double      monthlyexpensetotal = 0;
            double      monthlydifference   = 0;
            Transaction currenttransaction;
            Date        dateset = new Date();

            int previousmonth = currentDate.getMonth() - 1;

            if (previousmonth == 0)
            {
                previousmonth = DEC;
            }

            if (previousmonth == JAN)
            {
                lblPreviousMonth.Text = "January";
            }
            else if (previousmonth == FEB)
            {
                lblPreviousMonth.Text = "February";
            }
            else if (previousmonth == MAR)
            {
                lblPreviousMonth.Text = "March";
            }
            else if (previousmonth == APR)
            {
                lblPreviousMonth.Text = "April";
            }
            else if (previousmonth == MAY)
            {
                lblPreviousMonth.Text = "May";
            }
            else if (previousmonth == JUN)
            {
                lblPreviousMonth.Text = "June";
            }
            else if (previousmonth == JUL)
            {
                lblPreviousMonth.Text = "July";
            }
            else if (previousmonth == AUG)
            {
                lblPreviousMonth.Text = "August";
            }
            else if (previousmonth == SEP)
            {
                lblPreviousMonth.Text = "September";
            }
            else if (previousmonth == OCT)
            {
                lblPreviousMonth.Text = "October";
            }
            else if (previousmonth == NOV)
            {
                lblPreviousMonth.Text = "November";
            }
            else if (previousmonth == DEC)
            {
                lblPreviousMonth.Text = "December";
            }

            lbMonthlyReport.Items.Clear();

            for (int i = 0; i < recentHistory.getTransactionCount(); i++)
            {
                if (dateset.toDate(recentHistory.getTransaction(i).getDate()).getMonth()
                    == previousmonth)
                {
                    currenttransaction = recentHistory.getTransaction(i);
                    if (currenttransaction.getPrice() * FLIPNUMBERSIGN < 0)
                    {
                        monthlyexpensetotal += currenttransaction.getPrice();
                    }
                    else
                    {
                        monthlyrevenuetotal += currenttransaction.getPrice() * FLIPNUMBERSIGN;
                    }

                    string transactiondetails = currenttransaction.getTransactionNumber()
                                                + " " + currenttransaction.getDate()
                                                + ": "
                                                + ("$" + (currenttransaction.getPrice() * FLIPNUMBERSIGN).ToString("0.00"))
                                                + ", "
                                                + currenttransaction.getDesc();
                    lbMonthlyReport.Items.Insert(0, transactiondetails);
                }
            }

            monthlydifference = monthlyrevenuetotal - monthlyexpensetotal;

            lblMonthlyRevenues.Text    = "Revenue Total: $" + monthlyrevenuetotal.ToString("0.00");
            lblMonthlyRevenues.Visible = true;

            lblMonthlyExpenses.Text    = "Expense Total: $" + monthlyexpensetotal.ToString("0.00");
            lblMonthlyExpenses.Visible = true;

            lblMonthlyDifference.Text    = "Monthly Difference: $" + monthlydifference.ToString("0.00");
            lblMonthlyDifference.Visible = true;
        }