Przeglądaj źródła

Реализован весь функционал

Fox 6 miesięcy temu
rodzic
commit
d8ba31dc73
3 zmienionych plików z 75 dodań i 8 usunięć
  1. 15 6
      Pages/AddRemovePage.xaml
  2. 58 1
      Pages/AddRemovePage.xaml.cs
  3. 2 1
      Pages/PsychoPage.xaml.cs

+ 15 - 6
Pages/AddRemovePage.xaml

@@ -9,21 +9,30 @@
     <Grid Background="#00A08A">
 
         <Grid.RowDefinitions>
-            <RowDefinition Height="10*"/>
             <RowDefinition Height="*"/>
+            <RowDefinition Height="10*"/>
         </Grid.RowDefinitions>
-        
-        <ListView Margin="0,10,0,10" Name="TestList" Grid.Row="0" Background="#0000" BorderThickness="0">
+
+        <StackPanel>
+            <TextBlock FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" Text="Можете прикрепить или открепить пациентов"/>
+        </StackPanel>
+
+            <ListView HorizontalAlignment="Center" Margin="0,10,0,10" Name="PatientList" Grid.Row="1" Background="#0000" BorderThickness="0">
             <ListView.ItemsPanel>
                 <ItemsPanelTemplate>
-                    <StackPanel Width="1400"/>
+                    <StackPanel Width="1400" HorizontalAlignment="Center"/>
                 </ItemsPanelTemplate>
             </ListView.ItemsPanel>
 
             <ListView.ItemTemplate>
                 <DataTemplate>
-                    <StackPanel  Orientation="Horizontal">
-                        
+                    <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
+                        <TextBlock HorizontalAlignment="Center" FontSize="35" Uid="{Binding User_id}" Loaded="FullnameLoad"/>
+                        <CheckBox VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,0,0" Uid="{Binding User_id}" Name="addPasient" Checked="AddPatient" Unchecked="RemovePatient" Loaded="CheckBoxLoad">
+                            <CheckBox.LayoutTransform>
+                                <ScaleTransform ScaleX="2" ScaleY="2" />
+                            </CheckBox.LayoutTransform>
+                        </CheckBox>
                     </StackPanel>
                 </DataTemplate>
             </ListView.ItemTemplate>

+ 58 - 1
Pages/AddRemovePage.xaml.cs

@@ -19,9 +19,66 @@ namespace PsychoTest.Pages
     /// </summary>
     public partial class AddRemovePage : Window
     {
-        public AddRemovePage()
+        public PsychoBase DB = new PsychoBase();
+        public Users user = new Users();
+        public int psId;
+
+        public AddRemovePage(int psId)
         {
             InitializeComponent();
+
+            PatientList.ItemsSource = DB.Users.Where(x=>x.Id_role==2).ToList();
+            this.psId = psId;
+        }
+
+        private void AddPatient(object sender, RoutedEventArgs e)
+        {
+            CheckBox cb = (CheckBox)sender;
+            int id = Convert.ToInt32(cb.Uid);
+            user = DB.Users.Where(x=>x.User_id == id).FirstOrDefault();
+            if(user.Id_doctor != psId)
+            {
+                user.Id_doctor = psId;
+                DB.SaveChanges();
+                MainFrame.frame.Navigate(new PsychoPage(psId));
+            }
+        }
+
+        private void RemovePatient(object sender, RoutedEventArgs e)
+        {
+            CheckBox cb = (CheckBox)sender;
+            int id = Convert.ToInt32(cb.Uid);
+            user = DB.Users.Where(x => x.User_id == id).FirstOrDefault();
+            if (user.Id_doctor == psId)
+            {
+                user.Id_doctor = null;
+                DB.SaveChanges();
+                MainFrame.frame.Navigate(new PsychoPage(psId));
+            }
+        }
+
+        private void FullnameLoad(object sender, RoutedEventArgs e)
+        {
+            TextBlock tb = (TextBlock)sender;
+            int id = Convert.ToInt32(tb.Uid);
+            tb.Text = DB.Users.Where(x => x.User_id == id).Select(x => x.Surname).FirstOrDefault() + " "
+                + DB.Users.Where(x => x.User_id == id).Select(x => x.Name).FirstOrDefault() + " "
+                + DB.Users.Where(x => x.User_id == id).Select(x => x.Patronymic).FirstOrDefault();
+        }
+
+        private void CheckBoxLoad(object sender, RoutedEventArgs e)
+        {
+            CheckBox cb = (CheckBox)sender;
+            int id = Convert.ToInt32(cb.Uid);
+
+            if (DB.Users.Where(x=>x.User_id == id).Select(x=>x.Id_doctor).FirstOrDefault() == psId)
+            {
+                cb.IsChecked = true;
+            }
+            else
+            {
+                cb.IsChecked = false;
+            }
         }
     }
 }

+ 2 - 1
Pages/PsychoPage.xaml.cs

@@ -37,7 +37,8 @@ namespace PsychoTest.Pages
 
         private void AddPatients(object sender, RoutedEventArgs e)
         {
-
+            Window wnd = new AddRemovePage(Pid);
+            wnd.ShowDialog();
         }
 
         private void FullnamePatient(object sender, RoutedEventArgs e)