Exemplo n.º 1
0
        private void EditRule()
        {

            if (listViewContractsRules.SelectedItems.Count > 0)
            {
                ContractAccountingRule rule = listViewContractsRules.SelectedItems[0].Tag as ContractAccountingRule;
                FrmAddContractAccountingRule frmEditAccountingRule = new FrmAddContractAccountingRule {AccountingRule = rule};
                while (frmEditAccountingRule.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        ServicesProvider.GetInstance().GetAccountingRuleServices().UpdateAccountingRule(
                            frmEditAccountingRule.AccountingRule);
                        var editedRule =
                            ServicesProvider.GetInstance().GetAccountingRuleServices().Select(rule.Id) as
                            ContractAccountingRule;

                        int index = listViewContractsRules.Items.IndexOf(listViewContractsRules.SelectedItems[0]);
                        listViewContractsRules.Items[index] = GetListViewItem(editedRule);
                        CoreDomainProvider.GetInstance().GetChartOfAccounts().AccountingRuleCollection =
                            ServicesProvider.GetInstance().GetAccountingRuleServices().SelectAll();

                        break;
                    }
                    catch (Exception ex)
                    {
                        frmEditAccountingRule.Show(this);
                        new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                        frmEditAccountingRule.Hide();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void AddRule()
        {
            FrmAddContractAccountingRule frmAddAccountingRule = new FrmAddContractAccountingRule(_maxOrder);
            
            while (frmAddAccountingRule.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    int id =
                        ServicesProvider.GetInstance().GetAccountingRuleServices().SaveAccountingRule(frmAddAccountingRule.AccountingRule);

                    listViewContractsRules.Items.Add(
                        GetListViewItem(
                            ServicesProvider.GetInstance().GetAccountingRuleServices().Select(id) as
                            ContractAccountingRule));
                    CoreDomainProvider.GetInstance().GetChartOfAccounts().AccountingRuleCollection =
                        ServicesProvider.GetInstance().GetAccountingRuleServices().SelectAll();
                    _maxOrder = frmAddAccountingRule.AccountingRule.Order;
                    break;
                }
                catch (Exception ex)
                {
                    frmAddAccountingRule.Show(this);
                    new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                    frmAddAccountingRule.Hide();
                }
            }
        }
Exemplo n.º 3
0
        private void EditRule()
        {

            if (listViewContractsRules.SelectedItems.Count > 0)
            {
                ContractAccountingRule rule = listViewContractsRules.SelectedItems[0].Tag as ContractAccountingRule;
                FrmAddContractAccountingRule frmEditAccountingRule = new FrmAddContractAccountingRule {AccountingRule = rule};
                while (frmEditAccountingRule.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        ServicesProvider.GetInstance().GetAccountingRuleServices().UpdateAccountingRule(
                            frmEditAccountingRule.AccountingRule);
                        var editedRule =
                            ServicesProvider.GetInstance().GetAccountingRuleServices().Select(rule.Id) as
                            ContractAccountingRule;

                        int index = listViewContractsRules.Items.IndexOf(listViewContractsRules.SelectedItems[0]);
                        listViewContractsRules.Items[index] = GetListViewItem(editedRule);
                        CoreDomainProvider.GetInstance().GetChartOfAccounts().AccountingRuleCollection =
                            ServicesProvider.GetInstance().GetAccountingRuleServices().SelectAll();

                        break;
                    }
                    catch (Exception ex)
                    {
                        frmEditAccountingRule.Show(this);
                        new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                        frmEditAccountingRule.Hide();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void AddRule()
        {
            FrmAddContractAccountingRule frmAddAccountingRule = new FrmAddContractAccountingRule(_maxOrder);
            
            while (frmAddAccountingRule.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    int id =
                        ServicesProvider.GetInstance().GetAccountingRuleServices().SaveAccountingRule(frmAddAccountingRule.AccountingRule);

                    listViewContractsRules.Items.Add(
                        GetListViewItem(
                            ServicesProvider.GetInstance().GetAccountingRuleServices().Select(id) as
                            ContractAccountingRule));
                    CoreDomainProvider.GetInstance().GetChartOfAccounts().AccountingRuleCollection =
                        ServicesProvider.GetInstance().GetAccountingRuleServices().SelectAll();
                    _maxOrder = frmAddAccountingRule.AccountingRule.Order;
                    break;
                }
                catch (Exception ex)
                {
                    frmAddAccountingRule.Show(this);
                    new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                    frmAddAccountingRule.Hide();
                }
            }
        }