Parcourir la source

All Application

MoskalenkoSergey il y a 6 mois
Parent
commit
512653bc80

+ 4 - 6
PP_Ven_MosS/Pages/ApplicationsListAdmin.xaml.cs

@@ -48,8 +48,7 @@ namespace PP_Ven_MosS.Pages
             
             InitializeComponent();
            
-            ApplicationList.ItemsSource = DB.Applications.ToList().Where(x => x.Id_employee == user.Id_user);
-            Applications appl = DB.Applications.Where(x => x.Id_status_app == id).FirstOrDefault();
+            ApplicationList.ItemsSource = DB.Applications.Where(x => x.Id_employee == UserID.userid).ToList();
             CB_Filter_app.ItemsSource = new List<string> { "Фильтр по статусу", "Выполнен", "Не выполнен" };
             CB_Sort_app.ItemsSource = new List<string>() { "Фильтр по дате","Не сегодня", "Сегодня" };
             CB_Sort_app.SelectedIndex = 0;
@@ -65,8 +64,7 @@ namespace PP_Ven_MosS.Pages
         public ApplicationsListAdmin(int id)
         {
             InitializeComponent();
-            ApplicationList.ItemsSource = DB.Applications.ToList();
-            Applications appl = DB.Applications.Where(x => x.Id_application == id).FirstOrDefault();
+            ApplicationList.ItemsSource = DB.Applications.Where(x => x.Id_employee == UserID.userid).ToList();
             CB_Filter_app.ItemsSource = DB.Applications.ToList() ; 
             CB_Sort_app.ItemsSource = DB.Applications.ToList() ;
             CB_Sort_app.SelectedIndex = 0;
@@ -85,7 +83,7 @@ namespace PP_Ven_MosS.Pages
         {
             CheckBox cb = (CheckBox)sender;
             int id = Convert.ToInt32(cb.Uid);
-            Applications applications = Classes.Database.entities.Applications.FirstOrDefault(x => x.Id_application == id);
+            Applications applications = Classes.Database.entities.Applications.Where(x => x.Id_employee == UserID.userid).FirstOrDefault();
             applications.Id_status_app = 1;
             user.Count_complete_app++;
             Classes.Database.entities.SaveChanges();
@@ -103,7 +101,7 @@ namespace PP_Ven_MosS.Pages
         }
         private void Filter()
         {
-            List<Applications> applications = DB.Applications.ToList();
+            List<Applications> applications = DB.Applications.Where(x => x.Id_employee == UserID.userid).ToList();
             if (CB_Sort_app.SelectedIndex != 0)
             {
                 switch (CB_Sort_app.SelectedIndex)

+ 22 - 15
PP_Ven_MosS/Pages/Avtorization.xaml.cs

@@ -33,28 +33,35 @@ namespace PP_Ven_MosS
         }
         public void Sign_Click(object sender, RoutedEventArgs e)
         {
-            string GHCPass = PBPass.Password.GetHashCode().ToString();
-            User user = Database.entities.User.FirstOrDefault(x => x.Login == TBLog.Text && x.Password == GHCPass);
-            UserRole.userrole = user.Id_role;
-            UserID.userid = user.Id_user;
-            if (user != null)
+            try
             {
-                if (user.Id_role == 1)
+                string GHCPass = PBPass.Password.GetHashCode().ToString();
+                User user = Database.entities.User.FirstOrDefault(x => x.Login == TBLog.Text && x.Password == GHCPass);
+                UserRole.userrole = user.Id_role;
+                UserID.userid = user.Id_user;
+                if (user != null)
                 {
-                    FrameClass.MainFrame.Navigate(new MenuAdmin());
+                    if (user.Id_role == 1)
+                    {
+                        FrameClass.MainFrame.Navigate(new MenuAdmin());
+                    }
+                    else if (user.Id_role == 2)
+                    {
+                        FrameClass.MainFrame.Navigate(new ApplicationsListAdmin());
+                    }
+                    else if (user.Id_role == 3)
+                    {
+                        FrameClass.MainFrame.Navigate(new ApplicationsListUser());
+                    }
                 }
-                else if (user.Id_role == 2)
+                else
                 {
-                    FrameClass.MainFrame.Navigate(new ApplicationsListAdmin());
-                }
-                else if (user.Id_role == 3)
-                {
-                    FrameClass.MainFrame.Navigate(new ApplicationsListUser());
+                    MessageBox.Show("Неверный логин или пароль,\n попробуйте еще раз\n, или зарегистрируйтесь");
                 }
             }
-            else
+            catch
             {
-                MessageBox.Show("Неверный логин или пароль,\n попробуйте еще раз\n, или зарегистрируйтесь");
+                MessageBox.Show("Ошибка");
             }
         }
     }

+ 1 - 0
PP_Ven_MosS/Pages/MenuAdmin.xaml.cs

@@ -56,6 +56,7 @@ namespace PP_Ven_MosS.Pages
             if (ap.Id_employee != null)
             {
                 cb.SelectedValue = Convert.ToInt32(ap.Id_employee);
+                EmployeeID.employeeid = Convert.ToInt32(cb.SelectedValue);
             }
         }
 

+ 14 - 10
PP_Ven_MosS/Pages/Profile.xaml.cs

@@ -52,16 +52,20 @@ namespace PP_Ven_MosS.Pages
         // Кнопка сохранения изменений профиля
         private void Save_Click(object sender, RoutedEventArgs e)
         {
-            List<User> code = Classes.Database.entities.User.ToList();
-            changeuser.Surname = txtSurn.Text;
-            changeuser.Name = txtName.Text;
-            changeuser.Patronymic = txtPatron.Text;
-            changeuser.Post = txtPost.Text;
-            changeuser.Phone_number = txtPhone.Text;
-            changeuser.Login = txtLog.Text;
-            changeuser.Password = txtPass.Text;
-            Classes.Database.entities.SaveChanges();
-            users.usr = users.newuser();
+            PP_MininEntities2 DB = new PP_MininEntities2();
+            
+            User user = DB.User.FirstOrDefault(x => x.Id_user == UserID.userid);
+            user.Surname = txtSurn.Text;
+            user.Name = txtName.Text;
+            user.Patronymic = txtPatron.Text;
+            user.Post = txtPost.Text;
+            user.Phone_number = txtPhone.Text;
+            user.Login = txtLog.Text;
+            if(txtPass.Text != null)
+            {
+                user.Password = txtPass.Text.GetHashCode().ToString();
+            }
+            DB.SaveChanges();
             MessageBox.Show("Изменения сохранены");
         }