Exemplo n.º 1
0
        private void AuthClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IsFieldsEmpty())
                {
                    SharedClass.MessageBoxWarning("Все поля должны быть заполнены");
                    return;
                }

                if (userRepo.IsAuth(this.txtLogin.Text.Trim(), this.txtPassword.Text.Trim()))
                {
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    this.Close();
                }
                else
                {
                    SharedClass.MessageBoxWarning($"Неправильный логин или пароль.");
                }
            }
            catch (Exception ex)
            {
                SharedClass.MessageBoxError(ex);
            }
        }
Exemplo n.º 2
0
 private void AuthClick(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.txtLogin.Text != "" && this.txtPassword.Text != "")
         {
             if (model.IsAuth(this.txtLogin.Text, this.txtPassword.Text))
             {
                 SharedClass.OpenNewPage(this, new MainMenu());
             }
             else
             {
                 SharedClass.MessageBoxWarning("Неправильный логин или пароль");
             }
         }
         else
         {
             SharedClass.MessageBoxWarning("Все поля должны быть заполнены");
         }
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 3
0
        //sing in application
        private void ClickBtnSing(object sender, RoutedEventArgs e)
        {
            try
            {
                string login = this.TxbLogin.Text;

                string password = this.PsbPassword.Password;

                //if check is null, send message for user
                if (!user.CheckFields(login, password))
                {
                    return;
                }

                //authorization user
                if (!user.AuthUser(login, password))
                {
                    return;
                }

                //open MainPage if User has
                SharedClass.OpenNewWindow(new MainWindow(), this);
            }
            catch (Exception ex)
            {
                SharedClass.MessageBoxError(ex.Message);
            }
        }
 private void SaveEditAboutCar(object sender, RoutedEventArgs routedEventArgs)
 {
     try
     {
         if (!Admin.isSelected(SelectedCar))
         {
             SharedClass.MessageBoxWarning("Выберите автомобиль в таблице");
             return;
         }
         if (Admin.checkVIN(SelectedCar))
         {
             SharedClass.MessageBoxWarning("Все поля должны быть заполнены");
         }
         else
         {
             Controller.Model.SaveChanges();
             SharedClass.MessageBoxInformation("Data Success Edit for selected car");
             UpdateDataGrid();
         }
     }
     catch (NullReferenceException)
     {
         SharedClass.MessageBoxWarning("Все поля должны быть заполнены");
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
 //add new car in BD
 private void AddCar(object sender, RoutedEventArgs routedEventArgs)
 {
     try
     {
         //check fiels, if have null -> send message for user
         if (Admin.checkVIN(NewCar))
         {
             SharedClass.MessageBoxWarning("Все поля должны быть заполнены");
         }
         else
         {
             //add new user and send message for user
             Admin.AddCar(NewCar);
             SharedClass.MessageBoxInformation("Автомобиль успешно добавлен в базу данных");
             this.Close();
         }
     }
     catch (DbEntityValidationException)
     {
         SharedClass.MessageBoxWarning("Заполните все поля");
     }
     catch (NullReferenceException)
     {
         SharedClass.MessageBoxWarning("Все поля должны быть заполнены");
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 6
0
        private void SaveChanges(object sender, RoutedEventArgs e)
        {
            try
            {
                //check fiels, if null -> send message for user
                if (!new Controller.User().CheckFields(Controller.User.AuthorizedUser.Email, Controller.User.AuthorizedUser.Password,
                                                       Controller.User.AuthorizedUser.FirstName, Controller.User.AuthorizedUser.LastName))
                {
                    return;
                }

                Controller.Model.SaveChanges();

                SharedClass.MessageBoxInformation("Данные о пользователе успешно отредактированы");

                //open main menu, for type auth user
                if (new Controller.User().isAdmin())
                {
                    SharedClass.OpenNewPage(this, new View.Admin.MainMenu());
                }
                else
                {
                    SharedClass.OpenNewPage(this, new View.Client.MainMenu());
                }
            }
            catch (Exception ex)
            {
                SharedClass.MessageBoxError(ex);
            }
        }
Exemplo n.º 7
0
 private void BackClick(object sender, RoutedEventArgs e)
 {
     try {
         SharedClass.OpenNewPage(this, new ListClients());
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 8
0
 public Auth()
 {
     try
     {
         InitializeComponent();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 9
0
 private void Statistick(object sender, RoutedEventArgs eventArgs)
 {
     try
     {
         this.MainFrame.Content = new View.Admin.Statistick();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 10
0
 private void AddNewRent(object sender, RoutedEventArgs routedEventArgs)
 {
     try
     {
         SharedClass.OpenNewPage(this, new View.Client.AddNewRent());
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 11
0
 //edit data for account
 private void SettingsAccount(object sender, RoutedEventArgs e)
 {
     try
     {
         this.MainFrame.Content = new View.User.SettingsAccount();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 12
0
 private void AddNewRent(object sender, RoutedEventArgs eventArgs)
 {
     try
     {
         this.MainFrame.Content = new View.Client.AddNewRent();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 13
0
 private void LoadDataGrid()
 {
     try
     {
         this.ListRentCarsForUser.ItemsSource = Client.getListRentForUser(CarSharing.Controller.User.AuthorizedUser);
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// genarate main Window
 /// </summary>
 public MainWindow()
 {
     try
     {
         InitializeComponent();
         SharedClass.SetFrame(this.MainFrame, new ListClients());
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 15
0
 //update data in DataGrid
 private void UpdateDataGrid()
 {
     try
     {
         this.ListCars.ItemsSource = null;
         this.ListCars.ItemsSource = Admin.getListCars();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 16
0
 public MainWindow()
 {
     try
     {
         InitializeComponent();
         SetAuthText();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 17
0
 public SelectCity()
 {
     try
     {
         InitializeComponent();
         this.ListCities.ItemsSource = new Controller.Client().getListCities();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 18
0
 public MainMenu()
 {
     try
     {
         InitializeComponent();
         LoadDataGrid();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 19
0
 public AddNewRent()
 {
     try
     {
         InitializeComponent();
         SetStartTextBlocks();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 20
0
 private void SelectCityInDataGrid(object sender, RoutedEventArgs routedEventArgs)
 {
     try
     {
         Client.AddNewRent.SelectedCity = (CarSharing.Model.City) this.ListCities.SelectedItem;
         this.DialogResult = true;
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 21
0
 public ListOfCars()
 {
     try
     {
         InitializeComponent();
         LoadDataAboutCars();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 22
0
 //open window for add Car and Update data in DataGrid
 private void AddNewCar(object sender, RoutedEventArgs routedEventArgs)
 {
     try
     {
         new View.Admin.AddNewCar().ShowDialog();
         UpdateDataGrid();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 23
0
 public ListClients()
 {
     try
     {
         InitializeComponent();
         UpdateList();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 24
0
 private void UpdatePage()
 {
     try
     {
         this.ListRentCarsForUser.ItemsSource = null;
         rentCarForUser = new Model.RentCarForUser();
         LoadDataGrid();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 25
0
 private void SetStartTextBlocks()
 {
     try
     {
         setTextAuto("");
         setTextCity("");
         setTextPrice("");
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 26
0
 public AddNewCar()
 {
     try
     {
         InitializeComponent();
         this.DataContext = NewCar;
         this.LoadDataInComboBox();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 27
0
 private void getFuncForClient()
 {
     try
     {
         this.AdminFunctional.Visibility  = Visibility.Hidden;
         this.ClientFunctional.Visibility = Visibility.Visible;
         this.MainFrame.Content           = new View.Client.MainMenu();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 28
0
 public SettingsAccount()
 {
     try
     {
         InitializeComponent();
         //load data for auth User
         DataContext  = Controller.User.AuthorizedUser;
         TblRole.Text = $"Your Role: {Controller.User.AuthorizedUser.Role.NameRole}";
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 29
0
 private void LoadDataInComboBox()
 {
     try
     {
         this.CmbCarColor.ItemsSource   = Admin.getListColors();
         this.CmbTypeOfCar.ItemsSource  = Admin.getListTypeOfCar();
         this.CmbCarMake.ItemsSource    = Admin.getListCarMakes();
         this.CmbTypeEngine.ItemsSource = Admin.getListTypeEngines();
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }
Exemplo n.º 30
0
 //set DataContext from Selected Row
 private void SelectCar(object sender, RoutedEventArgs routedEventArgs)
 {
     try
     {
         if (this.ListCars.SelectedItem != null)
         {
             this.SelectedCar = (Model.Car) this.ListCars.SelectedItem;
             this.DataContext = this.SelectedCar;
         }
     }
     catch (Exception ex)
     {
         SharedClass.MessageBoxError(ex);
     }
 }