public void UpdateCompaniesList()
        {
            AppJournal.Write("Companies", "Update list", true);

            try {
                CompaniesList = DataBaseClient.ReadCompanies();
            } catch (Exception ex) { AppJournal.Write("Companies", "Get companies from db error :" + ex.ToString(), true); }
        }
Esempio n. 2
0
        private void UpdateCompaniesList(string filterText = "")
        {
            AppJournal.Write("Post|Companies", "Update list by filter", true);

            try {
                if (string.IsNullOrEmpty(FilterTxt))
                {
                    CompaniesList = DataBaseClient.ReadCompanies();
                }
                else
                {
                    CompaniesList = DataBaseClient.ReadCompanies(filterText);
                }
            } catch (Exception ex) { AppJournal.Write("Post|Companies", "Get companies by filter from db error :" + ex.ToString(), true); }
        }
        private void UpdateCompaniesList(string filterText, string filterBinText = null)
        {
            AppJournal.Write("Companies", "Update list by filter", true);

            try {
                CompaniesList = DataBaseClient.ReadCompanies(filterText, filterBinText);
                if (string.IsNullOrEmpty(FilterTxt) && string.IsNullOrEmpty(FilterBinTxt))
                {
                    CompaniesList = DataBaseClient.ReadCompanies();
                }
                else if (!string.IsNullOrEmpty(FilterTxt) && string.IsNullOrEmpty(FilterBinTxt))
                {
                    CompaniesList = DataBaseClient.ReadCompanies(FilterTxt, null);
                }
                else if (string.IsNullOrEmpty(FilterTxt) && !string.IsNullOrEmpty(FilterBinTxt))
                {
                    CompaniesList = DataBaseClient.ReadCompanies(null, FilterBinTxt);
                }
                else if (!string.IsNullOrEmpty(FilterTxt) && !string.IsNullOrEmpty(FilterBinTxt))
                {
                    CompaniesList = DataBaseClient.ReadCompanies(FilterTxt, FilterBinTxt);
                }
            } catch (Exception ex) { AppJournal.Write("Companies", "Get companies by filter from db error :" + ex.ToString(), true); }
        }
Esempio n. 4
0
        private void SaveDoc()
        {
            if (SelectedOtherDoc == null || SelectedOtherDoc.id == 0)  // Create
                                                                       // Fill
            {
                OtherDocsEF otherDoc = new OtherDocsEF()
                {
                    companyid      = DataBaseClient.ReadCompanies().FirstOrDefault(c => c.name == DocCompanyName).id,
                    brokerid       = SelectedBroker.id,
                    createdate     = DocCreateDate,
                    documenttypeid = SelectedDocType.id,
                    number         = DocNumber,
                    inpost         = false,
                    quantity       = DocQuantity
                };

                // Save
                int otherDocId = 0;

                try {
                    otherDocId = DataBaseClient.CreateOtherDoc(otherDoc);
                    IncludeVis = Visibility.Visible;

                    // Auto creation CertificateOfComplition when add InvoiceFacture
                    if (SelectedDocType.id == 31)
                    {
                        OtherDocsEF cCDoc = new OtherDocsEF()
                        {
                            companyid      = otherDoc.companyid,
                            brokerid       = SelectedBroker.id,
                            createdate     = DocCreateDate,
                            documenttypeid = 32,
                            number         = DocNumber,
                            inpost         = false,
                            quantity       = 2
                        };

                        DataBaseClient.CreateOtherDoc(cCDoc);
                    }
                } catch { MessagesService.Show("Оповещение", "Произошла ошибка во время сохранения в базу данных"); }

                // Update view
                UpdateOtherDocsList(otherDoc.companyid);
                SelectedOtherDoc = DataBaseClient.ReadOtherDoc(otherDocId);
            }
            else     // Update
            // Fill fields
            {
                SelectedOtherDoc.brokerid       = SelectedBroker.id;
                SelectedOtherDoc.createdate     = DocCreateDate;
                SelectedOtherDoc.documenttypeid = SelectedDocType.id;
                SelectedOtherDoc.number         = DocNumber;
                SelectedOtherDoc.quantity       = DocQuantity;

                // Save changes
                try {
                    DataBaseClient.UpdateOtherDoc(SelectedOtherDoc);
                } catch { MessagesService.Show("Оповещение", "Произошла ошибка во время сохранения в базу данных"); }

                // Update view
                UpdateOtherDocsList(SelectedOtherDoc.companyid);
            }

            DocDetailsVis = Visibility.Collapsed;
        }