コード例 #1
0
        public void searchInTxtBox()
        {
            List <Client> currentClient = AutoserviceBaseEntities.getContext().Client.ToList();

            currentClient = currentClient.Where(p => p.FirstName.ToLower().Contains(txtBoxSearch.Text.ToLower()) || p.LastName.ToLower().Contains(txtBoxSearch.Text.ToLower()) || p.Patronymic.ToLower().Contains(txtBoxSearch.Text.ToLower()) || p.Email.ToLower().Contains(txtBoxSearch.Text.ToLower()) || p.Phone.ToLower().Contains(txtBoxSearch.Text.ToLower())).ToList();
            ListViewClient.ItemsSource = currentClient.ToList();
        }
コード例 #2
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (comboBoxClient.SelectedItem == null)
            {
                stringBuilder.AppendLine("Не выбран клиент");
            }
            if (comboBoxService.SelectedItem == null)
            {
                stringBuilder.AppendLine("Не выбрана услуга");
            }
            if (datePickerBoxStart.ToString() == null)
            {
                stringBuilder.AppendLine("Не выбрана дата начала");
            }
            if (stringBuilder.Length != 0)
            {
                MessageBox.Show(stringBuilder.ToString(), "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            try
            {
                currentClientService.StartTime = (DateTime)datePickerBoxStart.SelectedDate;
                AutoserviceBaseEntities.getContext().ClientService.Add(currentClientService);
                AutoserviceBaseEntities.getContext().SaveChanges();
                MessageBox.Show("Данные успешно сохранены!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                Manager.mainFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка" + ex.Message.ToString());
                return;
            }
        }
コード例 #3
0
 private void Page_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (Visibility == Visibility.Visible)
     {
         AutoserviceBaseEntities.getContext().ChangeTracker.Entries().ToList().ForEach(p => p.Reload());
         DGridServices.ItemsSource = AutoserviceBaseEntities.getContext().Service.ToList();
     }
 }
コード例 #4
0
 public ClientServiceAddPage()
 {
     InitializeComponent();
     currentClientService                = new ClientService();
     DataContext                         = currentClientService;
     comboBoxClient.ItemsSource          = AutoserviceBaseEntities.getContext().Client.ToList();
     comboBoxService.ItemsSource         = AutoserviceBaseEntities.getContext().Service.ToList();
     datePickerBoxStart.DisplayDateStart = DateTime.Now;
 }
コード例 #5
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     if (radioService.IsChecked == true)
     {
         try
         {
             SaveFileDialog saveFileDialog = new SaveFileDialog();
             saveFileDialog.Filter = "csv files (.csv)|.csv";
             saveFileDialog.ShowDialog();
             StringBuilder sb = new StringBuilder();
             sb.Append("Наименование, Цена, Длительность, Описание, Скидка ");
             sb.AppendLine();
             foreach (var service in AutoserviceBaseEntities.getContext().Service)
             {
                 sb.Append(service.Title + " ");
                 sb.Append(service.Cost + " ");
                 sb.Append(service.DurationInSeconds + " ");
                 sb.Append(service.Description + " ");
                 sb.Append(service.Discount);
                 sb.AppendLine();
             }
             File.WriteAllText(saveFileDialog.FileName, sb.ToString());
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message.ToString());
         }
     }
     if (radioProduct.IsChecked == true)
     {
         try
         {
             SaveFileDialog saveFileDialog = new SaveFileDialog();
             saveFileDialog.Filter = "csv files (.csv)|.csv";
             saveFileDialog.ShowDialog();
             StringBuilder sb = new StringBuilder();
             sb.Append("Наименование, Цена, Описание, Статус, Производитель ");
             sb.AppendLine();
             foreach (var product in AutoserviceBaseEntities.getContext().Product)
             {
                 sb.Append(product.Title + " ");
                 sb.Append(product.Cost + " ");
                 sb.Append(product.Description + " ");
                 sb.Append(product.IsActive + " ");
                 sb.Append(product.Manufacturer.Name);
                 sb.AppendLine();
             }
             File.WriteAllText(saveFileDialog.FileName, sb.ToString());
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message.ToString());
         }
     }
 }
コード例 #6
0
 public EditClientPage(Client client)
 {
     InitializeComponent();
     currentClient = new Client();
     if (client != null)
     {
         currentClient = client;
     }
     DataContext = currentClient;
     comboBoxGender.ItemsSource = AutoserviceBaseEntities.getContext().Gender.ToList();
 }
コード例 #7
0
 public EditUserPage(User user)
 {
     InitializeComponent();
     currentUser = new User();
     if (user != null)
     {
         currentUser = user;
     }
     DataContext = currentUser;
     comboBoxRole.ItemsSource = AutoserviceBaseEntities.getContext().Role.ToList();
 }
コード例 #8
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (string.IsNullOrEmpty(currentClient.FirstName))
            {
                stringBuilder.AppendLine("Не введено имя");
            }
            if (string.IsNullOrEmpty(currentClient.LastName))
            {
                stringBuilder.AppendLine("Не введена фамилия");
            }
            if (string.IsNullOrEmpty(currentClient.Patronymic))
            {
                stringBuilder.AppendLine("Не введено отчество");
            }
            if (datePickerBirthday.SelectedDate == null)
            {
                stringBuilder.AppendLine("Не выбрана дата рождения");
            }
            if (datePickerRegDate.SelectedDate == null)
            {
                stringBuilder.AppendLine("Не выбрана дата регистрации");
            }
            if (string.IsNullOrEmpty(currentClient.Email))
            {
                stringBuilder.AppendLine("Не введено отчество");
            }
            if (string.IsNullOrEmpty(currentClient.Phone))
            {
                stringBuilder.AppendLine("Не введен телефон");
            }
            if (comboBoxGender.SelectedItem == null)
            {
                stringBuilder.AppendLine("Не введен пол");
            }
            if (stringBuilder.Length != 0)
            {
                MessageBox.Show(stringBuilder.ToString(), "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            try
            {
                AutoserviceBaseEntities.getContext().SaveChanges();
                MessageBox.Show("Данные успешно сохранены!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                Manager.mainFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка" + ex.Message.ToString());
            }
        }
コード例 #9
0
 private void comboBoxSort_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (comboBoxSort.SelectedIndex == 0)
     {
         ListViewClient.ItemsSource = AutoserviceBaseEntities.getContext().Client.OrderBy(p => p.LastName).ToList();
     }
     if (comboBoxSort.SelectedIndex == 1)
     {
         ListViewClient.ItemsSource = AutoserviceBaseEntities.getContext().Client.OrderBy(p => p.FirstName).ToList();
     }
     if (comboBoxSort.SelectedIndex == 2)
     {
         ListViewClient.ItemsSource = AutoserviceBaseEntities.getContext().Client.OrderBy(p => p.Patronymic).ToList();
     }
 }
コード例 #10
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (string.IsNullOrEmpty(txtBoxTitle.Text))
            {
                stringBuilder.AppendLine("Не введено наименование");
            }
            if (string.IsNullOrEmpty(txtBoxCost.Text))
            {
                stringBuilder.AppendLine("Не введена стоимость");
            }
            if (string.IsNullOrEmpty(txtBoxDuration.Text))
            {
                stringBuilder.AppendLine("Не введена продолжительность");
            }
            if (string.IsNullOrEmpty(txtBoxDiscount.Text))
            {
                stringBuilder.AppendLine("Не введена скидка");
            }
            if (stringBuilder.Length != 0)
            {
                MessageBox.Show(stringBuilder.ToString(), "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }


            try
            {
                AutoserviceBaseEntities.getContext().Service.Add(currentService);
                AutoserviceBaseEntities.getContext().SaveChanges();
                MessageBox.Show("Данные успешно сохранены!");
                Manager.mainFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка" + ex.Message.ToString());
            }
        }
コード例 #11
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (string.IsNullOrEmpty(currentUser.FirstName))
            {
                stringBuilder.AppendLine("Не введено имя");
            }
            if (string.IsNullOrEmpty(currentUser.LastName))
            {
                stringBuilder.AppendLine("Не введена фамилия");
            }
            if (string.IsNullOrEmpty(currentUser.Login))
            {
                stringBuilder.AppendLine("Не введен логин");
            }
            if (comboBoxRole.SelectedItem == null)
            {
                stringBuilder.AppendLine("Не введена роль");
            }
            if (stringBuilder.Length != 0)
            {
                MessageBox.Show(stringBuilder.ToString(), "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            try
            {
                AutoserviceBaseEntities.getContext().SaveChanges();
                MessageBox.Show("Данные успешно сохранены!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                Manager.mainFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка" + ex.Message.ToString());
            }
        }
コード例 #12
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            int count = 0;

            AuthHistory history = new AuthHistory();
            int         userId  = 0;

            foreach (var user in AutoserviceBaseEntities.getContext().User)
            {
                count++;
                if (txtBoxLogin.Text == user.Login && passBoxPassword.Password == user.Password || txtBoxPassword.Text == user.Password)
                {
                    Manager.firstName = user.FirstName;
                    Manager.lastName  = user.LastName;
                    foreach (var role in AutoserviceBaseEntities.getContext().Role)
                    {
                        if (user.RoleId == role.Id)
                        {
                            Manager.role = role.Name;
                        }
                    }
                    user.LastEnter = DateTime.Now;
                    userId         = user.Id;
                    MessageBox.Show("Вы успешно авторизованы.", "Информация!", MessageBoxButton.OK, MessageBoxImage.Information);
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    count = 0;
                    this.Close();
                    break;
                }
                if (txtBoxLogin.Text == user.Login)
                {
                    userId = user.Id;
                }
            }
            if (count != 0)
            {
                MessageBox.Show("Логин или пароль не верны!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Warning);
                try
                {
                    history.UserId   = userId;
                    history.DateTime = DateTime.Now;
                    history.Status   = "Blocked";
                    AutoserviceBaseEntities.getContext().AuthHistory.Add(history);
                    AutoserviceBaseEntities.getContext().SaveChanges();
                }
                catch
                {
                    MessageBox.Show("Ошибка записи истории входа в базу данных!\nПроверьте правильность введенных данных.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            countErrorAuths++;
            if (countErrorAuths % 3 == 0)
            {
                MessageBox.Show("Превышено количество попыток входа!\nПовторите попытку через 10 секунд.", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Warning);
                Thread.Sleep(10000);
            }
            try
            {
                if (!string.IsNullOrEmpty(txtBoxLogin.Text) && !string.IsNullOrEmpty(passBoxPassword.Password) && count == 0)
                {
                    history.UserId   = userId;
                    history.DateTime = DateTime.Now;
                    history.Status   = "Successfull";
                    AutoserviceBaseEntities.getContext().AuthHistory.Add(history);
                    AutoserviceBaseEntities.getContext().SaveChanges();
                }
            }
            catch
            {
                MessageBox.Show("Ошибка связи с базой данной!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }