Browse Source

change MainWindowViewModule

AngelikaSuhareva 4 months ago
parent
commit
abb15113d4

+ 28 - 2
ViewModels/MainWindowViewModel.cs

@@ -77,6 +77,30 @@ namespace Acosta.ViewModels
             UC = new VisitsView();
         }
 
+        public void EditUser(int userId)
+        {
+            editUserVM = new EditEmployeeViewModel(myConnection5, userId);
+            UC = new EditEmployeesView();
+        }
+
+        public void EditOutlet(int outletId)
+        {
+            editOutletVM = new EditOutletViewModel(myConnection6, outletId);
+            UC = new EditOutletsView();
+        }
+
+        public void SaveEditUser()
+        {
+            myConnection5.SaveChanges();
+            UC = new EmployeesView();
+        }
+
+        public void SaveEditOutlet()
+        {
+            myConnection6.SaveChanges();
+            UC = new OutletsView();
+        }
+
         public UserControl UC { get => uc; set => this.RaiseAndSetIfChanged(ref uc, value); } 
         private UserControl uc = new AuthorizationView();
         public int curUsId;
@@ -103,20 +127,22 @@ namespace Acosta.ViewModels
             }
         }
 
-        public void SavePassword()
+        /*public void SavePassword()
         {
             ChangePasswordView changePasswordView = new ChangePasswordView();
             currentUser = myConnection.Employees.FirstOrDefault(x => x.Email == AuthorizationVM.Login && x.Password == AuthorizationVM.Password);
             changePasswordView.cp(currentUser);
             myConnection.SaveChanges();
             UC = new PersonalAccountView();
-        }
+        }*/
 
         public List<Project> ListProjects => myConnection.Projects.ToList();
         public List<TradeNetwork> ListTrades => myConnection.TradeNetworks.ToList();
         public List<Employee> ListEmployees => myConnection.Employees.Include(x => x.RoleNavigation).ToList().Where(x => x.Employeesid != curUsId).ToList();
         public List<Outlet> ListOutlets => myConnection.Outlets.ToList();
         public List<Visit> ListVisits => myConnection.Visits.ToList();
+
+        public List<Acceptance> ListAcceptance => myConnection.Acceptances.ToList();
         //List<a> newList = new List<a>(new a((from p in myConnection.Outlets.ToList() select p.Outletid).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Address).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Location).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.TradeNetworks.ToList() select p.Title).ToImmutableList().ToList().FirstOrDefault()));
         //public List<string> fkTrade => myConnection.TradeNetworks.ToList().Select(x => x.Title).Where()
         //List<a> newList = new List<a>(new a((from p in myConnection.Outlets.ToList() select p.Outletid).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Address).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Location).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.TradeNetworks.ToList() select p.Title).ToImmutableList().ToList().FirstOrDefault()));

+ 2 - 2
Views/ChangePasswordView.axaml

@@ -149,9 +149,9 @@
 					<TextBlock Classes="TextToTextBox">Введите новый пароль:</TextBlock>
 					<TextBox Name="tbNewPas" Width="360"></TextBox>
 				</StackPanel>
-				<Button Classes="BtSave" Command="{Binding SavePassword}">
+				<!--<Button Classes="BtSave" Command="{Binding SavePassword}">
 					<TextBlock Classes="TextBtSave">Сохранить</TextBlock>
-				</Button>
+				</Button>-->
 			</StackPanel>
 		</StackPanel>
 	</Grid>

+ 2 - 2
Views/ChangePasswordView.axaml.cs

@@ -26,9 +26,9 @@ public partial class ChangePasswordView : UserControl
         InitializeComponent();
     }
 
-    public void cp(Employee? currentUser)
+    /*public void cp(Employee? currentUser)
     {
         int curUsId = currentUser.Employeesid;
         UserViewModel userVM = new UserViewModel(myConnection, curUsId, tbNewPas.Text, currentUser);
-    }
+    }*/
 }