public MainControlArchiveBid()
        {
            InitializeComponent();

            viewSource        = new CollectionViewSource();
            viewSource.Source = BidViewModel.instance().getArchiveCollection();

            viewSource.Filter += delegate(object sender, FilterEventArgs e)
            {
                Bid bid = e.Item as Bid;
                if (bid == null)
                {
                    return;
                }
                e.Accepted = bid.IsVisible;
            };

            DataContext = new
            {
                BidCollection = this.viewSource.View
            };
        }
        public AccountantMainWindow()
        {
            InitializeComponent();
            Title += " v" + Settings.version + ". Пользователь " + Auth.getInstance().Full_name + ". Режим бухгалтера.";

            try
            {
                int updateTime = int.Parse(CRMSettingViewModel.instance().getByMashineName("bid_update_time").Setting_value) * 1000;
                if (updateTime != 0)
                {
                    Classes.UpdateTask.Start(Dispatcher,
                                             new Action(() => { BidViewModel.instance().reload(); }),
                                             updateTime,
                                             new Action(() => { updateNotification.Visibility = Visibility.Hidden; }),
                                             new Action(() => { updateNotification.Visibility = Visibility.Visible; }));
                }
            }
            catch {}

            tiNewBid.Content     = new MainControlNewBid();
            tiInWorkBid.Content  = new MainControlInWork();
            tiArchiveBid.Content = new MainControlArchiveBid();
        }
Пример #3
0
        public static UserControl GetControl(int bidStatusId)
        {
            UserControl          control;
            CollectionViewSource viewSource = new CollectionViewSource();

            viewSource.Source = BidViewModel.instance().getCollectionByStatus(bidStatusId);

            viewSource.Filter += delegate(object sender, FilterEventArgs e)
            {
                Bid bid = e.Item as Bid;
                if (bid == null)
                {
                    return;
                }
                if (bid.Id_manager != Auth.getInstance().Id)
                {
                    e.Accepted = false;
                    return;
                }
                e.Accepted = bid.IsVisible;
            };
            switch (bidStatusId)
            {
            case 1:
                control = new MyBidControlID1(viewSource);
                break;

            case 2:
                control = new MyBidControlID2(viewSource);
                break;

            default:
                control = new StangradCRM.View.Controls.DefaultMainControl();
                break;
            }
            return(control);
        }
Пример #4
0
        public ArchiveControl(CollectionViewSource archiveViewSource)
        {
            InitializeComponent();
            viewSource = archiveViewSource;

            viewSource.Source  = BidViewModel.instance().Collection;
            viewSource.Filter += delegate(object sender, FilterEventArgs e)
            {
                Bid bid = e.Item as Bid;
                if (bid == null)
                {
                    return;
                }
                if (bid.IsShipped == true)
                {
                    e.Accepted = bid.IsVisible;
                }
                else
                {
                    e.Accepted = false;
                }
            };

            //Установка сортировки ---->
            //1: По статусу оплаты в порядке убывания (по id статусов)
            viewSource.SortDescriptions.Add(new SortDescription("Id_payment_status", ListSortDirection.Descending));
            //2: По дате отгрузки в порядке убывания
            viewSource.SortDescriptions.Add(new SortDescription("Shipment_date", ListSortDirection.Descending));
            //3: По дате создания в порядке убывания
            viewSource.SortDescriptions.Add(new SortDescription("Date_created", ListSortDirection.Descending));

            DataContext = new
            {
                BidCollection = viewSource.View
            };
        }
Пример #5
0
        public AdministratorMainWindow()
        {
            InitializeComponent();
            Title += " v" + Settings.version + ". Пользователь " + Auth.getInstance().Full_name + ". Режим администратора.";

            try
            {
                int updateTime = int.Parse(CRMSettingViewModel.instance().getByMashineName("bid_update_time").Setting_value) * 1000;
                if (updateTime != 0)
                {
                    Classes.UpdateTask.Start(Dispatcher,
                                             new Action(() => { BidViewModel.instance().reload(); }),
                                             updateTime,
                                             new Action(() => { updateNotification.Visibility = Visibility.Hidden; }),
                                             new Action(() => { updateNotification.Visibility = Visibility.Visible; }));
                }
            }
            catch {}

            menuOpenEquipmentWindow.Click += delegate
            {
                EquipmentWindow window = new EquipmentWindow();
                window.ShowDialog();
            };

            menuOpenComplectationItemWindow.Click += delegate
            {
                ComplectationItemWindow window = new ComplectationItemWindow();
                window.ShowDialog();
            };

            menuOpenBuyerWindow.Click += delegate
            {
                BuyerWindow window = new BuyerWindow();
                window.ShowDialog();
            };

            menuOpenSellerWindow.Click += delegate
            {
                SellerWindow window = new SellerWindow();
                window.ShowDialog();
            };

            menuOpenBidStatusWindow.Click += delegate
            {
                BidStatusWindow window = new BidStatusWindow();
                window.ShowDialog();
            };

            menuOpenPaymentStatusWindow.Click += delegate
            {
                PaymentStatusWindow window = new PaymentStatusWindow();
                window.ShowDialog();
            };

            menuOpenManagerWindow.Click += delegate
            {
                ManagerWindow window = new ManagerWindow();
                window.ShowDialog();
            };

            menuOpenTransportCompanyWindow.Click += delegate
            {
                TransportCompanyWindow window = new TransportCompanyWindow();
                window.ShowDialog();
            };

            menuOpenMessageTemplatesWindow.Click += delegate
            {
                MessageTemplatesWindow window = new MessageTemplatesWindow();
                window.ShowDialog();
            };

            tiCRMSetting.Content = new MainControlCRMSetting();
            tiBid.Content        = new MainControlBid();
        }
Пример #6
0
        //Клик по контекстному меню печати бланка
        void MiPrintBlank_Click(object sender, RoutedEventArgs e)
        {
            EquipmentBid equipmentBid = dgvEquipmentBid.SelectedItem as EquipmentBid;

            if (equipmentBid == null)
            {
                return;
            }

            Bid bid = BidViewModel.instance().getById(equipmentBid.Id_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)
            {
                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);

                processControl.Visibility = Visibility.Visible;
                processControl.Text       = "Сохранение бланка заявки...";

                Task.Factory.StartNew(() => {
                    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;
                    }
                    MessageBox.Show("Бланк заявки сохранен в директорию '" + openFolderDialog.SelectedPath + "'");
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Visibility = Visibility.Hidden; }));
                    iniFile.Write("report_path", openFolderDialog.SelectedPath);
                    System.Diagnostics.Process.Start(openFolderDialog.SelectedPath);
                });
            }
        }
Пример #7
0
        public override bool Save()
        {
            Bid bid = BidViewModel.instance().getById(equipmentBid.Id_bid);

            if (bid == null)
            {
                LastError = "Bid not found!";
                return(false);
            }
            Buyer buyer = BuyerViewModel.instance().getById(bid.Id_buyer);

            if (buyer == null)
            {
                LastError = "Buyer not found!";
                return(false);
            }

            Equipment equipment = EquipmentViewModel.instance().getById(equipmentBid.Id_equipment);

            if (equipment == null)
            {
                LastError = "Equipment not found!";
                return(false);
            }
            Modification modification = null;

            if (equipmentBid.Id_modification != null)
            {
                modification = ModificationViewModel.instance().getById((int)equipmentBid.Id_modification);
                if (modification != null)
                {
                    modificationString = modification.Name;
                }
            }

            ReportRow row = new ReportRow();

            row.Cells.Add(new ReportCell(buyer.Name.ToUpper())
            {
                ColumnSpan = 6,
                Height     = 20.25,
                TextStyle  = new List <TextStyle>()
                {
                    TextStyle.Bold
                },
            });
            row.Cells.Add(new ReportCell());
            row.Cells.Add(new ReportCell());
            row.Cells.Add(new ReportCell());
            row.Cells.Add(new ReportCell());
            row.Cells.Add(new ReportCell());
            row.Cells.Add(new ReportCell()
            {
                Width = 0.58, VerticalAlignment = VerticalAlignment.Bottom
            });
            row.Cells.Add(new ReportCell(buyer.City.ToUpper())
            {
                ColumnSpan          = 2,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                TextStyle           = new List <TextStyle>()
                {
                    TextStyle.Bold
                },
            });
            row.Cells.Add(new ReportCell()
            {
                Width               = 7.29,
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Right
            });
            Rows.Add(row);

            ReportRow row_1 = new ReportRow();

            row_1.Cells.Add(new ReportCell(buyer.Contact_person.ToUpper())
            {
                ColumnSpan = 6,
                TextStyle  = new List <TextStyle>()
                {
                    TextStyle.Bold
                },
            });
            row_1.Cells.Add(new ReportCell());
            row_1.Cells.Add(new ReportCell());
            row_1.Cells.Add(new ReportCell());
            row_1.Cells.Add(new ReportCell());
            row_1.Cells.Add(new ReportCell());
            row_1.Cells.Add(new ReportCell());
            row_1.Cells.Add(new ReportCell(buyer.Phone.ToUpper())
            {
                ColumnSpan = 2,
                TextStyle  = new List <TextStyle>()
                {
                    TextStyle.Bold
                },
                HorizontalAlignment = HorizontalAlignment.Right
            });
            Rows.Add(row_1);

            Rows.Add(new ReportRow());

            ReportRow row_2 = new ReportRow();

            row_2.Cells.Add(new ReportCell(equipment.Name.ToUpper())
            {
                ColumnSpan = 6,
                TextStyle  = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });
            row_2.Cells.Add(new ReportCell());
            row_2.Cells.Add(new ReportCell());
            row_2.Cells.Add(new ReportCell());
            row_2.Cells.Add(new ReportCell());
            row_2.Cells.Add(new ReportCell());
            row_2.Cells.Add(new ReportCell());
            row_2.Cells.Add(new ReportCell(serialNumber.ToUpper())
            {
                RowSpan             = 1,
                ColumnSpan          = 2,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                TextStyle           = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });
            Rows.Add(row_2);

            ReportRow row_3 = new ReportRow();

            row_3.Cells.Add(new ReportCell(modificationString.ToUpper())
            {
                ColumnSpan = 6,
                TextStyle  = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });
            Rows.Add(row_3);

            AllDocumentFontSize = 14;

            return(Create());
        }
Пример #8
0
        public void createData()
        {
            double sum = 0;

            for (int i = 0; i < payment.Count; i++)
            {
                Bid bid = BidViewModel.instance().getById(payment[i].Id_bid);
                if (bid == null || bid.Id_seller != seller.Id)
                {
                    continue;
                }

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

                ReportRow row = new ReportRow();
                row.Cells.Add(new ReportCell(bid.Id.ToString())
                {
                    HorizontalAlignment = HorizontalAlignment.Center,
                    BorderColor         = System.Drawing.Color.Black
                });

                row.Cells.Add(new ReportCell(bid.Account)
                {
                    BorderColor = System.Drawing.Color.Black
                });

                row.Cells.Add(new ReportCell(payment[i].Payment_date.ToString("dd.MM.yyyy"))
                {
                    BorderColor = System.Drawing.Color.Black
                });

                row.Cells.Add(new ReportCell(buyer.Name)
                {
                    BorderColor = System.Drawing.Color.Black
                });

                row.Cells.Add(new ReportCell(payment[i].Paying.ToString())
                {
                    BorderColor = System.Drawing.Color.Black, HorizontalAlignment = HorizontalAlignment.Right, Format = Format.Money
                });

                Rows.Add(row);

                sum += payment[i].Paying;
            }

            ReportRow sumRow = new ReportRow();

            sumRow.Add(new ReportCell());
            sumRow.Add(new ReportCell());
            sumRow.Add(new ReportCell());
            sumRow.Add(new ReportCell("Итого:")
            {
                HorizontalAlignment = HorizontalAlignment.Right
            });
            sumRow.Add(new ReportCell(sum.ToString().Replace(',', '.'))
            {
                HorizontalAlignment = HorizontalAlignment.Right, BorderColor = System.Drawing.Color.Black, Format = Format.Money
            });
            Rows.Add(sumRow);
        }