예제 #1
0
        //распределение между продавцами
        private void SellerDistribution()
        {
            Dictionary <int, double> sellerDict
                = new Dictionary <int, double>();

            for (int i = 0; i < archiveBid.Count; i++)
            {
                if (!sellerDict.ContainsKey(archiveBid[i].Id_seller))
                {
                    sellerDict.Add(archiveBid[i].Id_seller, archiveBid[i].Amount);
                }
                else
                {
                    sellerDict[archiveBid[i].Id_seller] += archiveBid[i].Amount;
                }
            }
            if (sellerDict.Count == 0)
            {
                return;
            }

            ReportRow rowH = new ReportRow();

            rowH.Add(new ReportCell("Распределение между продавцами:"));
            Rows.Add(rowH);

            ReportRow rowT = new ReportRow();

            rowT.Add(new ReportCell("Продавец")
            {
                BorderColor = System.Drawing.Color.Black, ColumnSpan = 1
            });
            rowT.Add(null);
            rowT.Add(new ReportCell("Сумма")
            {
                ColumnSpan = 1, BorderColor = System.Drawing.Color.Black
            });
            Rows.Add(rowT);

            foreach (KeyValuePair <int, double> kv in sellerDict.OrderByDescending(x => x.Value))
            {
                Seller seller = SellerViewModel.instance().getById(kv.Key);
                if (seller == null)
                {
                    continue;
                }

                ReportRow row = new ReportRow();
                row.Add(new ReportCell(seller.Name)
                {
                    ColumnSpan = 1, BorderColor = System.Drawing.Color.Black
                });
                row.Add(null);
                row.Add(new ReportCell(kv.Value.ToString().Replace(',', '.'))
                {
                    ColumnSpan = 1, BorderColor = System.Drawing.Color.Black
                });
                Rows.Add(row);
            }
        }
예제 #2
0
        private bool loadModels()
        {
            CRMSettingViewModel.instance();

            ComplectationItemViewModel.instance();

            EquipmentViewModel.instance();
            ModificationViewModel.instance();
            SellerViewModel.instance();
            BuyerViewModel.instance();
            BidStatusViewModel.instance();
            PaymentStatusViewModel.instance();
            MessageTemplatesViewModel.instance();

            RoleViewModel.instance();
            ManagerViewModel.instance();

            BidViewModel.instance();



            //EquipmentBidViewModel.instance();
            //ComplectationViewModel.instance();

            //ComplectationItemViewModel.instance();

            return(true);
        }
예제 #3
0
        //Третья строка (продавец и номер счета)
        private bool createSellerRow()
        {
            Seller seller = SellerViewModel.instance().getById(bid.Id_seller);

            if (seller == null)
            {
                return(false);
            }

            ReportRow row = new ReportRow();

            row.Cells.Add(new ReportCell("Продавец")
            {
                Height    = 16.50,
                TextStyle = new List <TextStyle>()
                {
                    TextStyle.Bold
                },
                VerticalAlignment = VerticalAlignment.Bottom
            });
            AddEmptyCell(row, 2);
            row.Cells.Add(new ReportCell(seller.Name)
            {
                ColumnSpan  = 4,
                BorderColor = System.Drawing.Color.Black
            });
            AddEmptyCell(row, 3);
            row.Cells.Add(new ReportCell()
            {
                VerticalAlignment = VerticalAlignment.Bottom
            });
            row.Cells.Add(new ReportCell("Номер счета")
            {
                TextStyle = new List <TextStyle>()
                {
                    TextStyle.Bold
                },
                VerticalAlignment = VerticalAlignment.Bottom
            });
            AddEmptyCell(row, 2);
            row.Cells.Add(new ReportCell(bid.Account)
            {
                ColumnSpan  = 4,
                BorderColor = Color.Black
            });
            AddEmptyCell(row, 3);
            row.Cells.Add(new ReportCell()
            {
                VerticalAlignment = VerticalAlignment.Bottom
            });
            Rows.Add(row);

            return(true);
        }
예제 #4
0
        public SelectSellerAndPeriod()
        {
            InitializeComponent();

            CollectionViewSource viewSource = new CollectionViewSource();

            viewSource.Source     = SellerViewModel.instance().Collection;
            cbxSeller.ItemsSource = viewSource.View;
            viewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending));

            cbxSeller.SelectedIndex = -1;
        }
        void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (dpSelectDateStart.SelectedDate == null ||
                dpSelectDateEnd.SelectedDate == null)
            {
                MessageBox.Show("Выберите дату с и по");
                return;
            }

            List <Payment> payment = PaymentViewModel.instance()
                                     .GetByPeriod((DateTime)dpSelectDateStart.SelectedDate,
                                                  (DateTime)dpSelectDateEnd.SelectedDate);

            if (payment.Count == 0)
            {
                MessageBox.Show("За выбранный период нет платежей!");
                return;
            }

            Microsoft.Win32.SaveFileDialog sfDialog = new Microsoft.Win32.SaveFileDialog();
            sfDialog.FileName = "Поступления с "
                                + ((DateTime)dpSelectDateStart.SelectedDate).ToString("dd.MM.yyyy")
                                + " по "
                                + ((DateTime)dpSelectDateEnd.SelectedDate).ToString("dd.MM.yyyy")
                                + ".xlsx";
            sfDialog.Filter = "Excel 2007 worksheet (*.xlsx)|*.xlsx";

            if (sfDialog.ShowDialog() != true)
            {
                return;
            }

            StangradCRM.Reports.TurnoverAllSeller turnoverAllSeller
                = new StangradCRM.Reports.TurnoverAllSeller(payment, SellerViewModel.instance().Collection.ToList(),
                                                            (DateTime)dpSelectDateStart.SelectedDate,
                                                            (DateTime)dpSelectDateEnd.SelectedDate);

            turnoverAllSeller.FileName = sfDialog.FileName;

            loadingProgress.Visibility = Visibility.Visible;
            Task.Factory.StartNew(() =>
            {
                if (!turnoverAllSeller.Save())
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { errorSave(turnoverAllSeller); }));
                }
                else
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { successSave(turnoverAllSeller); }));
                }
            });
        }
예제 #6
0
        public SellerWindow()
        {
            InitializeComponent();
            viewSource.Source = SellerViewModel.instance().Collection;

            viewSource.Filter += delegate(object sender, FilterEventArgs e)
            {
                Seller seller = e.Item as Seller;
                if (seller == null)
                {
                    return;
                }
                e.Accepted = seller.IsVisible;
            };
            viewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending));
            DataContext = new { SellerCollection = viewSource.View };
        }
예제 #7
0
        private void CreateBidList(Bid bid)
        {
            ReportRow row1 = new ReportRow();

            row1.Add(new ReportCell("Код заявки:")
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                TextStyle           = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });
            row1.Add(new ReportCell(bid.Id.ToString())
            {
                BorderColor       = System.Drawing.Color.Black,
                VerticalAlignment = VerticalAlignment.Bottom
            });

            row1.Add(new ReportCell("Сумма:")
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                TextStyle           = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });
            row1.Add(new ReportCell(bid.Amount.ToString())
            {
                BorderColor       = System.Drawing.Color.Black,
                VerticalAlignment = VerticalAlignment.Bottom
            });

            row1.Add(new ReportCell("Дата отгрузки:")
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                TextStyle           = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });
            if (bid.Planned_shipment_date != null)
            {
                row1.Add(new ReportCell(((DateTime)bid.Planned_shipment_date).ToString("dd.MM.yyyy"))
                {
                    BorderColor       = System.Drawing.Color.Black,
                    VerticalAlignment = VerticalAlignment.Bottom
                });
            }
            else
            {
                row1.Add(new ReportCell()
                {
                    VerticalAlignment = VerticalAlignment.Bottom
                });
            }

            ReportRow row2 = new ReportRow();

            row2.Add(new ReportCell("Продавец:")
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                TextStyle           = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });
            Seller seller = SellerViewModel.instance().getById(bid.Id_seller);

            row2.Add(new ReportCell(seller.Name)
            {
                BorderColor       = System.Drawing.Color.Black,
                VerticalAlignment = VerticalAlignment.Bottom
            });

            row2.Add(new ReportCell("Счет:")
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                TextStyle           = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });
            row2.Add(new ReportCell(bid.Account)
            {
                BorderColor       = System.Drawing.Color.Black,
                VerticalAlignment = VerticalAlignment.Bottom
            });

            row2.Add(new ReportCell("Дата заявки:")
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                TextStyle           = new List <TextStyle>()
                {
                    TextStyle.Bold
                }
            });

            row2.Add(new ReportCell(bid.Date_created.ToString("dd.MM.yyyy"))
            {
                BorderColor       = System.Drawing.Color.Black,
                VerticalAlignment = VerticalAlignment.Bottom
            });

            Rows.Add(row1);
            Rows.Add(row2);
            Rows.Add(new ReportRow());

            CreateEquipmentList(bid);
        }
예제 #8
0
 void TbxSearch_TextChanged(object sender, TextChangedEventArgs e)
 {
     SellerViewModel.instance().search(tbxSearch.Text);
     viewSource.View.Refresh();
 }