Пример #1
0
        public void Should_convert_cost_center_response_to_cost_center()
        {
            var costCenter =
                _costCenterConverter.ConvertCostCenterResponse(_middlewareData.GetCostCenterData(), _session.Office);

            Assert.IsNotNull(costCenter);
        }
Пример #2
0
        public void ChangeData <T>(Twinfield.DataChangeTypes changeType, System.Type dataType, List <T> item) where T : class
        {
            var response = string.Empty;

            if (dataType == typeof(CustomerResponse))
            {
                foreach (var t in item)
                {
                    var x = t as CustomerResponse;
                    if (x.Code == _form.dataVeld.GetItemText(_form.dataVeld.SelectedItem))
                    {
                        var c = _customerConverter.ConvertCustomerResponse(x, _session.Office);
                        if (changeType == Twinfield.DataChangeTypes.Create)
                        {
                            response = _customerInterface.Create(c);
                        }

                        if (changeType == Twinfield.DataChangeTypes.Delete)
                        {
                            response = _customerInterface.Delete(c);
                        }
                    }
                }
            }
            if (dataType == typeof(SupplierResponse))
            {
                foreach (var t in item)
                {
                    var x = t as SupplierResponse;
                    if (x.Code == _form.dataVeld.GetItemText(_form.dataVeld.SelectedItem))
                    {
                        var s = _supplierConverter.ConvertSupplierResponse(x, _session.Office);
                        if (changeType == Twinfield.DataChangeTypes.Create)
                        {
                            response = _supplierInterface.Create(s);
                        }

                        if (changeType == Twinfield.DataChangeTypes.Delete)
                        {
                            response = _supplierInterface.Delete(s);
                        }
                    }
                }
            }
            if (dataType == typeof(Product))
            {
                foreach (var t in item)
                {
                    var x = t as Product;
                    if (x.Code == _form.dataVeld.GetItemText(_form.dataVeld.SelectedItem))
                    {
                        var a = _articleConverter.ConvertProduct(x, _session.Office, "IN");
                        if (changeType == Twinfield.DataChangeTypes.Create)
                        {
                            response = _articleInterface.Create(a);
                        }

                        if (changeType == Twinfield.DataChangeTypes.Delete)
                        {
                            response = _articleInterface.Delete(a);
                        }
                    }
                }
            }
            if (dataType == typeof(SalesInvoiceResponse))
            {
                foreach (var t in item)
                {
                    var x = t as SalesInvoiceResponse;
                    if (x.InvoiceTypeAndNumber == _form.dataVeld.GetItemText(_form.dataVeld.SelectedItem))
                    {
                        var si = _salesInvoiceConverter.ConvertSalesInvoiceResponse(x, "IN");
                        if (changeType == Twinfield.DataChangeTypes.Create)
                        {
                            response = _salesInvoiceInterface.Create(si);
                        }
                    }
                }
            }
            if (dataType == typeof(GeneralLedgerResponse))
            {
                foreach (var t in item)
                {
                    var x = t as GeneralLedgerResponse;
                    if (x.Code == _form.dataVeld.GetItemText(_form.dataVeld.SelectedItem))
                    {
                        var glb = _generalLedgerConverter.ConvertGeneralLedgerResponseToBalanceSheet(x,
                                                                                                     _session.Office);
//                        var glp = _generalLedgerConverter.ConvertGeneralLedgerResponseToProfitLoss(x,
//                            _session.Office);
//                        if (int.Parse(glb.Code) <= 3999)
//                        {
                        if (changeType == Twinfield.DataChangeTypes.Create)
                        {
                            response = _balanceSheetInterface.Create(glb);
                        }

                        if (changeType == Twinfield.DataChangeTypes.Delete)
                        {
                            response = _balanceSheetInterface.Delete(glb);
                        }
//                        }
//                        else
//                        {
//                            if (changeType == Twinfield.DataChangeTypes.Create)
//                            {
//                                response = _profitLossInterface.Create(glp);
//                            }
//
//                            if (changeType == Twinfield.DataChangeTypes.Delete)
//                            {
//                                response = _profitLossInterface.Delete(glp);
//                            }
//                        }
                    }
                }
            }
            if (dataType == typeof(CostCenterResponse))
            {
                foreach (var t in item)
                {
                    var x = t as CostCenterResponse;
                    if (x.Code == _form.dataVeld.GetItemText(_form.dataVeld.SelectedItem))
                    {
                        var cc = _costCenterConverter.ConvertCostCenterResponse(x, _session.Office);
                        if (changeType == Twinfield.DataChangeTypes.Create)
                        {
                            response = _costCenterInterface.Create(cc);
                        }

                        if (changeType == Twinfield.DataChangeTypes.Delete)
                        {
                            response = _costCenterInterface.Delete(cc);
                        }
                    }
                }
            }
            if (response == "Created")
            {
                _form.resultBar.BackColor = Color.Chartreuse;
                _form.LogBox.AppendText("\r\nData aangemaakt in administratie");
            }
            else if (response == "Deleted")
            {
                _form.resultBar.BackColor = Color.Chartreuse;
                _form.LogBox.AppendText("\r\nData verwijderd uit administratie");
            }
            else
            {
                _form.resultBar.BackColor = Color.Red;
                if (changeType == Twinfield.DataChangeTypes.Create)
                {
                    _form.LogBox.AppendText("\r\nData kan niet aangemaakt worden in administratie");
                }

                if (changeType == Twinfield.DataChangeTypes.Delete)
                {
                    _form.LogBox.AppendText("\r\nData kan niet verwijderd worden uit administratie");
                }
                _form.LogBox.AppendText("\r\nError: " + response);
            }
            _form.LogBox.ScrollToCaret();
            _form.Cursor = Cursors.Arrow;
        }