private void trvAccount_AfterSelect(object sender, TreeViewEventArgs e) { if (trvAccount.SelectedNode != null && trvAccount.SelectedNode.Text != "(Root)") { CAccountBalanceDetail balance = LoadAccount(trvAccount.SelectedNode.Text); LoadAccountTransaction(trvAccount.SelectedNode.Text); lblBalance.Text = balance.lblBalance.ToString(); lblDebitOpening.Text = balance.lblDebitOpening.ToString(); lblCreditOpening.Text = balance.lblCreditOpening.ToString(); lblDebitAmount.Text = balance.lblDebitAmount.ToString(); lblCreditAmount.Text = balance.lblCreditAmount.ToString(); lblDebitEnding.Text = balance.lblDebitEnding.ToString(); lblCreditEnding.Text = balance.lblCreditEnding.ToString(); lblFutureBalance.Text = balance.lblFutureBalance.ToString(); lblFutureDebitAmount.Text = balance.lblFutureDebitAmount.ToString(); lblFutureCreditAmount.Text = balance.lblFutureCreditAmount.ToString(); lblFutureDebitEnding.Text = balance.lblFutureDebitEnding.ToString(); lblFutureCreditEnding.Text = balance.lblFutureCreditEnding.ToString(); CAccount account = G.glb.lstAccount.Find(o => o.AccountName == trvAccount.SelectedNode.Text); lblAccountName.Text = account.AccountName; lblCurrency.Text = account.Currency; RefreshPtgSubAccount(trvAccount.SelectedNode.Text); //plot.DrawPercentageBlocks(picCredit, "g", new List<double> { 0.2, 0.3, 0.3, 0.1, 0.1 }, new List<string> { "", "", "" }); //plot.DrawPercentageBlocks(picDebit, "r", new List<double> { 0.2, 0.3, 0.5 }, new List<string> { "", "", "" }); } }
private void btnSave_Click(object sender, EventArgs e) { bool CanSaveFlag = true; if (G.glb.lstAccount.Exists(o => o.AccountName == txtAccount.Text)) { CanSaveFlag = false; MessageBox.Show("Account exists!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (cbxAccountType.Text == "") { CanSaveFlag = false; MessageBox.Show("Choose The Account Type", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (txtCurrency.Text == "") { CanSaveFlag = false; MessageBox.Show("Choose The Currency", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (CanSaveFlag) { CAccount newAccount = new CAccount(); newAccount.AccountName = txtAccount.Text; int iconIndex = 0; switch (cbxAccountType.Text) { case "Assets": newAccount.AccountType = EAccountType.Assets; iconIndex = 2; break; case "Expense": newAccount.AccountType = EAccountType.Expense; iconIndex = 3; break; case "Equity": newAccount.AccountType = EAccountType.Equity; iconIndex = 2; break; case "Liability": newAccount.AccountType = EAccountType.Liability; iconIndex = 2; break; case "Income": newAccount.AccountType = EAccountType.Income; iconIndex = 1; break; default: break; } newAccount.Currency = txtCurrency.Text; G.glb.lstAccount.Add(newAccount); RSubAccount newRSubAccount = new RSubAccount(); int maxIndex; if (G.glb.lstSubAccount.Exists(o => o.Account == UpperAccount)) { List <RSubAccount> sameLevel = G.glb.lstSubAccount.FindAll(o => o.Account == UpperAccount).ToList(); sameLevel = sameLevel.OrderByDescending(o => o.index).ToList(); maxIndex = sameLevel[0].index + 1; } else { maxIndex = 0; } newRSubAccount.Account = UpperAccount; newRSubAccount.SubAccount = txtAccount.Text; newRSubAccount.index = maxIndex; G.glb.lstSubAccount.Add(newRSubAccount); AddChildNode(txtAccount.Text, iconIndex); Dispose(); } }