Example #1
0
        void Popup()
        {
            var item = datagrid.SelectedItem as AccountSubject;

            if (item != null)
            {
                var frm = new FormAccountSubjectPopup();
                frm.ItemSource     = item;
                frm.AfterSaveEvent = new AfterSaveEventHandler(() => {
                    FinanceForm_Loaded(datagrid, null);
                });
                frm.ShowDialog();
            }
            else
            {
                FinanceMessageBox.Info("请选中一个科目");
            }
        }
Example #2
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var txt = (sender as Button).Name;
                switch (txt)
                {
                case "new":
                    var frm = new FormAccountSubjectPopup();
                    frm.AfterSaveEvent = new AfterSaveEventHandler(() => {
                        FinanceForm_Loaded(datagrid, null);
                    });
                    frm.ShowDialog();
                    break;

                case "modify":
                    Popup();
                    break;

                case "delete":
                    var item = datagrid.SelectedItem as AccountSubject;
                    if (item != null)
                    {
                        var ret = FinanceMessageBox.Quest(string.Format("确认要删除科目[{0}-{1}]吗?", item.no, item.name));
                        if (MessageBoxResult.Yes == ret)
                        {
                            DataFactory.Instance.GetAccountSubjectExecuter().Delete(item.id);
                            FinanceForm_Loaded(datagrid, null);
                        }
                    }
                    else
                    {
                        FinanceMessageBox.Info("请选中一个科目");
                    }
                    break;

                case "disable":
                    var item1 = datagrid.SelectedItem as AccountSubject;
                    if (item1 != null)
                    {
                        var ret = FinanceMessageBox.Quest(string.Format("确认要禁用科目[{0}-{1}]吗?", item1.no, item1.name));
                        if (MessageBoxResult.Yes == ret)
                        {
                            DataFactory.Instance.GetAccountSubjectExecuter().SetStatus(item1.id, 1);
                            FinanceForm_Loaded(datagrid, null);
                        }
                    }
                    else
                    {
                        FinanceMessageBox.Info("请选中一个科目");
                    }
                    break;

                case "enable":
                    var item2 = datagrid.SelectedItem as AccountSubject;
                    if (item2 != null)
                    {
                        var ret = FinanceMessageBox.Quest(string.Format("确认要启用科目[{0}-{1}]吗?", item2.no, item2.name));
                        if (MessageBoxResult.Yes == ret)
                        {
                            DataFactory.Instance.GetAccountSubjectExecuter().SetStatus(item2.id, 0);
                            FinanceForm_Loaded(datagrid, null);
                        }
                    }
                    else
                    {
                        FinanceMessageBox.Info("请选中一个科目");
                    }
                    break;

                case "refresh":
                    FinanceForm_Loaded(datagrid, null);
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                FinanceMessageBox.Error(ex.Message);
            }
        }