예제 #1
0
        void UpdateContract(bool isnew)
        {
            var restClient = (ContractsRestClient)DataProcessor.GetRestClient("ContractsRestClient");
            var updated    = GetUpdatedContract();

            _contractUniqueNumber = updated.UniqueNumber;
            if (isnew)
            {
                if (AlreadyExistContractAndServiceType(updated))
                {
                    return;
                }
                if (_isnewOrganization)
                {
                    _frmParent.Contracts = new List <Contract> {
                        updated
                    };
                    _frmParent.UpdateOrganization(true);
                    Dirty = false;
                    this.Close();
                    return;
                }
                _contract             = restClient.CreateContract(updated);
                _contractUniqueNumber = _contract.UniqueNumber;
                _isnew = false;
            }
            else
            {
                restClient.UpdateContract(updated);
            }
            RefreshData();
            _frmParent.RefreshContracts();
        }
예제 #2
0
        private void EditorOnButtonClick(object sender, ButtonPressedEventArgs buttonPressedEventArgs)
        {
            try
            {
                var restClient = (OrdersDocumentsRestClient)DataProcessor.GetRestClient("OrdersDocumentsRestClient");
                var o          = gridViewDocuments.GetRow(gridViewDocuments.FocusedRowHandle);
                var od         = o as OrderDocumentInfoDecorator;

                OrderDocument orderDocument = restClient.GetOrderDocument(_orderUniqueNumber, od.Code);

                string filePath = Path.Combine(Path.GetTempPath(), orderDocument.Name);
                File.WriteAllBytes(filePath, orderDocument.Content);
                Process.Start(new ProcessStartInfo {
                    FileName = filePath, UseShellExecute = true
                });
            }
            catch (LogicalApiException e)
            {
                MessageBox.Show(String.Format("Ошибка. Код: {0}. Сообщение: {1}", e.Code, e.Message));
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("Ошибка. {0}", e.Message));
            }
        }
예제 #3
0
        public void UpdateOrganization(bool isnew)
        {
            var          restClient = (OrganizationRestClient)DataProcessor.GetRestClient("OrganizationRestClient");
            Organization updated    = GetUpdatedOrganization();

            _organizationcode = updated.Code;
            if (_organizationcode == "")
            {
                return;
            }
            if (isnew)
            {
                try
                {
                    restClient.CreateOrganization(updated, Contracts);
                }
                catch (LogicalApiException ex)
                {
                    MessageBox.Show(Utils.ErrorMsg(ex), "Desktop", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                restClient.UpdateOrganization(updated);
            }
            RefreshData();
        }
예제 #4
0
        private void btnReassign_Click(object sender, EventArgs e)
        {
            if (txtNewOrderNumber.Text.Trim() == "")
            {
                MessageBox.Show("Номер заявки не указан", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            string msg = string.Format("Вы уверены, что хотите перенести отчет об оплате № {0} с заявки {1} на заявку {2}"
                                       , _paymentReportUniqueNumber, _paymentReport.OrderUniqueNumber, txtNewOrderNumber.Text.Trim());
            DialogResult result = MessageBox.Show(msg, "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }
            var restClient = (PaymentReportsRestClient)DataProcessor.GetRestClient("PaymentReportsRestClient");

            try
            {
                //restClient.ReassignPaymentReport(_paymentReportUniqueNumber, txtNewOrderNumber.Text.Trim());
                MessageBox.Show("Отчет об оплате успешно перенесен.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format(ex.Message), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #5
0
        void UpdateSite(bool isnew)
        {
            if (!Dirty && !isnew)
            {
                return;
            }
            string errmsg = CheckFields();

            if (errmsg != "")
            {
                MessageBox.Show(errmsg, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                var restClient = (SiteRestClient)DataProcessor.GetRestClient("SiteRestClient");
                var updated    = GetUpdatedSite();
                if (isnew)
                {
                    _site  = restClient.CreateSite(updated);
                    _isnew = false;
                    string siteinfo = String.Format(
                        "Скопируйте и сохраните эту информацию.\r\n" +
                        "Создан новый сайт: \r\n " +
                        "SiteSlug: {0}\r\n" +
                        "Название: {1}\r\n" +
                        "Код организации: {2}\r\n" +
                        "API key: {3}"
                        , _site.SiteSlug
                        , _site.Name
                        , _site.OrganizationCode
                        , _site.ApiKey
                        );
                    _siteslug = _site.SiteSlug;
                    new DlgInfoText("Создан новый сайт", siteinfo).ShowDialog();
                }
                else
                {
                    restClient.UpdateSite(updated);
                }
            }
            catch (LogicalApiException ex)
            {
                if (ex.Code == ErrorCode.SiteAlreadyExists)
                {
                    MessageBox.Show("Сайт с таким кодом уже существует", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show(ex.Message, "Ошибка API", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            RefreshData();
        }
예제 #6
0
        static List <OrganizationInfoDecorator> _buyers;        //singleton

        public static IList <ReportTemplateInfo> GetReportTemplatesInfo(bool reload = false)
        {
            if (_reportTemplatesInfo == null || reload)
            {
                var restClient = (ReportsRestClient)DataProcessor.GetRestClient("ReportsRestClient");
                _reportTemplatesInfo = restClient.GetReportTemplatesInfo();
            }
            return(_reportTemplatesInfo);
        }
예제 #7
0
        private void SaveToServer()
        {
            var stream = new MemoryStream();

            xrDesignMdiController1.ActiveDesignPanel.Report.SaveLayout(stream);
            _template.TemplateContent = stream.ToArray();
            var restClient = (ReportsRestClient)DataProcessor.GetRestClient("ReportsRestClient");

            restClient.SaveReportTemplate(_template);
        }
예제 #8
0
        public static Organization LoggedOrganization()
        {
            if (_loggedOrganization == null)
            {
                var siteRestClient = (SiteRestClient)DataProcessor.GetRestClient("SiteRestClient");
                var org            = siteRestClient.GetSite(Config.SiteSlug);

                var restClient = (OrganizationRestClient)DataProcessor.GetRestClient("OrganizationRestClient");
                _loggedOrganization = restClient.GetOrganization(org.OrganizationCode);
            }
            return(_loggedOrganization);
        }
예제 #9
0
        private void FrmAbout_Load(object sender, EventArgs e)
        {
            lblVersion.Text += System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            var restClient = (SystemRestClient)DataProcessor.GetRestClient("SystemRestClient");
            ServerSystemInfo serverSystemInfo = restClient.GetServerSystemInfo();

            lblApiVersion.Text += serverSystemInfo.Version;

            lblUrl.Text      += Config.Url;
            lblSiteslug.Text += Config.SiteSlug;
        }
예제 #10
0
 void GetPaymentReport()
 {
     try
     {
         var restClient = (PaymentReportsRestClient)DataProcessor.GetRestClient("PaymentReportsRestClient");
         _paymentReport = restClient.GetPaymentReport(_paymentReportUniqueNumber);
     }
     catch (LogicalApiException e)
     {
         MessageBox.Show(String.Format("Ошибка. Код: {0}. Сообщение: {1}", e.Code, e.Message));
     }
 }
예제 #11
0
 void GetOrder()
 {
     try
     {
         var restClient    = (OrdersRestClient)DataProcessor.GetRestClient("OrdersRestClient");
         var ordersPayload = restClient.GetOrder(_orderUniqueNumber).Payload as OrdersPayloadElement;
         _order = new OrderDecorator(ordersPayload.Orders[0]);
         RefreshOrder();
     }
     catch (LogicalApiException e)
     {
         //MessageBox.Show(String.Format("Ошибка. Код: {0}. Сообщение: {1}", e.Code, e.Message));
     }
 }
예제 #12
0
        private void SaveCopyToServer()
        {
            var dlg = new DlgSaveReportTemplate(Guid.NewGuid().ToString(), _template.TypeCodes, _template.Name + " Copy");

            dlg.ShowDialog();
            if (dlg.DialogResult == DialogResult.OK)
            {
                var newtemplate = new ReportTemplate(dlg.name, dlg.TypeCodes, dlg.code);
                var stream      = new MemoryStream();
                xrDesignMdiController1.ActiveDesignPanel.Report.SaveLayout(stream);
                newtemplate.TemplateContent = stream.ToArray();
                var restClient = (ReportsRestClient)DataProcessor.GetRestClient("ReportsRestClient");
                restClient.SaveReportTemplate(newtemplate);
            }
        }
예제 #13
0
        private void RefreshFormulas()
        {
            if (_formulas != null)
            {
                _formulas.Sort((f1, f2) => f1.Number.CompareTo(f2.Number));
            }
            gridFormulas.DataSource = null;
            gridFormulas.DataSource = _formulas;
            var restClient = (ContractsRestClient)DataProcessor.GetRestClient("ContractsRestClient");
            var riCombo    = new RepositoryItemLookUpEdit();

            riCombo.EditValueChanged += RiComboOnEditValueChanged;
            riCombo.DataSource        = restClient.GetPriceRowTypes();
            riCombo.NullText          = "";

            gridFormulas.RepositoryItems.Add(riCombo);
            riCombo.ValueMember   = "Code";
            riCombo.DisplayMember = "Code";
            if (gridViewFormulas.Columns.Count > 1)
            {
                gridViewFormulas.Columns[2].ColumnEdit = riCombo;
            }
        }
예제 #14
0
        void GetUser()
        {
            var restClient = (UserRestClient)DataProcessor.GetRestClient("UserRestClient");

            _user = restClient.GetUser(_siteslug, _email);
        }
예제 #15
0
        void GetContract()
        {
            var restClient = (ContractsRestClient)DataProcessor.GetRestClient("ContractsRestClient");

            _contract = restClient.GetContract(_contractUniqueNumber);
        }
예제 #16
0
        void GetOrganization()
        {
            var restClient = (OrganizationRestClient)DataProcessor.GetRestClient("OrganizationRestClient");

            _organization = restClient.GetOrganization(_organizationcode);
        }
예제 #17
0
        void GetSite()
        {
            var restClient = (SiteRestClient)DataProcessor.GetRestClient("SiteRestClient");

            _site = restClient.GetSite(_siteslug);
        }