Beispiel #1
0
 private void DeletePeriodButton_Click(object sender, RoutedEventArgs e)
 {
     if (PeriodsComboBox.SelectedIndex > -1)
     {
         ModelSprintDBContainer  container = new ModelSprintDBContainer(connString);
         List <MonthConsumption> lst       = container.Set <MonthConsumption>().ToList();
         string deleteStr = PeriodsComboBox.SelectedItem.ToString();
         foreach (MonthConsumption item in lst)
         {
             string str = (item.Date / 100).ToString() + "/" + (item.Date % 100 < 10 ? "0" + (item.Date % 100).ToString() : (item.Date % 100).ToString());
             if (string.Equals(str, deleteStr))
             {
                 var billingLst = container.Set <Billing>().ToList();
                 foreach (var bill in billingLst)
                 {
                     if (bill.MonthConsumption.MonthBillingID == item.MonthBillingID)
                     {
                         container.BillingSet.Remove(bill);
                     }
                 }
                 container.MonthConsumptionSet.Remove(item);
                 break;
             }
         }
         container.SaveChanges();
         Close();
     }
     else
     {
         MessageBox.Show("Выберите нужный период из списка", "Ошибка");
     }
 }
Beispiel #2
0
        private void isRecordsExist()
        {
            ModelSprintDBContainer container = new ModelSprintDBContainer(connString);

            if (container.CottagerSet.Count() == 0 && container.MonthConsumptionSet.Count() == 0)
            {
                ViewDataGrid.ItemsSource  = null;
                currentViewTextBlock.Text = "";
            }
        }
Beispiel #3
0
        private void CreateCostBtn_Click(object sender, RoutedEventArgs e)
        {
            ModelSprintDBContainer container = new ModelSprintDBContainer(connString);

            container.CostOfWaterSet.Add(new CostOfWater()
            {
                Cost = Decimal.Parse(CostOfWaterTB.Text)
            });
            container.SaveChanges();
            Close();
        }
        public DeleteCottagerWindow(string connectionString)
        {
            InitializeComponent();
            connString = connectionString;
            ModelSprintDBContainer container = new ModelSprintDBContainer(connString);
            List <Cottager>        lst       = container.Set <Cottager>().ToList();

            lst.Sort();
            foreach (Cottager item in lst)
            {
                CottagersComboBox.Items.Add(item.Author + "; S = " + item.Square.ToString());
            }
        }
Beispiel #5
0
        public DeleteMonthConsWindow(string connectionString)
        {
            InitializeComponent();
            connString = connectionString;
            ModelSprintDBContainer  container = new ModelSprintDBContainer(connString);
            List <MonthConsumption> lst       = container.Set <MonthConsumption>().ToList();

            lst.Sort();
            foreach (MonthConsumption item in lst)
            {
                PeriodsComboBox.Items.Add((item.Date / 100).ToString() + "/" + (item.Date % 100 < 10 ? "0" + (item.Date % 100).ToString() : (item.Date % 100).ToString()));
            }
        }
Beispiel #6
0
        private void ShowCostOfWaterBtn_Click(object sender, RoutedEventArgs e)
        {
            ModelSprintDBContainer container = new ModelSprintDBContainer(connString);
            List <CostOfWater>     lst       = container.Set <CostOfWater>().ToList();
            string str  = "";
            int    cost = Convert.ToInt32(lst[0].Cost * 100);

            str = (cost / 100).ToString() + " руб. ";
            if (cost % 100 > 0)
            {
                str += (cost % 100).ToString() + " коп.";
            }

            MessageBox.Show("Кубический метр воды стоит " + str, "Цена за воду");
        }
Beispiel #7
0
        private void SetMonthConsAsItemSource()
        {
            ModelSprintDBContainer  container = new ModelSprintDBContainer(connString);
            List <MonthConsumption> lst       = container.Set <MonthConsumption>().ToList();

            if (lst.Count > 0)
            {
                ViewDataGrid.ItemsSource = lst;
                ViewDataGrid.Columns.RemoveAt(0);
                ViewDataGrid.Columns.RemoveAt(2);
                ViewDataGrid.Columns[0].Header = "Дата";
                ViewDataGrid.Columns[1].Header = "Потребление за месяц";
                SortByFirstColumn();
                currentViewTextBlock.Text = "Потребление воды по месяцам";
            }
        }
Beispiel #8
0
        private void SetCottagersAsItemsSource()
        {
            ModelSprintDBContainer container = new ModelSprintDBContainer(connString);
            List <Cottager>        lst       = container.Set <Cottager>().ToList();

            if (lst.Count > 0)
            {
                ViewDataGrid.ItemsSource = lst;
                ViewDataGrid.Columns.RemoveAt(0);
                ViewDataGrid.Columns.RemoveAt(2);
                ViewDataGrid.Columns[0].Header = "ФИО дачника";
                ViewDataGrid.Columns[1].Header = "Площадь участка";

                SortByFirstColumn();
                currentViewTextBlock.Text = "Дачники";
            }
        }
Beispiel #9
0
        private void Wizard_Next(object sender, Xceed.Wpf.Toolkit.Core.CancelRoutedEventArgs e)
        {
            if (WizardWindow.CurrentPage == Page3)
            {
                int cost = Convert.ToInt32(costOfWater * 100);
                costTextBlock.Text += (cost / 100).ToString() + " руб. ";
                if (cost % 100 > 0)
                {
                    costTextBlock.Text += (cost % 100).ToString() + " коп.";
                }

                countCottagersTextBlock.Text += cottagers.Count.ToString();

                ModelSprintDBContainer container = new ModelSprintDBContainer(connString);

                var CollCost = from item in container.CostOfWaterSet
                               select item;
                container.CostOfWaterSet.RemoveRange(CollCost);
                container.CostOfWaterSet.Add(new CostOfWater()
                {
                    Cost = Convert.ToDecimal(costOfWater)
                });

                var CollCottagers = from item in container.CottagerSet
                                    select item;
                container.CottagerSet.RemoveRange(CollCottagers);
                foreach (var item in cottagers)
                {
                    container.CottagerSet.Add(new Cottager()
                    {
                        Author = item.Author,
                        Square = item.Square
                    });
                }

                var CollBilling = from item in container.BillingSet
                                  select item;
                container.BillingSet.RemoveRange(CollBilling);

                var CollMonthConsumption = from item in container.MonthConsumptionSet
                                           select item;
                container.MonthConsumptionSet.RemoveRange(CollMonthConsumption);

                container.SaveChanges();
            }
        }
Beispiel #10
0
        private void SetMonthBillingAsItemSource(MonthConsumption consumption, Billing billEx)
        {
            ModelSprintDBContainer container = new ModelSprintDBContainer(connString);
            IQueryable <Billing>   lst       = null;

            if (billEx == null)
            {
                lst = from bill in container.BillingSet
                      where bill.MonthConsumption.MonthBillingID == consumption.MonthBillingID
                      select bill;
            }
            else
            {
                lst = from bill in container.BillingSet
                      where bill.Date == billEx.Date
                      select bill;
            }
            List <Billing> bills = lst.ToList();

            if (bills.Count > 0)
            {
                ViewDataGrid.ItemsSource = bills;
                ViewDataGrid.Columns.RemoveAt(0);
                ViewDataGrid.Columns.RemoveAt(1);
                ViewDataGrid.Columns.RemoveAt(2);
                ViewDataGrid.Columns.RemoveAt(2);
                ViewDataGrid.Columns[0].Header = "ФИО дачника";
                ViewDataGrid.Columns[1].Header = "Счёт за месяц";
                int date = (billEx == null ? consumption.Date : billEx.MonthConsumption.Date);
                currentViewTextBlock.Text = "Отчёт за период: " + (date / 100).ToString() + "/" + (date % 100 < 10 ? "0" + (date % 100).ToString() : (date % 100).ToString());
                SortByFirstColumn();
            }
            else if (consumption != null)
            {
                MessageBox.Show("Отсутствуют дачники для выбранного периода");
            }
        }
Beispiel #11
0
        private void FillDBForExampleBtn_Click(object sender, RoutedEventArgs e)
        {
            ModelSprintDBContainer container = new ModelSprintDBContainer(connString);

            ClearDB();
            //пример
            CostOfWater costOfWater = new CostOfWater()
            {
                Cost = 1.57M
            };

            container.CostOfWaterSet.Add(costOfWater);

            container.CottagerSet.Add(new Cottager()
            {
                Author = "Шубин Семён Николаевич",
                Square = 12
            });
            container.CottagerSet.Add(new Cottager()
            {
                Author = "Иванов Пётр Михайлович",
                Square = 15
            });
            container.CottagerSet.Add(new Cottager()
            {
                Author = "Сидоров Александр Анатольевич",
                Square = 20
            });
            container.CottagerSet.Add(new Cottager()
            {
                Author = "Машинцев Илья Константинович",
                Square = 9.5M
            });

            var cottagers = from item in container.CottagerSet.Local
                            select item;

            MonthConsumption monthConsumption = new MonthConsumption()
            {
                Consumption = 300,
                Date        = 201804
            };
            decimal square = 0;

            foreach (Cottager cottager in cottagers)
            {
                square += cottager.Square;
            }
            foreach (Cottager cottager in cottagers)
            {
                Billing bill = new Billing()
                {
                    MonthConsumption = monthConsumption,
                    Cottager         = cottager,
                    Author           = cottager.Author,
                    Date             = monthConsumption.Date,
                    Bill             = Convert.ToDecimal((cottager.Square / square) * monthConsumption.Consumption * costOfWater.Cost),
                };
                container.BillingSet.Add(bill);
            }

            monthConsumption = new MonthConsumption()
            {
                Consumption = 470.5M,
                Date        = 201803
            };

            foreach (Cottager cottager in cottagers)
            {
                Billing bill = new Billing()
                {
                    MonthConsumption = monthConsumption,
                    Cottager         = cottager,
                    Author           = cottager.Author,
                    Date             = monthConsumption.Date,
                    Bill             = Convert.ToDecimal((cottager.Square / square) * monthConsumption.Consumption * costOfWater.Cost),
                };
                container.BillingSet.Add(bill);
            }

            container.SaveChanges();
            SetCottagersAsItemsSource();
        }