Exemplo n.º 1
0
        private void functieUitvoeren_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (!radioButton1.Checked)
            {
                switch (functie.Text)
                {
                case ReadText:

                    try
                    {
                        switch (DataComboBox.Text)
                        {
                        case CustomersText:
                            _ldf.LoadData(_customerInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case SuppliersText:
                            _ldf.LoadData(_supplierInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case ArticlesText:
                            _ldf.LoadData(_articleInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case SalesInvoicesText:
                            var      data  = dataVeld.GetItemText(dataVeld.SelectedItem);
                            string[] items = data.Split(',');
                            _ldf.LoadData(_salesInvoiceInterface.Read(items[1], items[0]));
                            break;

                        case BalanceSheetsText:
                            _ldf.LoadData(_balanceSheetInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case ProfitAndLossText:
                            _ldf.LoadData(_profitLossInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case CostCentersText:
                            _ldf.LoadData(_costCenterInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;
                        }

                        this.Cursor = Cursors.Arrow;
                        break;
                    }
                    catch (Exception ex)
                    {
                        this.Cursor         = Cursors.Arrow;
                        resultBar.BackColor = Color.Red;
                        LogBox.AppendText("\r\nDe data kan niet gelezen worden");
                        LogBox.AppendText("\r\nError: " + ex.Message);
                        break;
                    }

                case ConvertText:
                    try
                    {
                        switch (DataComboBox.Text)
                        {
                        case CustomersText:
                            _ldf.ConvertData(_customerInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case SuppliersText:
                            _ldf.ConvertData(_supplierInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case ArticlesText:
                            _ldf.ConvertData(_articleInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case SalesInvoicesText:
                            var      data  = dataVeld.GetItemText(dataVeld.SelectedItem);
                            string[] items = data.Split(',');
                            _ldf.ConvertData(_salesInvoiceInterface.Read(items[1], items[0]));
                            break;

                        case BalanceSheetsText:
                            _ldf.ConvertData(_balanceSheetInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case ProfitAndLossText:
                            _ldf.ConvertData(_profitLossInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;

                        case CostCentersText:
                            _ldf.ConvertData(_costCenterInterface.Read(dataVeld.GetItemText(dataVeld.SelectedItem)));
                            break;
                        }
                        break;
                    }
                    catch (Exception exception)
                    {
                        LogBox.AppendText(
                            "\r\nDe data kan niet geconverteerd worden naar de middleware");
                        LogBox.AppendText("\r\nError: " + exception.Message);
                        Cursor.Current      = Cursors.Arrow;
                        resultBar.BackColor = Color.Red;
                        break;
                    }

                case @"None":
                    LogBox.AppendText("\r\nEr moet eerst data ingeladen worden.");
                    break;
                }
            }
            else
            {
                switch (functie.Text)
                {
                case ReadText:
                    switch (DataComboBox.Text)
                    {
                    case CustomersText:

                        _ldf.LoadDataMiddleware(typeof(CustomerResponse), Gegevens);
                        break;

                    case SuppliersText:
                        _ldf.LoadDataMiddleware(typeof(SupplierResponse), Gegevens);
                        break;

                    case ArticlesText:
                        _ldf.LoadDataMiddleware(typeof(Product), Gegevens);
                        break;

                    case SalesInvoicesText:
                        _ldf.LoadDataMiddleware(typeof(SalesInvoiceResponse), Gegevens);
                        break;

                    case BalanceSheetsText:
                        _ldf.LoadDataMiddleware(typeof(GeneralLedgerResponse), Gegevens);
                        break;

                    case ProfitAndLossText:
                        _ldf.LoadDataMiddleware(typeof(GeneralLedgerResponse), Gegevens);
                        break;

                    case CostCentersText:
                        _ldf.LoadDataMiddleware(typeof(CostCenterResponse), Gegevens);
                        break;
                    }

                    break;

                case CreateText:
                    switch (DataComboBox.Text)
                    {
                    case CustomersText:
                        _ldf.ChangeData(DataChangeTypes.Create, typeof(CustomerResponse), Gegevens);
                        break;

                    case SuppliersText:
                        _ldf.ChangeData(DataChangeTypes.Create, typeof(SupplierResponse), Gegevens);
                        break;

                    case ArticlesText:
                        _ldf.ChangeData(DataChangeTypes.Create, typeof(Product), Gegevens);
                        break;

                    case SalesInvoicesText:
                        _ldf.ChangeData(DataChangeTypes.Create, typeof(SalesInvoiceResponse), Gegevens);
                        break;

                    case BalanceSheetsText:
                        _ldf.ChangeData(DataChangeTypes.Create, typeof(GeneralLedgerResponse), Gegevens);
                        break;

                    case ProfitAndLossText:
                        _ldf.ChangeData(DataChangeTypes.Create, typeof(GeneralLedgerResponse), Gegevens);
                        break;

                    case CostCentersText:
                        _ldf.ChangeData(DataChangeTypes.Create, typeof(CostCenterResponse), Gegevens);
                        break;
                    }

                    break;

                case DeleteText:
                    switch (DataComboBox.Text)
                    {
                    case CustomersText:
                        _ldf.ChangeData(DataChangeTypes.Delete, typeof(CustomerResponse), Gegevens);
                        break;

                    case SuppliersText:
                        _ldf.ChangeData(DataChangeTypes.Delete, typeof(SupplierResponse), Gegevens);
                        break;

                    case ArticlesText:
                        _ldf.ChangeData(DataChangeTypes.Delete, typeof(Product), Gegevens);
                        break;

                    case SalesInvoicesText:
                        LogBox.AppendText(
                            "\r\nSales invoices kunnen niet verwijderd worden in Twinfield");
                        break;

                    case BalanceSheetsText:
                        _ldf.ChangeData(DataChangeTypes.Delete, typeof(GeneralLedgerResponse), Gegevens);
                        break;

                    case ProfitAndLossText:
                        _ldf.ChangeData(DataChangeTypes.Delete, typeof(GeneralLedgerResponse), Gegevens);
                        break;

                    case CostCentersText:
                        _ldf.ChangeData(DataChangeTypes.Delete, typeof(CostCenterResponse), Gegevens);
                        break;
                    }
                    break;
                }
            }

            LogBox.ScrollToCaret();
        }