Пример #1
0
        private void AddCottagerButton_Click(object sender, RoutedEventArgs e)
        {
            if (decimal.TryParse(SquareTextBox.Text, out decimal t) == true && t > 0)
            {
                ModelSprintDBContainer container = new ModelSprintDBContainer(connString);
                List <Cottager>        lst       = container.Set <Cottager>().ToList();//cottagers.Add(cottager);

                Cottager cottager = new Cottager
                {
                    Author = AuthorOfCottageTextBox.Text,
                    Square = t
                };

                if (lst.Contains(cottager) == true)
                {
                    MessageBox.Show("Не должно быть одинаковых записей", "Ошибка");
                }
                else if (cottager.Author == "")
                {
                    MessageBox.Show("У дачника должно быть ФИО", "Ошибка");
                }
                else
                {
                    container.CottagerSet.Add(cottager);
                    container.SaveChanges();
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Площадь должна быть неотрицательным числом", "Ошибка");
            }
        }
Пример #2
0
        private void SetCottagerBillsAsItemSource(Cottager cottager, Billing billEx)
        {
            ModelSprintDBContainer container = new ModelSprintDBContainer(connString);
            IEnumerable <Billing>  lst       = null;

            if (billEx == null)
            {
                lst = from bill in cottager.Billing
                      select bill;
            }
            else
            {
                lst = from bill in billEx.Cottager.Billing
                      select bill;
            }
            List <Billing> billing = lst.ToList();

            if (billing.Count > 0)
            {
                ViewDataGrid.ItemsSource = lst;
                ViewDataGrid.Columns.RemoveAt(0);
                ViewDataGrid.Columns.RemoveAt(0);
                ViewDataGrid.Columns.RemoveAt(0);
                ViewDataGrid.Columns.RemoveAt(0);
                ViewDataGrid.Columns[0].Header = "Дата";
                ViewDataGrid.Columns[1].Header = "Счёт";
                currentViewTextBlock.Text      = (billEx == null ? cottager.Author : billEx.Cottager.Author) + ": счета по месяцам";
                SortByFirstColumn();
            }
            else
            {
                MessageBox.Show("Для выбранного дачника нет рассчитанных периодов");
            }
        }
Пример #3
0
        private void AddCottagerButton_Click(object sender, RoutedEventArgs e)
        {
            if (decimal.TryParse(SquareTextBox.Text, out decimal t) == true && t > 0)
            {
                Cottager cottager = new Cottager
                {
                    Author = AuthorOfCottageTextBox.Text,
                    Square = t
                };

                if (cottagers.Contains(cottager) == true)
                {
                    MessageBox.Show("Не должно быть одинаковых записей", "Ошибка");
                }
                else if (cottager.Author == "")
                {
                    MessageBox.Show("У дачника должно быть ФИО", "Ошибка");
                }
                else
                {
                    cottagers.Add(cottager);
                    AuthorOfCottageTextBox.Text = "";
                    SquareTextBox.Text          = "";
                    BindListToDataGrid();
                }
            }
            else
            {
                MessageBox.Show("Площадь должна быть неотрицательным числом", "Ошибка");
            }
        }