コード例 #1
0
        //Клик на кнопку сохранения оборудования/модификации
        void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!validate())
            {
                return;
            }
            equipmentBid.Id_equipment = (int)cbxEquipment.SelectedValue;
            if (cbxModification.SelectedIndex != -1)
            {
                equipmentBid.Id_modification = (int)cbxModification.SelectedValue;
            }
            else
            {
                equipmentBid.Id_modification = null;
            }
            loadingProgress.Visibility = Visibility.Visible;
            IsEnabled = false;

            Task.Factory.StartNew(() => {
                if (equipmentBid.save())
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { successSave(); }));
                }
                else
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { errorSave(); }));
                }
            });
        }
コード例 #2
0
        //Клик по кнопке печати бланков
        void BtnPrintBlank_Click(object sender, RoutedEventArgs e)
        {
            Bid bid = dgvBid.SelectedItem as Bid;

            if (bid == null)
            {
                return;
            }

            Buyer buyer = BuyerViewModel.instance().getById(bid.Id_buyer);

            if (buyer == null)
            {
                return;
            }

            var openFolderDialog = new System.Windows.Forms.FolderBrowserDialog();

            if (iniFile.KeyExists("report_path") && System.IO.Directory.Exists(iniFile.Read("report_path")))
            {
                openFolderDialog.SelectedPath = iniFile.Read("report_path");
            }
            System.Windows.Forms.DialogResult result =
                openFolderDialog.ShowDialog(Classes.OpenDirectoryDialog.GetIWin32Window(this));

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                processControl.Visibility = Visibility.Visible;
                Task.Factory.StartNew(() => {
                    int reportCount = bid.EquipmentBidCollection.Count;
                    for (int i = 0; i < reportCount; i++)
                    {
                        Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Text = "Формирование бланков " + (i + 1).ToString() + " из " + reportCount.ToString(); }));
                        EquipmentBid equipmentBid = bid.EquipmentBidCollection[i];
                        string fileName           = "Бланк заявки №" + bid.Id.ToString() + "-" + equipmentBid.Id.ToString() + " " + bid.Account + " " + buyer.Name + ".xlsx";
                        Reports.BidBlank bidBlank = new StangradCRM.Reports.BidBlank(bid, equipmentBid);
                        bidBlank.FileName         = openFolderDialog.SelectedPath + "/" + Classes.ReplaceSpecialCharsFileName.Replace(fileName);
                        if (!bidBlank.Save())
                        {
                            MessageBox.Show(bidBlank.LastError);
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Visibility = Visibility.Hidden; }));
                            return;
                        }
                        equipmentBid.Is_blank_print = 1;
                        if (!equipmentBid.save())
                        {
                            MessageBox.Show("Не удалось установить статус 'Бланк заявки сформирован' для оборудования в заявке\n" + equipmentBid.LastError);
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Visibility = Visibility.Hidden; }));
                            return;
                        }
                    }
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Visibility = Visibility.Hidden; }));
                    MessageBox.Show("Все бланки заявок сохранены в директорию '" + openFolderDialog.SelectedPath + "'");
                    iniFile.Write("report_path", openFolderDialog.SelectedPath);
                    System.Diagnostics.Process.Start(openFolderDialog.SelectedPath);
                });
            }
        }
コード例 #3
0
        void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button == null)
            {
                return;
            }

            DataGridRow row = Classes.FindItem.FindParentItem <DataGridRow>(button);

            if (row == null)
            {
                return;
            }

            EquipmentBid equipmentBid = row.Item as EquipmentBid;

            if (equipmentBid == null)
            {
                return;
            }

            if (MessageBox.Show("Вернуть в работу?", "Вернуть в работу?",
                                MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }

            equipmentBid.Is_archive = 0;
            Bid bid = BidViewModel.instance().getById(equipmentBid.Id_bid);

            if (!equipmentBid.save())
            {
                MessageBox.Show(equipmentBid.LastError);
                return;
            }
            else
            {
                if (bid != null)
                {
                    bid.Guid = Guid.NewGuid().ToString();
                    if (!bid.save())
                    {
                        MessageBox.Show("Не удалось обновить время модификации заявки!\nДругой специалист тех. отдела не увидит обновление\n" + bid.LastError);
                    }
                }
            }
            EquipmentBidViewModel.instance().updateStatus(equipmentBid);
        }