void ShowForm(string header, string name, FinanceForm form) { var tabControl = FindMetroTabControl(name); if (tabControl != null) { var mainTabItem = FindMainTabItem(tabControl); if (null != mainTabItem) { mainTabItem.IsSelected = true; var tabName = SUB_TAB_PREFIX + name; var me = MainMenuTab.FindName(tabName) as MetroTabItem; if (me != null) { me.IsSelected = true; return; } if (form is FormUdefReport) { form.Name = name; var frmUdfReport = form as FormUdefReport; frmUdfReport.xTitle = header; frmUdfReport.ShowSelectedItemEvent += (id) => { var frmVoucher = FindForm("voucher_input") as FormVoucher; if (frmVoucher == null) { frmVoucher = new FormVoucher(); } frmVoucher.VoucherId = id; ShowForm("凭证录入", "voucher_input", frmVoucher); }; } MetroTabItem tabItem = new MetroTabItem(); tabItem.Header = header; tabItem.Content = form; tabItem.Name = tabName; tabControl.Items.Add(tabItem); MainMenuTab.RegisterName(tabName, tabItem); tabItem.IsSelected = true; tabItem.ButtonClick += TabItem_ButtonClick; } } }
private void menu_click(object sender, RoutedEventArgs e) { try { var menu = (sender as Button).Name; switch (menu) { case "auxiliary_form": AuxiliaryPopup popup = new AuxiliaryPopup(Finance.Account.Controls.Commons.AuxiliaryType.Invalid); popup.SelectedEvent += (auxiliaryObj) => { FinanceMessageBox.Info(auxiliaryObj.name); }; popup.Show(); break; case "user_list": ShowForm("用户列表", "FormUser", new FormUser()); break; case "account_subject": ShowForm("科目", "FormAccountSubject", new FormAccountSubject()); break; case "begin_balance": ShowForm("初始余额表", "FormBeginBalance", new FormBeginBalance()); break; case "voucher_input": ShowForm("凭证录入", "FormVoucher", new FormVoucher()); break; case "voucher_list": var frm = new FormVoucherList(); frm.ShowSelectedItemEvent += (id) => { var frmVoucher = FindForm("FormVoucher") as FormVoucher; if (frmVoucher == null) { frmVoucher = new FormVoucher(); ShowForm("凭证录入", "FormVoucher", frmVoucher); } frmVoucher.VoucherId = id; }; ShowForm("凭证列表", "FormVoucherList", frm); break; case "account_balance": ShowForm("科目余额表", "FormAccountBalance", new FormAccountBalance()); break; case "cashflow_sheet": ShowForm("现金流量表", "FormCashflowSheet", new FormCashflowSheet()); break; case "balance_sheet": ShowForm("资产负债表", "FormBalanceSheet", new FormBalanceSheet()); break; case "profit_sheet": ShowForm("利润表", "FormProfitSheet", new FormProfitSheet()); break; case "settle": MessageBoxResult mbr = FinanceMessageBox.Quest("确认现在结账吗?"); if (mbr == MessageBoxResult.Yes) { bool bEnd = false; bool bTmp = false; string message = "结账完成"; Task task = Task.Run(() => { try { DataFactory.Instance.GetAccountBalanceExecuter().Settle(); } catch (Exception ex) { message = ex.Message; } bEnd = true; }); FinanceMessageBox.Progress("开始结账...", (args) => { bTmp = !bTmp; args.Message = "正在结账 " + (bTmp ? "..." : ""); args.Close = bEnd; }); FinanceMessageBox.Info(message); } break; } } catch (Exception ex) { FinanceMessageBox.Error(ex.Message); } }
private void MenuItemVoucher_Click(object sender, EventArgs e) { FormVoucher Frm = FormVoucher.GetForm(); ShowForm(Frm); }
void menuDispatch(string name) { try { switch (name) { case "abount": ShowForm("user_list"); break; case "voucher_list": var frm = new FormVoucherList(); frm.ShowSelectedItemEvent += (id) => { var frmVoucher = FindForm("voucher_input") as FormVoucher; if (frmVoucher == null) { frmVoucher = new FormVoucher(); } frmVoucher.VoucherId = id; ShowForm("凭证录入", "voucher_input", frmVoucher); }; ShowForm("凭证列表", name, frm); break; case "settle": MessageBoxResult mbr = FinanceMessageBox.Quest("确认现在结账吗?"); if (mbr == MessageBoxResult.Yes) { bool bEnd = false; bool bTmp = false; string message = "结账完成"; Task task = Task.Run(() => { try { DataFactory.Instance.GetAccountBalanceExecuter().Settle(); } catch (Exception ex) { message = ex.Message; } bEnd = true; }); FinanceMessageBox.Progress("开始结账...", (args) => { bTmp = !bTmp; args.Message = "正在结账 " + (bTmp ? "..." : ""); args.Close = bEnd; }); FinanceMessageBox.Info(message); } break; default: ShowForm(name); break; } } catch (Exception ex) { FinanceMessageBox.Error(ex.Message); } }