示例#1
0
 private void tsmIndependent_Click(object sender, EventArgs e)
 {
     if (trvTask.SelectedNode != null)
     {
         TreeNode node            = trvTask.SelectedNode;
         TreeNode parentNode      = node.Parent;
         TreeNode grandparentNode = node.Parent.Parent;
         TreeNode newNode         = (TreeNode)node.Clone();
         if (node.Parent != null && node.Parent.Parent != null)
         {
             string parentNodeName      = parentNode.Text;
             string grandparentNodeName = grandparentNode.Text;
             G.glb.lstSubTask.RemoveAll(o => o.Task == parentNode.Text && o.SubTask == node.Text);
             RSubTask newSub = new RSubTask();
             newSub.Task    = grandparentNode.Text;
             newSub.SubTask = node.Text;
             newSub.index   = grandparentNode.Nodes.Count;
             G.glb.lstSubTask.Add(newSub);
             grandparentNode.Nodes.Insert(parentNode.Index + 1, newNode);
             node.Remove();
             trvTask.SelectedNode = newNode;
             ReIndex(grandparentNodeName);
             ReIndex(parentNodeName);
             calculate C = new calculate();
             C.RefreshFinishTask(parentNodeName, G.glb.lstSubTask, G.glb.lstTask, G.glb.lstLog);
             RefreshIcon(trvTask.Nodes[0]);
         }
     }
 }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool CanSaveFlag = true;

            if (txtSummary.Text == "")
            {
                MessageBox.Show("Need a summary name");
                CanSaveFlag = false;
            }
            if (txtCreditAmount.Text == "" || txtDebitAmount.Text == "")
            {
                MessageBox.Show("Amount incomplete");
                CanSaveFlag = false;
            }

            if (CanSaveFlag)
            {
                CTransaction newTransaction = new CTransaction();
                newTransaction.TagTime        = curDate;
                newTransaction.Summary        = txtSummary.Text;
                newTransaction.CreditAccount  = cbxCredit.Text;
                newTransaction.CreditAmount   = Convert.ToDouble(txtCreditAmount.Text);
                newTransaction.CreditCurrency = lblCreditCurrency.Text;
                newTransaction.DebitAccount   = cbxDebit.Text;
                newTransaction.DebitAmount    = Convert.ToDouble(txtDebitAmount.Text);
                newTransaction.DebitCurrency  = lblDebitCurrency.Text;
                calculate C = new calculate();
                newTransaction.IconType = C.MoneyInOrOut(
                    G.glb.lstAccount.Find(o => o.AccountName == cbxDebit.Text).AccountType,
                    G.glb.lstAccount.Find(o => o.AccountName == cbxCredit.Text).AccountType);
                G.glb.lstTransaction.Add(newTransaction);
                DrawLog();
                Dispose();
            }
        }
示例#3
0
 private void tsmAbort_Click(object sender, EventArgs e)
 {
     if (trvTask.SelectedNode != null)
     {
         // 对于根节点,不让Abort
         if (trvTask.SelectedNode.Text == "(Root)")
         {
             MessageBox.Show("Cannot abort the root.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else if (G.glb.lstTask.Exists(o => o.TaskName == trvTask.SelectedNode.Text))
         {
             if (G.glb.lstTask.Find(o => o.TaskName == trvTask.SelectedNode.Text).TaskState != ETaskState.Aborted)
             {
                 calculate C = new calculate();
                 C.AbortTask(trvTask.SelectedNode.Text, G.glb.lstSubTask, G.glb.lstTask, G.glb.lstLog);
                 C.RefreshFinishTask(trvTask.SelectedNode.Parent.Text, G.glb.lstSubTask, G.glb.lstTask, G.glb.lstLog);
                 RefreshIcon(trvTask.Nodes[0]);
             }
             else
             {
                 calculate C = new calculate();
                 C.ReAssignTask(trvTask.SelectedNode.Text, G.glb.lstSubTask, G.glb.lstTask, G.glb.lstLog);
                 C.RefreshFinishTask(trvTask.SelectedNode.Parent.Text, G.glb.lstSubTask, G.glb.lstTask, G.glb.lstLog);
                 RefreshIcon(trvTask.Nodes[0]);
             }
         }
     }
 }
示例#4
0
 private void AddChildNode(string nodeName)
 {
     if (trvTask.SelectedNode != null)
     {
         TreeNode node    = trvTask.SelectedNode;
         TreeNode newNode = new TreeNode(nodeName, 1, 1);
         newNode.Name = nodeName;
         node.Nodes.Add(newNode);
         calculate C = new calculate();
         C.RefreshFinishTask(trvTask.SelectedNode.Text, G.glb.lstSubTask, G.glb.lstTask, G.glb.lstLog);
         RefreshIcon(trvTask.Nodes[0]);
     }
 }
示例#5
0
 private void tsmDeleteAccount_Click(object sender, EventArgs e)
 {
     if (trvAccount.SelectedNode != null)
     {
         if (trvAccount.SelectedNode.Text == "(Root)" &&
             G.glb.lstAccount.Find(o => o.AccountName == trvAccount.SelectedNode.Text).ProtectedAccount == false)
         {
             MessageBox.Show("Cannot remove the root.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else if (G.glb.lstAccount.Exists(o => o.AccountName == trvAccount.SelectedNode.Text))
         {
             string    UpperAccount  = trvAccount.SelectedNode.Parent.Text;
             calculate C             = new calculate();
             bool      CanDeleteFlag = C.DeleteAccount(trvAccount.SelectedNode.Text, G.glb.lstSubAccount, G.glb.lstAccount, G.glb.lstTransaction, G.glb.lstBudget);
             if (CanDeleteFlag)
             {
                 trvAccount.Nodes.Remove(trvAccount.SelectedNode);
                 ReIndex(UpperAccount);
             }
         }
     }
 }
示例#6
0
 private void tsmRemove_Click(object sender, EventArgs e)
 {
     if (trvTask.SelectedNode != null)
     {
         // 对于根节点,不让删
         if (trvTask.SelectedNode.Text == "(Root)")
         {
             MessageBox.Show("Cannot remove the root.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else if (G.glb.lstTask.Exists(o => o.TaskName == trvTask.SelectedNode.Text))
         {
             string    UpperTask     = trvTask.SelectedNode.Parent.Text;
             calculate C             = new calculate();
             bool      CanDeleteFlag = C.DeleteTask(trvTask.SelectedNode.Text, G.glb.lstSubTask, G.glb.lstTask, G.glb.lstLog, G.glb.lstSchedule);
             if (CanDeleteFlag)
             {
                 trvTask.Nodes.Remove(trvTask.SelectedNode);
                 C.RefreshFinishTask(UpperTask, G.glb.lstSubTask, G.glb.lstTask, G.glb.lstLog);
                 ReIndex(UpperTask);
                 RefreshIcon(trvTask.Nodes[0]);
             }
         }
     }
 }
示例#7
0
 private void LoadTask(string taskName)
 {
     chkBottom.Enabled   = false;
     chkFinished.Enabled = false;
     dtpDeadline.Enabled = false;
     chkInfinite.Enabled = false;
     dgvLog.Rows.Clear();
     if (G.glb.lstTask.Exists(o => o.TaskName == taskName))
     {
         CTask task = G.glb.lstTask.Find(o => o.TaskName == taskName);
         lblTaskTitle.Text = task.TaskName;
         chkBottom.Checked = task.IsBottom;
         if (task.TaskState == ETaskState.Finished)
         {
             chkFinished.Checked = true;
         }
         calculate C = new calculate();
         lblTaskTimeSpent.Text = Math.Round(C.CalTimeSpentInTask(task.TaskName, G.glb.lstSubTask, G.glb.lstLog), 2).ToString() + "h";
         DateTime?NextTimeMarker = C.FindNextTimeMarker(task.TaskName, G.glb.lstSubTask, G.glb.lstTask);
         if (NextTimeMarker != null)
         {
             dtpNextTimeMarker.Value = (DateTime)NextTimeMarker;
         }
         else
         {
             dtpNextTimeMarker.Value = new DateTime(9998, 12, 31);
         }
         if (task.IsInfinite)
         {
             chkInfinite.Checked = true;
             dtpDeadline.Value   = new DateTime(9998, 12, 31);
         }
         else
         {
             chkInfinite.Checked = false;
             dtpDeadline.Value   = task.DeadLine;
         }
         List <string> bottomTasks = C.FindAllBottomTask(taskName, G.glb.lstSubTask);
         foreach (string bottomTask in bottomTasks)
         {
             List <CLog> logs = G.glb.lstLog.FindAll(o => o.ContributionToTask == bottomTask);
             foreach (CLog log in logs)
             {
                 TimeSpan span = log.EndTime - log.StartTime;
                 dgvLog.Rows.Add(
                     log.StartTime.ToString("MM/dd/yyyy"),
                     bottomTask,
                     log.LogName,
                     span.TotalHours
                     );
             }
         }
         lsbTaskNote.Items.Clear();
         List <CNote> notes = G.glb.lstNote.FindAll(o => C.FindAllHeirTask(taskName, G.glb.lstSubTask).Exists(p => p == o.TaskName));
         foreach (CNote note in notes)
         {
             lsbTaskNote.Items.Add(note.TagTime.Year.ToString() + "." + note.TagTime.Month.ToString() + "." + note.TagTime.Day.ToString() + " - " + note.Topic);
         }
     }
     else
     {
         lblTaskTitle.Text     = "(No Record)";
         chkBottom.Checked     = false;
         chkFinished.Checked   = false;
         chkInfinite.Checked   = false;
         lblTaskTimeSpent.Text = "----";
         lsbTaskNote.Items.Clear();
         dtpNextTimeMarker.Value = DateTime.Today;
         dtpDeadline.Value       = DateTime.Today;
     }
 }
示例#8
0
        public SBalance CalFutureBalance(
            string AccountName,
            List <CAccount> accounts,
            List <RSubAccount> rSubAccounts,
            List <CTransaction> transactions,
            List <CTransaction> budgets,
            List <RCurrencyRate> currencyRates,
            DateTime StartTime,
            DateTime EndTime)
        {
            // Calculate The Balance without budget
            SBalance balance = CalBalance(AccountName, accounts, rSubAccounts, transactions, currencyRates, StartTime, EndTime);
            double   retOpeningBalanceDebit  = balance.OpeningBalanceDebit;
            double   retOpeningBalanceCredit = balance.OpeningBalanceCredit;
            double   retAmountDebit          = balance.AmountDebit;
            double   retAmountCredit         = balance.AmountCredit;
            double   retEndingBalanceDebit   = balance.EndingBalanceDebit;
            double   retEndingBalanceCredit  = balance.EndingBalanceCredit;

            // 找到所有的Heir科目
            calculate           C              = new calculate();
            List <string>       heirAccount    = C.FindAllHeirAccount(AccountName, rSubAccounts);
            List <CTransaction> BudgetsInRange = budgets.FindAll(
                o => o.TagTime >= StartTime &&
                o.TagTime <= EndTime &&
                heirAccount.Exists(
                    p => p == o.DebitAccount ||
                    p == o.CreditAccount)).ToList();

            foreach (CTransaction budget in BudgetsInRange)
            {
                if (heirAccount.Exists(o => o == budget.DebitAccount))
                {
                    if (budget.DebitCurrency == accounts.Find(o => o.AccountName == AccountName).Currency)
                    {
                        retAmountDebit += budget.DebitAmount;
                    }
                    else
                    {
                        if (currencyRates.Exists(o => o.CurrencyA == accounts.Find(p => p.AccountName == AccountName).Currency&& o.CurrencyB == budget.DebitCurrency))
                        {
                            retAmountDebit += budget.DebitAmount / currencyRates.Find(o => o.CurrencyA == accounts.Find(p => p.AccountName == AccountName).Currency&& o.CurrencyB == budget.DebitCurrency).Rate;
                        }
                        else if (currencyRates.Exists(o => o.CurrencyB == accounts.Find(p => p.AccountName == AccountName).Currency&& o.CurrencyA == budget.DebitCurrency))
                        {
                            retAmountDebit += budget.DebitAmount * currencyRates.Find(o => o.CurrencyB == accounts.Find(p => p.AccountName == AccountName).Currency&& o.CurrencyA == budget.DebitCurrency).Rate;
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Lack of exchange rate of " + budget.DebitCurrency + " → " + accounts.Find(o => o.AccountName == AccountName).Currency);
                        }
                    }
                }
                if (heirAccount.Exists(o => o == budget.CreditAccount))
                {
                    if (budget.CreditCurrency == accounts.Find(o => o.AccountName == AccountName).Currency)
                    {
                        retAmountCredit += budget.CreditAmount;
                    }
                    else
                    {
                        if (currencyRates.Exists(o => o.CurrencyA == accounts.Find(p => p.AccountName == AccountName).Currency&& o.CurrencyB == budget.CreditCurrency))
                        {
                            retAmountCredit += budget.CreditAmount / currencyRates.Find(o => o.CurrencyA == accounts.Find(p => p.AccountName == AccountName).Currency&& o.CurrencyB == budget.CreditCurrency).Rate;
                        }
                        else if (currencyRates.Exists(o => o.CurrencyB == accounts.Find(p => p.AccountName == AccountName).Currency&& o.CurrencyA == budget.CreditCurrency))
                        {
                            retAmountCredit += budget.CreditAmount * currencyRates.Find(o => o.CurrencyB == accounts.Find(p => p.AccountName == AccountName).Currency&& o.CurrencyA == budget.CreditCurrency).Rate;
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Lack of exchange rate of " + budget.CreditCurrency + " → " + accounts.Find(o => o.AccountName == AccountName).Currency);
                        }
                    }
                }
            }
            // 目前账目等均以2019.1.1开始,之前默认为无数据
            if (EndTime >= new DateTime(2019, 1, 1))
            {
                SBalance toStart = CalFutureBalance(AccountName, accounts, rSubAccounts, transactions, budgets, currencyRates, new DateTime(2019, 1, 1), StartTime.AddDays(-1));
                if (toStart.EndingBalanceDebit - toStart.EndingBalanceCredit > 0)
                {
                    retOpeningBalanceDebit  = toStart.EndingBalanceDebit - toStart.EndingBalanceCredit;
                    retOpeningBalanceCredit = 0;
                }
                else
                {
                    retOpeningBalanceDebit  = 0;
                    retOpeningBalanceCredit = -(toStart.EndingBalanceDebit - toStart.EndingBalanceCredit);
                }
            }
            else
            {
                retOpeningBalanceDebit  = 0;
                retOpeningBalanceCredit = 0;
            }
            double abs = (retOpeningBalanceDebit + retAmountDebit) - (retOpeningBalanceCredit + retAmountCredit);

            if (abs > 0)
            {
                retEndingBalanceDebit  = abs;
                retEndingBalanceCredit = 0;
            }
            else
            {
                retEndingBalanceDebit  = 0;
                retEndingBalanceCredit = -abs;
            }

            SBalance ret = new SBalance();

            ret.OpeningBalanceDebit  = retOpeningBalanceDebit;
            ret.OpeningBalanceCredit = retOpeningBalanceCredit;
            ret.AmountDebit          = retAmountDebit;
            ret.AmountCredit         = retAmountCredit;
            ret.EndingBalanceDebit   = retEndingBalanceDebit;
            ret.EndingBalanceCredit  = retEndingBalanceCredit;
            return(ret);
        }
示例#9
0
        private void LoadAccountTransaction(string accountName)
        {
            dgvDetail.Rows.Clear();
            calculate           C            = new calculate();
            List <string>       heirAccounts = C.FindAllHeirAccount(accountName, G.glb.lstSubAccount);
            List <CTransaction> transactions = G.glb.lstTransaction.FindAll(
                o => (heirAccounts.Exists(p => p == o.CreditAccount) || heirAccounts.Exists(p => p == o.DebitAccount)) &&
                o.TagTime >= dtpStatementPeriodStart.Value.Date && o.TagTime <= dtpStatementPeriodEnd.Value.Date);

            foreach (CTransaction trans in transactions)
            {
                if (heirAccounts.Exists(o => o == trans.DebitAccount))
                {
                    if (trans.DebitCurrency == G.glb.lstAccount.Find(o => o.AccountName == accountName).Currency)
                    {
                        dgvDetail.Rows.Add(
                            trans.TagTime.Date.ToString("MM/dd/yyyy"),
                            trans.Summary,
                            trans.DebitAccount,
                            trans.CreditAccount,
                            "D",
                            trans.DebitAmount,
                            trans.DebitCurrency,
                            trans.DebitAmount,
                            1);
                    }
                    else if (G.glb.lstCurrencyRate.Exists(o => o.CurrencyA == trans.DebitCurrency && o.CurrencyB == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency))
                    {
                        dgvDetail.Rows.Add(
                            trans.TagTime.Date.ToString("MM/dd/yyyy"),
                            trans.Summary,
                            trans.DebitAccount,
                            trans.CreditAccount,
                            "D",
                            trans.DebitAmount,
                            trans.DebitCurrency,
                            trans.DebitAmount * G.glb.lstCurrencyRate.Find(o => o.CurrencyA == trans.DebitCurrency && o.CurrencyB == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency).Rate,
                            G.glb.lstCurrencyRate.Find(o => o.CurrencyA == trans.DebitCurrency && o.CurrencyB == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency).Rate);
                    }
                    else if (G.glb.lstCurrencyRate.Exists(o => o.CurrencyB == trans.DebitCurrency && o.CurrencyA == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency))
                    {
                        dgvDetail.Rows.Add(
                            trans.TagTime.Date.ToString("MM/dd/yyyy"),
                            trans.Summary,
                            trans.DebitAccount,
                            trans.CreditAccount,
                            "D",
                            trans.DebitAmount,
                            trans.DebitCurrency,
                            trans.DebitAmount / G.glb.lstCurrencyRate.Find(o => o.CurrencyB == trans.DebitCurrency && o.CurrencyA == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency).Rate,
                            1 / G.glb.lstCurrencyRate.Find(o => o.CurrencyB == trans.DebitCurrency && o.CurrencyA == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency).Rate);
                    }
                    else
                    {
                        MessageBox.Show("Lack of exchange rate of " + trans.CreditCurrency + " → " + G.glb.lstAccount.Find(o => o.AccountName == accountName).Currency);
                    }
                }
                if (heirAccounts.Exists(o => o == trans.CreditAccount))
                {
                    if (trans.CreditCurrency == G.glb.lstAccount.Find(o => o.AccountName == accountName).Currency)
                    {
                        dgvDetail.Rows.Add(
                            trans.TagTime.Date.ToString("MM/dd/yyyy"),
                            trans.Summary,
                            trans.CreditAccount,
                            trans.DebitAccount,
                            "C",
                            trans.CreditAmount,
                            trans.CreditCurrency,
                            trans.CreditAmount,
                            1);
                    }
                    else if (G.glb.lstCurrencyRate.Exists(o => o.CurrencyA == trans.CreditCurrency && o.CurrencyB == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency))
                    {
                        dgvDetail.Rows.Add(
                            trans.TagTime.Date.ToString("MM/dd/yyyy"),
                            trans.Summary,
                            trans.CreditAccount,
                            trans.DebitAccount,
                            "C",
                            trans.CreditAmount,
                            trans.CreditCurrency,
                            trans.CreditAmount * G.glb.lstCurrencyRate.Find(o => o.CurrencyA == trans.CreditCurrency && o.CurrencyB == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency).Rate,
                            G.glb.lstCurrencyRate.Find(o => o.CurrencyA == trans.CreditCurrency && o.CurrencyB == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency).Rate);
                    }
                    else if (G.glb.lstCurrencyRate.Exists(o => o.CurrencyB == trans.CreditCurrency && o.CurrencyA == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency))
                    {
                        dgvDetail.Rows.Add(
                            trans.TagTime.Date.ToString("MM/dd/yyyy"),
                            trans.Summary,
                            trans.CreditAccount,
                            trans.DebitAccount,
                            "C",
                            trans.CreditAmount,
                            trans.CreditCurrency,
                            trans.CreditAmount / G.glb.lstCurrencyRate.Find(o => o.CurrencyB == trans.CreditCurrency && o.CurrencyA == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency).Rate,
                            1 / G.glb.lstCurrencyRate.Find(o => o.CurrencyB == trans.CreditCurrency && o.CurrencyA == G.glb.lstAccount.Find(p => p.AccountName == accountName).Currency).Rate);
                    }
                    else
                    {
                        MessageBox.Show("Lack of exchange rate of " + trans.CreditCurrency + " → " + G.glb.lstAccount.Find(o => o.AccountName == accountName).Currency);
                    }
                }
            }
        }
示例#10
0
        private CAccountBalanceDetail LoadAccount(string accountName)
        {
            CAccountBalanceDetail res = new CAccountBalanceDetail();
            calculate             C   = new calculate();

            double curAssetsBalance      = 0;
            double curLiabilitiesBalance = 0;

            calculate.SBalance currentAssets = C.CalBalance(
                "(Assets)",
                G.glb.lstAccount,
                G.glb.lstSubAccount,
                G.glb.lstTransaction,
                G.glb.lstCurrencyRate,
                dtpStatementPeriodStart.Value.Date,
                dtpStatementPeriodEnd.Value.Date);
            curAssetsBalance = currentAssets.EndingBalanceDebit - currentAssets.EndingBalanceCredit;
            calculate.SBalance currentLiabilities = C.CalBalance(
                "(Liability)",
                G.glb.lstAccount,
                G.glb.lstSubAccount,
                G.glb.lstTransaction,
                G.glb.lstCurrencyRate,
                dtpStatementPeriodStart.Value.Date,
                dtpStatementPeriodEnd.Value.Date);
            curLiabilitiesBalance = currentLiabilities.EndingBalanceDebit - currentLiabilities.EndingBalanceCredit;
            res.lblBalance        = Math.Round(curAssetsBalance + curLiabilitiesBalance, 2);

            calculate.SBalance balance = C.CalBalance(
                accountName,
                G.glb.lstAccount,
                G.glb.lstSubAccount,
                G.glb.lstTransaction,
                G.glb.lstCurrencyRate,
                dtpStatementPeriodStart.Value.Date,
                dtpStatementPeriodEnd.Value.Date);
            res.lblDebitOpening  = Math.Round(balance.OpeningBalanceDebit, 2);
            res.lblCreditOpening = Math.Round(balance.OpeningBalanceCredit, 2);
            res.lblDebitAmount   = Math.Round(balance.AmountDebit, 2);
            res.lblCreditAmount  = Math.Round(balance.AmountCredit, 2);
            res.lblDebitEnding   = Math.Round(balance.EndingBalanceDebit, 2);
            res.lblCreditEnding  = Math.Round(balance.EndingBalanceCredit, 2);

            double futureAssetsBalance      = 0;
            double futureLiabilitiesBalance = 0;

            calculate.SBalance futureAssets = C.CalFutureBalance(
                "(Assets)",
                G.glb.lstAccount,
                G.glb.lstSubAccount,
                G.glb.lstTransaction,
                G.glb.lstBudget,
                G.glb.lstCurrencyRate,
                dtpStatementPeriodStart.Value.Date,
                dtpEndOfPredictPeriod.Value.Date);
            futureAssetsBalance = futureAssets.EndingBalanceDebit - futureAssets.EndingBalanceCredit;
            calculate.SBalance futureLiabilities = C.CalFutureBalance(
                "(Liability)",
                G.glb.lstAccount,
                G.glb.lstSubAccount,
                G.glb.lstTransaction,
                G.glb.lstBudget,
                G.glb.lstCurrencyRate,
                dtpStatementPeriodStart.Value.Date,
                dtpEndOfPredictPeriod.Value.Date);
            futureLiabilitiesBalance = futureLiabilities.EndingBalanceDebit - futureLiabilities.EndingBalanceCredit;
            res.lblFutureBalance     = Math.Round(futureAssetsBalance + futureLiabilitiesBalance, 2);

            calculate.SBalance futureBalance = C.CalFutureBalance(
                accountName,
                G.glb.lstAccount,
                G.glb.lstSubAccount,
                G.glb.lstTransaction,
                G.glb.lstBudget,
                G.glb.lstCurrencyRate,
                dtpStatementPeriodStart.Value.Date,
                dtpEndOfPredictPeriod.Value.Date);
            res.lblFutureDebitAmount  = Math.Round(futureBalance.AmountDebit, 2);
            res.lblFutureCreditAmount = Math.Round(futureBalance.AmountCredit, 2);
            res.lblFutureDebitEnding  = Math.Round(futureBalance.EndingBalanceDebit, 2);
            res.lblFutureCreditEnding = Math.Round(futureBalance.EndingBalanceCredit, 2);


            return(res);
        }
示例#11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool CanSaveFlag = true;

            if (dtpPeriodEnd.Value < dtpPeriodStart.Value)
            {
                MessageBox.Show("End date can not earlier than start date");
                CanSaveFlag = false;
            }
            if (txtSummary.Text == "")
            {
                MessageBox.Show("Need a summary name");
                CanSaveFlag = false;
            }
            if (txtCreditAmount.Text == "" || txtDebitAmount.Text == "")
            {
                MessageBox.Show("Amount incomplete");
                CanSaveFlag = false;
            }

            if (CanSaveFlag)
            {
                DateTime startDate = dtpPeriodStart.Value.Date;
                DateTime endDate   = dtpPeriodEnd.Value.Date;
                for (DateTime day = startDate; day <= endDate; day = day.AddDays(1))
                {
                    bool IsSaveBudget = false;
                    switch (day.DayOfWeek)
                    {
                    case DayOfWeek.Sunday:
                        if (chkSu.Checked)
                        {
                            IsSaveBudget = true;
                        }
                        break;

                    case DayOfWeek.Monday:
                        if (chkMo.Checked)
                        {
                            IsSaveBudget = true;
                        }
                        break;

                    case DayOfWeek.Tuesday:
                        if (chkTu.Checked)
                        {
                            IsSaveBudget = true;
                        }
                        break;

                    case DayOfWeek.Wednesday:
                        if (chkWe.Checked)
                        {
                            IsSaveBudget = true;
                        }
                        break;

                    case DayOfWeek.Thursday:
                        if (chkTh.Checked)
                        {
                            IsSaveBudget = true;
                        }
                        break;

                    case DayOfWeek.Friday:
                        if (chkFr.Checked)
                        {
                            IsSaveBudget = true;
                        }
                        break;

                    case DayOfWeek.Saturday:
                        if (chkSa.Checked)
                        {
                            IsSaveBudget = true;
                        }
                        break;

                    default:
                        break;
                    }
                    if (IsSaveBudget)
                    {
                        CTransaction newBudget = new CTransaction();
                        newBudget.TagTime        = day;
                        newBudget.Summary        = txtSummary.Text;
                        newBudget.CreditAccount  = cbxCredit.Text;
                        newBudget.CreditAmount   = Convert.ToDouble(txtCreditAmount.Text);
                        newBudget.CreditCurrency = lblCreditCurrency.Text;
                        newBudget.DebitAccount   = cbxDebit.Text;
                        newBudget.DebitAmount    = Convert.ToDouble(txtDebitAmount.Text);
                        newBudget.DebitCurrency  = lblDebitCurrency.Text;
                        calculate C = new calculate();
                        newBudget.IconType = C.MoneyInOrOut(
                            G.glb.lstAccount.Find(o => o.AccountName == cbxDebit.Text).AccountType,
                            G.glb.lstAccount.Find(o => o.AccountName == cbxCredit.Text).AccountType);
                        G.glb.lstBudget.Add(newBudget);
                    }
                }
                DrawLog();
                Dispose();
            }
        }