Exemplo n.º 1
0
 private void ClientBuyMembership()
 {
     if (ClientIDTxtBox.Text.Length > 0)
     {
         ClientMembership clientBought = e.ClientMemberships
                                         .FirstOrDefault(p => p.Client_ID.ToString() == ClientIDTxtBox.Text && p.IsActive == true);
         if (clientBought != default)
         {
             clientBought.IsActive = false;
             e.SaveChanges();
             clientBought                     = new ClientMembership();
             clientBought.Client_ID           = Guid.Parse(ClientIDTxtBox.Text);
             clientBought.ClientMembership_ID = Guid.NewGuid();
             clientBought.Membership_ID       = MembershipIDComboBox.SelectedIndex + 1;
             clientBought.RemainingVisits     = e.MembershipClassifications
                                                .Where(type => type.Membership_ID == clientBought.Membership_ID)
                                                .Select(p => p.NumberOfVisits).First();
             clientBought.PurchaseDate = DateTime.Now.Date;
             clientBought.IsActive     = true;
             e.ClientMemberships.Add(clientBought);
             e.SaveChanges();
             CreateClientsTable();
             MessageBox.Show("Покупка оформлена!");
         }
     }
     else
     {
         MessageBox.Show("Ошибка при выборе!");
     }
 }
Exemplo n.º 2
0
 private void AddNewClient()
 {
     if (IsTextStringCorrect(ClientFirstNameTxtBox.Text) && IsTextStringCorrect(ClientMiddleNameTxtBox.Text) &&
         IsTextStringCorrect(ClientLastNameTxtBox.Text) && IsPhoneCorrect(ClientPhoneTxtBox) &&
         IsAdult(ClientBirthDatePicker.SelectedDate))
     {
         var client = new Client
         {
             Client_ID   = Guid.NewGuid(),
             FirstName   = ClientFirstNameTxtBox.Text,
             MiddleName  = ClientMiddleNameTxtBox.Text,
             LastName    = ClientLastNameTxtBox.Text,
             PhoneNumber = ClientPhoneTxtBox.Text,
             BirthDate   = ClientBirthDatePicker.SelectedDate
         };
         ClientMembership clientMembership = new ClientMembership
         {
             Client_ID           = client.Client_ID,
             ClientMembership_ID = Guid.NewGuid(),
             Membership_ID       = MembershipIDComboBox.SelectedIndex + 1
         };
         clientMembership.RemainingVisits = e.MembershipClassifications
                                            .Where(type => type.Membership_ID == clientMembership.Membership_ID)
                                            .Select(p => p.NumberOfVisits).First();
         clientMembership.PurchaseDate = DateTime.Now.Date;
         clientMembership.IsActive     = true;
         e.Clients.Add(client);
         e.ClientMemberships.Add(clientMembership);
         e.SaveChanges();
     }
     else
     {
         MessageBox.Show("Данные для регистрации клиента введены неверно!");
     }
 }
Exemplo n.º 3
0
 private void DecreaseNumberOfVisits()
 {
     if (ClientIDTxtBox.Text.Length > 0)
     {
         ClientMembership clientDecrease = e.ClientMemberships
                                           .FirstOrDefault(p => p.Client_ID.ToString() == ClientIDTxtBox.Text && p.IsActive == true);
         clientDecrease.RemainingVisits--;
         e.SaveChanges();
         MessageBox.Show("Посещение отмечено!");
     }
     else
     {
         MessageBox.Show("Клиент не выбран!");
     }
 }