Exemplo n.º 1
0
        public void DeleteClick(object obj)
        {
            using (var db = new MeiMeiContext())
            {
                var delete = (from b in db.Shedules
                              where b.CustomerName == Customer && b.ServiceName == Service && b.EmployeeTable.FIO == Employee && b.Time == b.Time && b.Size == b.Size && b.Data == b.Data
                              select b).FirstOrDefault();


                var deleteHistory = (from b in db.EmployeeHistories
                                     where b.ServiceName == Service
                                     select b).FirstOrDefault();


                var deletehistoryCustomer = (from b in db.Histories
                                             where b.ServiceName == Service
                                             select b).FirstOrDefault();

                db.Shedules.Remove(delete);
                db.SaveChanges();

                db.EmployeeHistories.Remove(deleteHistory);
                db.SaveChanges();

                db.Histories.Remove(deletehistoryCustomer);
                db.SaveChanges();
            }

            MessageBox.Show(Properties.Resources.RemovedSuccessfully_message, "", MessageBoxButton.OK, MessageBoxImage.Information);

            ScheduleVM.Instance.FindeShedule(ShedulePage.Instance.gridShedule);
        }
Exemplo n.º 2
0
        public void EditSheduleCommandClick(object obj)
        {
            if (SelectedFirstTime != null && SelectedSecondTime != null)
            {
                using (var db = new MeiMeiContext())
                {
                    var shedules = (from b in db.Shedules
                                    where b.Id == shedule.Id
                                    select b).FirstOrDefault();

                    shedules.CustomerName      = ClientName;
                    shedules.Time              = SelectedFirstTime.Id.ToString();
                    shedules.Size              = SelectedSecondTime.Id.ToString();
                    shedules.ServiceName       = Service;
                    shedules.ServicePrice      = Price;
                    shedules.Data              = MyDate;
                    shedules.EmployeeTable.FIO = Employye;
                    shedules.Room              = shedule.Room;
                    db.SaveChanges();

                    var history = (from b in db.Histories
                                   where b.Id == shedules.Id && b.Customer.FIO == shedules.CustomerName
                                   select b).FirstOrDefault();
                    history.ServiceName = Service;
                    history.ServiceCost = Price;
                    db.SaveChanges();
                }

                ScheduleVM.Instance.FindeShedule(ShedulePage.Instance.gridShedule);
            }
            else
            {
                MessageBox.Show(Properties.Resources.FirstFill_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 3
0
        public void RemoveCommand(object obj)
        {
            if (SelectedEmployee != null)
            {
                using (var db = new MeiMeiContext())
                {
                    while (db.EmployeeHistories.Count() != null)
                    {
                        var history = (from b in db.EmployeeHistories
                                       join ba in db.EmployeeTables on b.EmployeeTableId equals ba.Id
                                       where b.EmployeeTableId == SelectedEmployee.Id
                                       select b).FirstOrDefault();
                        if (history != null)
                        {
                            db.EmployeeHistories.Remove(history);
                            db.SaveChanges();
                        }
                        else
                        {
                            break;
                        }
                    }

                    while (db.Shedules.Count() != null)
                    {
                        var shedule = (from b in db.Shedules
                                       join ba in db.EmployeeTables on b.EmployeeTableId equals ba.Id
                                       where b.EmployeeTableId == SelectedEmployee.Id
                                       select b).FirstOrDefault();
                        if (shedule != null)
                        {
                            db.Shedules.Remove(shedule);
                            db.SaveChanges();
                        }
                        else
                        {
                            break;
                        }
                    }
                    var employee = (from b in db.EmployeeTables
                                    where b.FIO == SelectedEmployee.FIO && b.Id == SelectedEmployee.Id
                                    select b).FirstOrDefault();
                    db.EmployeeTables.Remove(employee);
                    db.SaveChanges();
                    OnPropertyChanged("EmployeeFIOCollection");
                }
            }
            else
            {
                MessageBox.Show(Properties.Resources.FirstSelectObject_message, "", MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
        }
Exemplo n.º 4
0
 public void SaveClick(object obj)
 {
     if (Fio != string.Empty && Birthday != string.Empty && Contacts != string.Empty && Post != string.Empty &&
         Salarity != string.Empty && PersonalData != string.Empty)
     {
         using (var db = new MeiMeiContext())
         {
             var emploeyy = (from b in db.EmployeeTables
                             where b.FIO == EmployeeVM.Instance.SelectedEmployee.FIO
                             select b).FirstOrDefault();
             emploeyy.FIO          = Fio;
             emploeyy.Birthday     = Birthday;
             emploeyy.Contacts     = Contacts;
             emploeyy.PersonalData = PersonalData;
             emploeyy.Post         = Post;
             emploeyy.Salary       = Salarity;
             emploeyy.Photo        = a;
             db.SaveChanges();
         }
         _employeeVMOwner.EmployeeFIOCollection = _employeeVMOwner.EmployeeFIOCollection;
         MessageBox.Show(Properties.Resources.Сompleted_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else
     {
         MessageBox.Show(Properties.Resources.FirstFill_message, Properties.Resources.Attention_message, MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
Exemplo n.º 5
0
        public void AddCustomersClick(object obj)
        {
            //Добавление и запись в бд
            if (FIO != string.Empty || Contacts != string.Empty || Birthyday != string.Empty || Notes != string.Empty)
            {
                using (var db = new MeiMeiContext())
                {
                    var customer = new Customers
                    {
                        FIO      = FIO,
                        Birthday = Birthyday,
                        Contakts = Contacts,
                        Notes    = Notes,
                        Photo    = a
                    };
                    db.Customers.Add(customer);
                    db.SaveChanges();
                }

                MessageBox.Show("Добавленно", "", MessageBoxButton.OK, MessageBoxImage.Information);
                FIO       = string.Empty;
                Birthyday = string.Empty;
                Contacts  = string.Empty;
                Notes     = string.Empty;
                _customerVMOwner.CustomersColl = _customerVMOwner.CustomersColl;
            }
            else
            {
                MessageBox.Show("Пожалуста заполните все строки", "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemplo n.º 6
0
        public void SaveCommandClick(object obj)
        {
            if (Fio != string.Empty || Birthday != string.Empty || Contacts != string.Empty || Post != string.Empty || PersonalData != string.Empty)
            {
                using (var db = new MeiMeiContext())
                {
                    var emploeyy = new EmployeeTable
                    {
                        FIO          = Fio,
                        Birthday     = Birthday,
                        Contacts     = Contacts,
                        Post         = Post,
                        Salary       = Salarity,
                        PersonalData = PersonalData,
                        Photo        = a
                    };
                    db.EmployeeTables.Add(emploeyy);
                    db.SaveChanges();
                }

                MessageBox.Show(Properties.Resources.Сompleted_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
                Fio          = string.Empty;
                Birthday     = string.Empty;
                Contacts     = string.Empty;
                Post         = string.Empty;
                PersonalData = string.Empty;
                Salarity     = string.Empty;

                _employeeVMOwner.EmployeeFIOCollection = _employeeVMOwner.EmployeeFIOCollection;
            }
            else
            {
                MessageBox.Show(Properties.Resources.FirstFill_message, Properties.Resources.Attention_message, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 7
0
        public void SaveClick(object obj)
        {
            if (FIO != string.Empty && Birthyday != string.Empty && Contacts != string.Empty && Notes != string.Empty)
            {
                using (var db = new MeiMeiContext())
                {
                    var customer = (from b in db.Customers
                                    where b.Id == CustomerVM.Instance.SelectedCustomer.Id
                                    select b).FirstOrDefault();
                    customer.FIO      = FIO;
                    customer.Birthday = Birthyday;
                    customer.Contakts = Contacts;
                    customer.Notes    = Notes;
                    customer.Photo    = a;
                    db.SaveChanges();
                }

                _customerVMOwner.CustomersColl = _customerVMOwner.CustomersColl;
                MessageBox.Show(Properties.Resources.Сompleted_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show(Properties.Resources.FirstFill_message, Properties.Resources.Attention_message, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 8
0
        public void Delete(object obj)
        {
            if (SelectedTypeService != null && SelectedService != null)
            {
                using (var db = new MeiMeiContext())
                {
                    var delete = (from b in db.Services
                                  where b.Id == SelectedService.Id
                                  select b).FirstOrDefault();

                    db.Services.Remove(delete);
                    db.SaveChanges();
                    OnPropertyChanged("PriceCollection");
                }
            }
            else if (SelectedTypeService != null)
            {
                using (var db = new MeiMeiContext())
                {
                    for (int i = 0; i < db.Services.Count(); i++)
                    {
                        var deleteService = (from b in db.Services
                                             where b.TypeOfServiceId == SelectedTypeService.Id
                                             select b).FirstOrDefault();

                        if (deleteService != null)
                        {
                            db.Services.Remove(deleteService);
                            db.SaveChanges();
                            MessageBox.Show(Properties.Resources.RemovedSuccessfully_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        else
                        {
                            break;
                        }
                    }

                    var deleteType = (from b in db.TypeOfServices
                                      where b.Id == SelectedTypeService.Id
                                      select b).FirstOrDefault();
                    db.TypeOfServices.Remove(deleteType);
                    db.SaveChanges();
                }
            }
        }
Exemplo n.º 9
0
        public void DeleteGoodClick(object obj)
        {
            if (SelectedGoods != null && SelectedTypeOfGoods != null)
            {
                using (var db = new MeiMeiContext())
                {
                    var delete = (from b in db.Goods
                                  where b.Id == SelectedGoods.Id
                                  select b).FirstOrDefault();
                    db.Goods.Remove(delete);
                    db.SaveChanges();
                    OnPropertyChanged("GoodsColl");
                }
            }

            else if (SelectedTypeOfGoods != null)
            {
                using (var db = new MeiMeiContext())
                {
                    for (int i = 0; i < db.Goods.Count(); i++)
                    {
                        var deleteGoods = (from b in db.Goods
                                           where b.TypeOfGoodsId == SelectedTypeOfGoods.Id
                                           select b).FirstOrDefault();
                        if (deleteGoods != null)
                        {
                            db.Goods.Remove(deleteGoods);
                            db.SaveChanges();
                        }
                        else
                        {
                            break;
                        }

                        var deleteType = (from b in db.TypeOfGoods
                                          where b.Id == SelectedTypeOfGoods.Id
                                          select b).FirstOrDefault();
                        db.TypeOfGoods.Remove(deleteType);
                        db.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 10
0
        public void AddTimesCklick(object obj)
        {
            if (StartFrom != string.Empty && EndFrom != string.Empty)
            {
                int a, b;
                a = Convert.ToInt32(StartFrom);
                b = Convert.ToInt32(EndFrom);
                int c = 0;
                for (int i = a; i < b + 1; i++)
                {
                    for (int j = 1; j < 5; j++)
                    {
                        if (c == 0)
                        {
                            using (var db = new MeiMeiContext())
                            {
                                var time = new SheduleTime
                                {
                                    Time = i + " : " + c + "0"
                                };
                                db.SheduleTimes.Add(time);
                                db.SaveChanges();
                            }
                        }
                        else
                        {
                            using (var db = new MeiMeiContext())
                            {
                                var time = new SheduleTime
                                {
                                    Time = i + " : " + c
                                };
                                db.SheduleTimes.Add(time);
                                db.SaveChanges();
                            }
                        }

                        c += 15;
                        if (c > 45)
                        {
                            c = 0;
                        }
                    }
                }
            }

            else
            {
                MessageBox.Show(Properties.Resources.StartEnterDay_message, "", MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
        }
Exemplo n.º 11
0
 public void RemoveCustomerClick(object obj)
 {
     if (SelectedCustomer != null)
     {
         using (var db = new MeiMeiContext())
         {
             while (db.Histories.Count() != null)
             {
                 var history = (from b in db.Histories
                                join ba in db.Customers on b.CustomersId equals ba.Id
                                where b.CustomersId == SelectedCustomer.Id
                                select b).FirstOrDefault();
                 if (history != null)
                 {
                     db.Histories.Remove(history);
                     db.SaveChanges();
                 }
                 else
                 {
                     break;
                 }
             }
             var customer = (from b in db.Customers
                             where b.FIO == SelectedCustomer.FIO
                             select b).FirstOrDefault();
             db.Customers.Remove(customer);
             db.SaveChanges();
         }
         OnPropertyChanged("CustomersColl");
     }
     else
     {
         MessageBox.Show(Properties.Resources.FirstSelectObject_message, "", MessageBoxButton.OK,
                         MessageBoxImage.Information);
     }
 }
Exemplo n.º 12
0
 public void SaveKategoria(object obj)
 {
     using (var db = new MeiMeiContext())
     {
         var kategoria = (from b in db.TypeOfServices
                          where b.TypeService == _servis.SelectedTypeService.TypeService
                          select b).FirstOrDefault();
         if (kategoria != null)
         {
             kategoria.TypeService = KategoriaServis;
         }
         db.SaveChanges();
     }
     MessageBox.Show(Properties.Resources.Save_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
 }
Exemplo n.º 13
0
 public void SaveKategoria(object obj)
 {
     using (var db = new MeiMeiContext())
     {
         var kategoria = (from b in db.TypeOfGoods
                          where b.TypeGoods == _good.SelectedTypeOfGoods.TypeGoods
                          select b).FirstOrDefault();
         if (kategoria != null)
         {
             kategoria.TypeGoods = GoodKategoria;
         }
         db.SaveChanges();
         OnPropertyChanged("CompColl");
     }
     MessageBox.Show(Properties.Resources.Save_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
 }
Exemplo n.º 14
0
 public void SaveService(object obj)
 {
     using (var db = new MeiMeiContext())
     {
         var service = (from b in db.Services
                        where b.ServiceName == _servis.SelectedService.ServiceName && b.ServicePrice == _servis.SelectedService.ServicePrice
                        select b).FirstOrDefault();
         if (service != null)
         {
             service.ServiceName  = NameServis;
             service.ServicePrice = CostServis;
         }
         db.SaveChanges();
     }
     MessageBox.Show(Properties.Resources.Save_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
 }
Exemplo n.º 15
0
 public void SaveService(object obj)
 {
     using (var db = new MeiMeiContext())
     {
         var good = (from b in db.Goods
                     where b.GoodName == _good.SelectedGoods.GoodName && b.GoodPrice == _good.SelectedGoods.GoodPrice && b.Count == _good.SelectedGoods.Count
                     select b).FirstOrDefault();
         if (good != null)
         {
             good.GoodName  = GoodName;
             good.GoodPrice = GoodPrice;
             good.Count     = GoodCount;
         }
         db.SaveChanges();
     }
     MessageBox.Show(Properties.Resources.Save_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
 }
Exemplo n.º 16
0
 public void AddGoodsClick(object obj)
 {
     PriceGoodsCollection.Add(new Add_GoodsVM {
         Name = Name, Price = Price, Count = Count
     });
     using (var db = new MeiMeiContext())
     {
         var goods = new Goods
         {
             GoodName      = Name,
             GoodPrice     = Price,
             Count         = Count,
             TypeOfGoodsId = SelectTypeOfGoods.Id
         };
         db.Goods.Add(goods);
         db.SaveChanges();
     }
 }
Exemplo n.º 17
0
 public void AddTypeGoodsClick(object obj)
 {
     if (Company != string.Empty)
     {
         using (var db = new MeiMeiContext())
         {
             var typeGoods = new TypeOfGoods
             {
                 TypeGoods = Company
             };
             db.TypeOfGoods.Add(typeGoods);
             db.SaveChanges();
         }
         OnPropertyChanged("TypeOfGoodsCollection");
     }
     else
     {
         MessageBox.Show(Properties.Resources.FirstFill_message);
     }
 }
Exemplo n.º 18
0
 public void AddTypeservice(object obj)
 {
     if (TypeOfService != string.Empty)
     {
         using (var db = new MeiMeiContext())
         {
             var typeService = new TypeOfService
             {
                 TypeService = TypeOfService
             };
             db.TypeOfServices.Add(typeService);
             db.SaveChanges();
         }
         OnPropertyChanged("TypeServiceCollection");
     }
     else
     {
         MessageBox.Show(Properties.Resources.FirstFill_message, "", MessageBoxButton.OK,
                         MessageBoxImage.Information);
     }
 }
Exemplo n.º 19
0
        public void RemoveClick(object obj)
        {
            if (SelectedColumn != null)
            {
                using (var db = new MeiMeiContext())
                {
                    var sheduleColumn = (from b in db.SheduleColumns
                                         where b.ColumnName == SelectedColumn.ColumnName
                                         select b).FirstOrDefault();
                    db.SheduleColumns.Remove(sheduleColumn);
                    db.SaveChanges();

                    OnPropertyChanged("ColumnCollection");
                }
            }

            else
            {
                MessageBox.Show(Properties.Resources.FirstSelectObject_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 20
0
        public void AddColumnClick(object obj)
        {
            if (NewColumn != string.Empty)
            {
                using (var db = new MeiMeiContext())
                {
                    var column = new SheduleColumn
                    {
                        ColumnName = NewColumn
                    };
                    db.SheduleColumns.Add(column);
                    db.SaveChanges();
                }

                MessageBox.Show(Properties.Resources.Сompleted_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
                OnPropertyChanged("ColumnCollection");
            }
            else
            {
                MessageBox.Show(Properties.Resources.FirstFill_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 21
0
        public void AddServis(object obj)
        {
            if (NameServis != String.Empty && CostServis != String.Empty && SelectTypeOfService != null)
            {
                if (SelectTypeOfService != null)
                {
                    PricesColl.Add(new AddServisVM {
                        NameServis = NameServis, CostServis = CostServis,
                    });

                    using (var db = new MeiMeiContext())
                    {
                        var service = new Service
                        {
                            ServiceName     = NameServis,
                            ServicePrice    = CostServis,
                            TypeOfServiceId = SelectTypeOfService.Id
                        };
                        db.Services.Add(service);
                        db.SaveChanges();
                    }

                    NameServis = String.Empty;
                    CostServis = String.Empty;
                }
                else
                {
                    MessageBox.Show(Properties.Resources.SelectServiceType_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show(Properties.Resources.FirstFill_message, Properties.Resources.Attention_message, MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
        }
Exemplo n.º 22
0
        public void AddShedule(object obj)
        {
            int size, firstNum, secondNum;

            size     = SelectedSecondTime.Id - SelectedFirstTime.Id + 1;
            firstNum = SelectedFirstTime.Id;

            if (SelectedEmployee != null && SelectedFirstTime != null &&
                SelectedSecondTime != null && SelectedThisService != null && SelectedService != null)
            {
                if (SelectedItem == null)
                {
                    using (var db = new MeiMeiContext())
                    {
                        var customer = new Customers
                        {
                            FIO = Customer
                        };
                        db.Customers.Add(customer);
                        db.SaveChanges();
                    }

                    using (var db = new MeiMeiContext())
                    {
                        var shedule = new Shedule
                        {
                            CustomerName    = Customer,
                            ServicePrice    = SelectedThisService.ServicePrice,
                            ServiceName     = SelectedThisService.ServiceName,
                            Data            = MyDate.Date,
                            EmployeeTableId = SelectedEmployee.Id,
                            Time            = firstNum.ToString(),
                            Size            = size.ToString(),
                            Room            = Room,
                            Column          = (_shedule.ColumnNumber + 1).ToString()
                        };


                        var history = new History
                        {
                            CustomersId = (from b in db.Customers
                                           where b.FIO == Customer
                                           select b.Id).FirstOrDefault(),
                            Data        = MyDate.Date.ToString(),
                            ServiceName = SelectedThisService.ServiceName,
                            ServiceCost = SelectedThisService.ServicePrice + " грн."
                        };

                        var employeeHistory = new EmployeeHistory
                        {
                            Cost            = SelectedThisService.ServicePrice,
                            Data            = MyDate.Date,
                            EmployeeTableId = SelectedEmployee.Id,
                            ServiceName     = SelectedThisService.ServiceName
                        };
                        db.Shedules.Add(shedule);
                        db.SaveChanges();

                        db.Histories.Add(history);
                        db.SaveChanges();

                        db.EmployeeHistories.Add(employeeHistory);
                        db.SaveChanges();
                    }
                }
                else if (SelectedItem != null)
                {
                    using (var db = new MeiMeiContext())
                    {
                        var shedule = new Shedule
                        {
                            CustomerName    = SelectedItem.FIO,
                            ServicePrice    = SelectedThisService.ServicePrice,
                            ServiceName     = SelectedThisService.ServiceName,
                            Data            = MyDate.Date,
                            EmployeeTableId = SelectedEmployee.Id,
                            Time            = firstNum.ToString(),
                            Size            = size.ToString(),
                            Room            = Room,
                            Column          = (_shedule.ColumnNumber + 1).ToString()
                        };


                        var history = new History
                        {
                            CustomersId = SelectedItem.Id,
                            Data        = MyDate.Date.ToString(),
                            ServiceName = SelectedThisService.ServiceName,
                            ServiceCost = SelectedThisService.ServicePrice + " грн."
                        };


                        var employeeHistory = new EmployeeHistory
                        {
                            Cost            = SelectedThisService.ServicePrice,
                            Data            = MyDate.Date,
                            EmployeeTableId = SelectedEmployee.Id,
                            ServiceName     = SelectedThisService.ServiceName
                        };

                        db.Shedules.Add(shedule);
                        db.SaveChanges();

                        db.Histories.Add(history);
                        db.SaveChanges();

                        db.EmployeeHistories.Add(employeeHistory);
                        db.SaveChanges();
                    }
                }
                MessageBox.Show(Properties.Resources.Сompleted_message, "", MessageBoxButton.OK,
                                MessageBoxImage.Information);


                ScheduleVM.Instance.FindeShedule(ShedulePage.Instance.gridShedule);
            }
            else
            {
                MessageBox.Show(Properties.Resources.FirstFill_message, "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 23
0
        public void SellGoodsClick(object obj)
        {
            if (SelectedGoods != null)
            {
                int price = Convert.ToInt32(SelectedGoods.GoodPrice) * Convert.ToInt32(Count);

                int newCount = Convert.ToInt32(SelectedGoods.Count) - Convert.ToInt32(Count);


                using (var db = new MeiMeiContext())
                {
                    if (SelectedCustomers != null)
                    {
                        var goodHistory = new GoodHistory
                        {
                            GoodName = SelectedGoods.GoodName,
                            Price    = price.ToString(),
                            Data     = DateTime.Now,
                            Customer = SelectedCustomers.FIO
                        };
                        db.GoodHistories.Add(goodHistory);
                        db.SaveChanges();



                        var goods = (from b in db.Goods
                                     where
                                     b.GoodName == GoodVM.Instance.SelectedGoods.GoodName &&
                                     b.GoodPrice == GoodVM.Instance.SelectedGoods.GoodPrice &&
                                     b.Count == GoodVM.Instance.SelectedGoods.Count
                                     select b).FirstOrDefault();

                        if (newCount >= 0)
                        {
                            goods.Count = newCount.ToString();
                            db.SaveChanges();
                            OnPropertyChanged("GoodsColl");
                            OnPropertyChanged("GoodsHistoryColl");
                        }
                        else
                        {
                            MessageBox.Show("Больше продать нельзя");
                        }
                    }
                    else if (selectedCustomers == null)
                    {
                        using (var bd = new MeiMeiContext())
                        {
                            var customer = new Customers
                            {
                                FIO = Customer
                            };
                            bd.Customers.Add(customer);
                            bd.SaveChanges();

                            var goodHistory = new GoodHistory
                            {
                                GoodName = SelectedGoods.GoodName,
                                Price    = price.ToString(),
                                Data     = DateTime.Now,
                                Customer = Customer
                            };
                            bd.GoodHistories.Add(goodHistory);
                            bd.SaveChanges();



                            var goods = (from b in bd.Goods
                                         where
                                         b.GoodName == GoodVM.Instance.SelectedGoods.GoodName &&
                                         b.GoodPrice == GoodVM.Instance.SelectedGoods.GoodPrice &&
                                         b.Count == GoodVM.Instance.SelectedGoods.Count
                                         select b).FirstOrDefault();

                            OnPropertyChanged("CustomerColl");

                            if (newCount >= 0)
                            {
                                goods.Count = newCount.ToString();
                                bd.SaveChanges();
                                OnPropertyChanged("GoodsColl");
                                OnPropertyChanged("GoodsHistoryColl");
                            }
                            else
                            {
                                MessageBox.Show("Больше продать нельзя");
                            }
                        }
                    }
                }
            }
        }