Kaynağa Gözat

some changes (popitki to replace title instead of id)

bai 4 ay önce
ebeveyn
işleme
da442aa4c7

+ 49 - 1
ViewModels/MainWindowViewModel.cs

@@ -26,6 +26,9 @@ namespace Acosta.ViewModels
         AddOutletsViewModel outletVM = new AddOutletsViewModel(myConnection);
         public AddOutletsViewModel OutletVM { get => outletVM; set => outletVM = value; }
 
+        PersonalAccountViewModel personalAccountVM = new PersonalAccountViewModel(myConnection);
+        public PersonalAccountViewModel PersonalAccountVM { get => personalAccountVM; set => personalAccountVM = value; }
+
         public void SaveNetwork()
         {
             myConnection.SaveChanges();
@@ -45,7 +48,8 @@ namespace Acosta.ViewModels
         }*/
 
         public UserControl UC { get => uc; set => this.RaiseAndSetIfChanged(ref uc, value); } 
-        private UserControl uc = new TradeNetworksView();
+        private UserControl uc = new AuthorizationView();
+        public int curUsId;
 
         public void LoadPersonalAccount()
         {
@@ -62,6 +66,8 @@ namespace Acosta.ViewModels
             else
             {
                 AuthorizationVM.Message = "Успех!";
+                curUsId = currentUser.Employeesid;
+                PersonalAccountVM = new PersonalAccountViewModel(myConnection, curUsId);
                 UC = new PersonalAccountView();
             }
         }
@@ -69,8 +75,50 @@ namespace Acosta.ViewModels
         public List<Project> ListProjects => myConnection.Projects.ToList();
         public List<Employee> ListEmployees => myConnection.Employees.ToList();
         public List<Outlet> ListOutlets => myConnection.Outlets.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 struct a
+        {
+            int Outlerid;
+            string Address;
+            string Location;
+            string TradeNetworks;
+            
+
+            public a(int oid, string ad, string loc, string tn)
+            {
+                Outlerid = oid;
+                Address = ad;
+                Location = loc;
+                TradeNetworks = tn;
+            }
+        }
+        //public IEnumerable<dynamic> ListOutlets => myConnection.Outlets.Select(p => new
+        //{
+        //    p.Outletid,
+        //    p.Address,
+        //    p.Location,
+        //    TradeTitles = ListTrades.Where(x => x.Tradeid == p.TradeNetworks).Select(x => x.Title),
+        //    p.TradeNetworks,
+        //    p.Visits
+        //}).ToList();
+        //    public List<Outlet> ListOutlets => myConnection.Outlets
+        //.Join(myConnection.TradeNetworks,
+        //      outlet => outlet.TradeNetworks,
+        //      tradeNetwork => tradeNetwork.Tradeid,
+        //      (outlet, tradeNetwork) => new Outlet
+        //      {
+        //          Outletid = outlet.Outletid,
+        //          Address = outlet.Address,
+        //          Location = outlet.Location,
+        //          TradeNetworks = tradeNetwork.Title, // replace this with the actual property name for the retail chain name
+        //          Visits = outlet.Visits
+        //      })
+        //.ToList();
         public List<TradeNetwork> ListTrades => myConnection.TradeNetworks.ToList();
 
+        
+
         /*public List<Role> rolesList => (from p in myConnection.Roles.ToList() where p.Title != "Оператор" select p).ToImmutableList().ToList();
         public List<Employee> userList => (from p in myConnection.Employees.ToList() where p.Role != 1 select p).ToImmutableList().ToList();*/
 

+ 32 - 0
ViewModels/PersonalAccountViewModel.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using ReactiveUI;
+using Acosta.Models;
+using Microsoft.EntityFrameworkCore;
+using System.Linq;
+
+namespace Acosta.ViewModels
+{
+	public class PersonalAccountViewModel : ReactiveObject
+	{
+		SuharevaContext myConnection;
+		Employee currentUser;
+        string oldPass;
+        public string FIO;
+        public PersonalAccountViewModel(SuharevaContext myConnection)
+		{
+            this.myConnection = myConnection;
+            CurrentUser = new Employee();
+            myConnection.Add(CurrentUser);
+        }
+        public PersonalAccountViewModel(SuharevaContext myConnection, int id)
+        {
+            this.myConnection = myConnection;
+            CurrentUser = myConnection.Employees.FirstOrDefault(x => x.Employeesid == id);
+            oldPass = CurrentUser.Password;
+            CurrentUser.Surname = CurrentUser.Surname + " " + CurrentUser.Name.ToCharArray()[0] + ". " + CurrentUser.Patronymic.ToCharArray()[0] + ".";
+        }
+
+        public Employee CurrentUser { get => currentUser; set => currentUser = value; }
+    }
+}

+ 2 - 2
Views/OutletsView.axaml

@@ -196,8 +196,8 @@
 								<!--<Border  Classes="Data" CornerRadius="13"  Width="180" Height="40" Margin="0 0 140 0">
 						<TextBlock Classes="Data">Типа ID</TextBlock>
 					</Border>-->
-								<TextBox Text="{Binding Outletid}" Classes="EditTextBox" Width="70" Margin="0 0 140 0">Типа id</TextBox>
-								<TextBox Text="{Binding TradeNetworks}" Classes="EditTextBox" Width="70" Margin="0 0 140 0">Типа название торговой сети</TextBox>
+								<TextBlock Text="{Binding Outletid}" Classes="EditTextBox" Width="70" Margin="0 0 140 0">Типа id</TextBlock>
+								<TextBlock Text="{Binding $parent[Window].((vm:MainWindowViewModel)DataContext).getTitle}" Classes="EditTextBox" Width="70" Margin="0 0 140 0">Типа название торговой сети</TextBlock>
 								<!--<Border  Classes="Data" CornerRadius="13"  Width="310" Height="40" Margin="0 0 140 0">
 						<TextBlock Classes="Data">Типа название торговой сети</TextBlock>
 					</Border>-->

+ 1 - 1
Views/PersonalAccountView.axaml

@@ -43,7 +43,7 @@
 				<StackPanel Orientation="Horizontal">
 					<TextBlock Classes="headerLogo">Acosta</TextBlock>
 					<TextBlock Classes="greeting" Margin="770 12 0 0">Добро пожаловать, оператор</TextBlock>
-					<TextBlock Classes="greeting" Margin="7 12 0 0" FontWeight="Bold" Name="FIO">Фамилия И.О.</TextBlock>
+					<TextBlock Classes="greeting" Margin="7 12 0 0" FontWeight="Bold" Name="FIO" Text="{Binding PersonalAccountVM.CurrentUser.Surname}"/>
 					<TextBlock Classes="greeting" Margin="10 10 0 0">/</TextBlock>
 					<Button Classes="headerBt" Command="">Изменить пароль</Button>
 					<TextBlock Classes="greeting" Margin="0 10 0 0">/</TextBlock>

+ 1 - 0
Новый текстовый документ.txt

@@ -0,0 +1 @@
+ardaismine@gmail.com