Four push
This commit is contained in:
Binary file not shown.
@@ -9,6 +9,10 @@
|
|||||||
{
|
{
|
||||||
"AbsoluteMoniker": "D:0:0:{68BE38C1-9A3E-4D01-81ED-9DC821B2AE98}|PR14\\PR14.csproj|C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\pr14\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
"AbsoluteMoniker": "D:0:0:{68BE38C1-9A3E-4D01-81ED-9DC821B2AE98}|PR14\\PR14.csproj|C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\pr14\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||||
"RelativeMoniker": "D:0:0:{68BE38C1-9A3E-4D01-81ED-9DC821B2AE98}|PR14\\PR14.csproj|solutionrelative:pr14\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
"RelativeMoniker": "D:0:0:{68BE38C1-9A3E-4D01-81ED-9DC821B2AE98}|PR14\\PR14.csproj|solutionrelative:pr14\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"AbsoluteMoniker": "D:0:0:{68BE38C1-9A3E-4D01-81ED-9DC821B2AE98}|PR14\\PR14.csproj|c:\\users\\usersql\\source\\repos\\mdk0101\\pr14\\pr14\\models\\model1.edmx||{C99AEA30-8E36-4515-B76F-496F5A48A6AA}|",
|
||||||
|
"RelativeMoniker": "D:0:0:{68BE38C1-9A3E-4D01-81ED-9DC821B2AE98}|PR14\\PR14.csproj|solutionrelative:pr14\\models\\model1.edmx||{C99AEA30-8E36-4515-B76F-496F5A48A6AA}|"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"DocumentGroupContainers": [
|
"DocumentGroupContainers": [
|
||||||
@@ -18,7 +22,7 @@
|
|||||||
"DocumentGroups": [
|
"DocumentGroups": [
|
||||||
{
|
{
|
||||||
"DockedWidth": 200,
|
"DockedWidth": 200,
|
||||||
"SelectedChildIndex": 14,
|
"SelectedChildIndex": 16,
|
||||||
"Children": [
|
"Children": [
|
||||||
{
|
{
|
||||||
"$type": "Bookmark",
|
"$type": "Bookmark",
|
||||||
@@ -76,14 +80,30 @@
|
|||||||
"$type": "Bookmark",
|
"$type": "Bookmark",
|
||||||
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
|
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"$type": "Bookmark",
|
||||||
|
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Document",
|
||||||
|
"DocumentIndex": 2,
|
||||||
|
"Title": "Model1.edmx [Diagram1]",
|
||||||
|
"DocumentMoniker": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\Models\\Model1.edmx",
|
||||||
|
"RelativeDocumentMoniker": "PR14\\Models\\Model1.edmx",
|
||||||
|
"ToolTip": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\Models\\Model1.edmx [Diagram1]",
|
||||||
|
"RelativeToolTip": "PR14\\Models\\Model1.edmx [Diagram1]",
|
||||||
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001116|",
|
||||||
|
"WhenOpened": "2026-04-20T12:26:58.918Z",
|
||||||
|
"EditorCaption": " [Diagram1]"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 0,
|
"DocumentIndex": 0,
|
||||||
"Title": "MainWindow.xaml",
|
"Title": "MainWindow.xaml",
|
||||||
"DocumentMoniker": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\MainWindow.xaml",
|
"DocumentMoniker": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\MainWindow.xaml",
|
||||||
"RelativeDocumentMoniker": "PR14\\MainWindow.xaml",
|
"RelativeDocumentMoniker": "PR14\\MainWindow.xaml",
|
||||||
"ToolTip": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\MainWindow.xaml*",
|
"ToolTip": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\MainWindow.xaml",
|
||||||
"RelativeToolTip": "PR14\\MainWindow.xaml*",
|
"RelativeToolTip": "PR14\\MainWindow.xaml",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
|
||||||
"WhenOpened": "2026-04-20T10:44:32.389Z",
|
"WhenOpened": "2026-04-20T10:44:32.389Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
@@ -94,8 +114,9 @@
|
|||||||
"Title": "MainWindow.xaml.cs",
|
"Title": "MainWindow.xaml.cs",
|
||||||
"DocumentMoniker": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\MainWindow.xaml.cs",
|
"DocumentMoniker": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\MainWindow.xaml.cs",
|
||||||
"RelativeDocumentMoniker": "PR14\\MainWindow.xaml.cs",
|
"RelativeDocumentMoniker": "PR14\\MainWindow.xaml.cs",
|
||||||
"ToolTip": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\MainWindow.xaml.cs",
|
"ToolTip": "C:\\Users\\usersql\\Source\\Repos\\MDK0101\\PR14\\PR14\\MainWindow.xaml.cs*",
|
||||||
"RelativeToolTip": "PR14\\MainWindow.xaml.cs",
|
"RelativeToolTip": "PR14\\MainWindow.xaml.cs*",
|
||||||
|
"ViewState": "AQIAAFQAAAAAAAAAAAAgwG0AAAANAAAA",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2026-04-20T10:44:31.757Z",
|
"WhenOpened": "2026-04-20T10:44:31.757Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<configSections>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||||
</startup>
|
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
|
</configSections>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
<entityFramework>
|
||||||
|
<providers>
|
||||||
|
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||||
|
</providers>
|
||||||
|
</entityFramework>
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="DBPR14Entities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=PC-314-12;initial catalog=DBPR14;integrated security=True;trustservercertificate=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||||
|
</connectionStrings>
|
||||||
</configuration>
|
</configuration>
|
||||||
59
PR14/PR14/AppointmentWindow.xaml
Normal file
59
PR14/PR14/AppointmentWindow.xaml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<Window x:Class="PR14.AppointmentWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:PR14"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="AppointmentWindow" Height="450" Width="300">
|
||||||
|
<StackPanel Margin="20">
|
||||||
|
<TextBlock Text="Запись на прием" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Margin="0,0,0,20"/>
|
||||||
|
|
||||||
|
<TextBlock Text="Пациент:" Foreground="Gray"/>
|
||||||
|
<TextBox
|
||||||
|
x:Name="tbPatientName"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Margin="0,5,0,15"/>
|
||||||
|
|
||||||
|
<TextBlock Text="Специальность:"/>
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cbSpeciality"
|
||||||
|
DisplayMemberPath="name"
|
||||||
|
Margin="0,5,0,15"
|
||||||
|
SelectionChanged="cbSpeciality_SelectionChanged"/>
|
||||||
|
|
||||||
|
<TextBlock Text="Врач:"/>
|
||||||
|
<ComboBox x:Name="cbDoctor" Margin="0,5,0,15">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock>
|
||||||
|
<Run Text="{Binding last_name}"/>
|
||||||
|
<Run Text="{Binding first_name}"/>
|
||||||
|
<Run Text="{Binding middle_name}"/>
|
||||||
|
</TextBlock>
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<TextBlock Text="Дата:"/>
|
||||||
|
<DatePicker x:Name="dpDate" Margin="0,5,0,15"/>
|
||||||
|
|
||||||
|
<TextBlock Text="Время:"/>
|
||||||
|
<ComboBox x:Name="cbTime" Margin="0,5,0,25">
|
||||||
|
<ComboBoxItem Content="08:00"/>
|
||||||
|
<ComboBoxItem Content="09:00"/>
|
||||||
|
<ComboBoxItem Content="10:00"/>
|
||||||
|
<ComboBoxItem Content="11:00"/>
|
||||||
|
<ComboBoxItem Content="13:00"/>
|
||||||
|
<ComboBoxItem Content="14:00"/>
|
||||||
|
<ComboBoxItem Content="15:00"/>
|
||||||
|
<ComboBoxItem Content="16:00"/>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Content="Записать"
|
||||||
|
Click="BtnSave_Click"
|
||||||
|
Height="35"
|
||||||
|
FontWeight="Bold"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
||||||
99
PR14/PR14/AppointmentWindow.xaml.cs
Normal file
99
PR14/PR14/AppointmentWindow.xaml.cs
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
using PR14.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using static System.Data.Entity.Infrastructure.Design.Executor;
|
||||||
|
|
||||||
|
namespace PR14
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Логика взаимодействия для AppointmentWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class AppointmentWindow : Window
|
||||||
|
{
|
||||||
|
DBPR14Entities db = new DBPR14Entities();
|
||||||
|
Patient currentPatient;
|
||||||
|
public AppointmentWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
public AppointmentWindow(Patient patient)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
currentPatient = patient;
|
||||||
|
tbPatientName.Text = $"{patient.middle_name} {patient.first_name[0]}.{patient.last_name[0]}.";
|
||||||
|
|
||||||
|
// Загружаем специальности в ComboBox
|
||||||
|
cbSpeciality.ItemsSource = db.Specialities.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Фильтрация врачей при выборе специальности
|
||||||
|
private void cbSpeciality_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (cbSpeciality.SelectedItem is Speciality spec)
|
||||||
|
{
|
||||||
|
// Показываем только врачей этой специальности
|
||||||
|
cbDoctor.ItemsSource = db.Doctors.Where(d => d.speciality_id == spec.id).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BtnSaveAppointment_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var record = new Record // Ваша таблица записей
|
||||||
|
{
|
||||||
|
id_patient = currentPatient.id_patient,
|
||||||
|
id_doctor = (cbDoctor.SelectedItem as Doctor).id,
|
||||||
|
appointment_date = dpDate.SelectedDate.Value,
|
||||||
|
appointment_time = Convert.ToDateTime(cbTime.Text)
|
||||||
|
};
|
||||||
|
|
||||||
|
db.Records.Add(record);
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
MessageBox.Show("Запись успешно создана!");
|
||||||
|
this.Close(); // Возврат на главную форму
|
||||||
|
}
|
||||||
|
catch (Exception ex) { MessageBox.Show("Ошибка: " + ex.Message); }
|
||||||
|
}
|
||||||
|
private void BtnSave_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (cbDoctor.SelectedItem == null || dpDate.SelectedDate == null || cbTime.SelectedItem == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Заполните все поля записи!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var newAppointment = new Record
|
||||||
|
{
|
||||||
|
id_patient = currentPatient.id_patient,
|
||||||
|
id_doctor = (cbDoctor.SelectedItem as Doctor).id_doctor,
|
||||||
|
appointment_date = dpDate.SelectedDate.Value,
|
||||||
|
appointment_time = TimeSpan.Parse(cbTime.Text)
|
||||||
|
};
|
||||||
|
|
||||||
|
db.Records.Add(newAppointment);
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
MessageBox.Show("Пациент успешно записан!");
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Ошибка записи: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,38 +18,45 @@
|
|||||||
Text="Список пациентов:"
|
Text="Список пациентов:"
|
||||||
Margin="10,10,10,0"
|
Margin="10,10,10,0"
|
||||||
/>
|
/>
|
||||||
<ListView
|
<ListView x:Name="lvPatients" Margin="10" Height="320" SelectionChanged="lvPatients_SelectionChanged">
|
||||||
Margin="10"
|
<ListView.View>
|
||||||
Height="320"
|
<GridView>
|
||||||
>
|
<GridViewColumn Header="Фамилия" DisplayMemberBinding="{Binding middle_name}" Width="100"/>
|
||||||
|
<GridViewColumn Header="Имя" DisplayMemberBinding="{Binding first_name}" Width="100"/>
|
||||||
|
<GridViewColumn Header="Полис" DisplayMemberBinding="{Binding policy_number}" Width="120"/>
|
||||||
|
</GridView>
|
||||||
|
</ListView.View>
|
||||||
</ListView>
|
</ListView>
|
||||||
<Button Content="Просмотреть записи" Margin="10" Height="30"/>
|
<Button Content="Просмотреть записи" Margin="10" Height="30"/>
|
||||||
<Button Content="Записать" Margin="10" Height="30"/>
|
<Button Content="Записать" Margin="10" Height="30"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Column = "1">
|
<StackPanel Grid.Column="1">
|
||||||
<TextBlock Text="Фамилия:" Name="tbSurname" Margin="10"/>
|
<TextBlock Text="Фамилия:" Margin="10"/>
|
||||||
<TextBox Margin="10,0,10,0"/>
|
<TextBox x:Name="tbSurname" Margin="10,0,10,0"/>
|
||||||
<TextBlock Text="Имя:" Name="tbName" Margin="10"/>
|
|
||||||
<TextBox Margin="10,0,10,0"/>
|
<TextBlock Text="Имя:" Margin="10"/>
|
||||||
<TextBlock Text="Отчество:" Name="tbPatronymic" Margin="10"/>
|
<TextBox x:Name="tbName" Margin="10,0,10,0"/>
|
||||||
<TextBox Margin="10,0,10,0"/>
|
|
||||||
|
<TextBlock Text="Отчество:" Margin="10"/>
|
||||||
|
<TextBox x:Name="tbPatronymic" Margin="10,0,10,0"/>
|
||||||
|
|
||||||
<TextBlock Text="Пол:" Margin="10,0,0,0"/>
|
<TextBlock Text="Пол:" Margin="10,0,0,0"/>
|
||||||
<StackPanel Orientation="Horizontal" Margin="10">
|
<StackPanel Orientation="Horizontal" Margin="10">
|
||||||
<RadioButton GroupName="rbgRadios" Content="М" Margin="0,0,20,0"/>
|
<RadioButton x:Name="rbMale" GroupName="Radios" Content="М" IsChecked="True" Margin="0,0,20,0"/>
|
||||||
<RadioButton GroupName="Radios" Content="Ж"/>
|
<RadioButton x:Name="rbFemale" GroupName="Radios" Content="Ж"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<TextBlock Text="Дата рождения:" Margin="10,0,0,0"/>
|
<TextBlock Text="Дата рождения:" Margin="10,0,0,0"/>
|
||||||
<DatePicker Name="dpBirthday" Margin="10"/>
|
<DatePicker x:Name="dpBirthday" Margin="10"/>
|
||||||
|
|
||||||
<TextBlock Name="tbAdress" Text="Фактический адрес:" Margin="10"/>
|
<TextBlock Text="Фактический адрес:" Margin="10"/>
|
||||||
<TextBox Margin="10,0,10,0"/>
|
<TextBox x:Name="tbAddress" Margin="10,0,10,0"/>
|
||||||
|
|
||||||
<TextBlock Name="tbPolis" Text="Полис:" Margin="10"/>
|
<TextBlock Text="Полис:" Margin="10"/>
|
||||||
<TextBox Margin="10,0,10,0"/>
|
<TextBox x:Name="tbPolis" Margin="10,0,10,0" MaxLength="16"/>
|
||||||
|
|
||||||
<TextBlock Name="tbPhone" Text="Телефон:" Margin="10"/>
|
<TextBlock Text="Телефон:" Margin="10"/>
|
||||||
<TextBox Margin="10,0,10,0"/>
|
<TextBox x:Name="tbPhone" Margin="10,0,10,0" MaxLength="11"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Column = "2">
|
<StackPanel Grid.Column = "2">
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -59,7 +66,7 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Grid.Row="0" Height="370"/>
|
<StackPanel Grid.Row="0" Height="370"/>
|
||||||
<StackPanel Grid.Row="1">
|
<StackPanel Grid.Row="1">
|
||||||
<Button Content="Добавить" VerticalAlignment="Bottom" Margin="10"/>
|
<Button Content="Добавить" VerticalAlignment="Bottom" Margin="10" Height="30" Click="BtnAdd_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using PR14.Models;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -20,9 +21,123 @@ namespace PR14
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
DBPR14Entities db = new DBPR14Entities();
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void BtnAdd_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(tbSurname.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(tbName.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(tbAddress.Text) ||
|
||||||
|
dpBirthday.SelectedDate == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Заполните все обязательные поля!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dpBirthday.SelectedDate >= DateTime.Now)
|
||||||
|
{
|
||||||
|
throw new Exception("Дата рождения не может быть в будущем!");
|
||||||
|
}
|
||||||
|
|
||||||
|
string polis = tbPolis.Text.Trim();
|
||||||
|
if (polis.Length != 16 || !polis.All(char.IsDigit))
|
||||||
|
{
|
||||||
|
throw new Exception("Полис должен содержать 16 цифр!");
|
||||||
|
}
|
||||||
|
|
||||||
|
string phone = tbPhone.Text.Trim();
|
||||||
|
if (phone.Length != 11 || !phone.All(char.IsDigit))
|
||||||
|
{
|
||||||
|
throw new Exception("Номер телефона должен содержать 11 цифр!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (db.Patients.Any(p => p.policy_number == polis))
|
||||||
|
{
|
||||||
|
throw new Exception("Пациент с таким номером полиса уже существует в базе!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (db.Patients.Any(p => p.phone_number == phone))
|
||||||
|
{
|
||||||
|
throw new Exception("Пациент с таким номером телефона уже существует в базе!");
|
||||||
|
}
|
||||||
|
var newPatient = new Patient
|
||||||
|
{
|
||||||
|
middle_name = tbSurname.Text,
|
||||||
|
first_name = tbName.Text,
|
||||||
|
last_name = tbPatronymic.Text,
|
||||||
|
gender = rbMale.IsChecked == true ? "М" : "Ж",
|
||||||
|
birth_date = dpBirthday.SelectedDate.Value,
|
||||||
|
address = tbAddress.Text,
|
||||||
|
policy_number = polis,
|
||||||
|
phone_number = phone
|
||||||
|
};
|
||||||
|
|
||||||
|
db.Patients.Add(newPatient);
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
MessageBox.Show("Пациент успешно добавлен!");
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
|
||||||
|
{
|
||||||
|
string fullError = "Ошибка валидации данных:\n";
|
||||||
|
foreach (var validationErrors in dbEx.EntityValidationErrors)
|
||||||
|
{
|
||||||
|
foreach (var validationError in validationErrors.ValidationErrors)
|
||||||
|
{
|
||||||
|
fullError += $"- Поле: {validationError.PropertyName}, Ошибка: {validationError.ErrorMessage}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MessageBox.Show(fullError, "Ошибка модели");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
lvPatients.ItemsSource = db.Patients.ToList();
|
||||||
|
}
|
||||||
|
private void lvPatients_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (lvPatients.SelectedItem is Patient selected)
|
||||||
|
{
|
||||||
|
tbSurname.Text = selected.middle_name;
|
||||||
|
tbName.Text = selected.first_name;
|
||||||
|
tbPatronymic.Text = selected.last_name;
|
||||||
|
dpBirthday.SelectedDate = selected.birth_date;
|
||||||
|
tbAddress.Text = selected.address;
|
||||||
|
tbPolis.Text = selected.policy_number;
|
||||||
|
tbPhone.Text = selected.phone_number;
|
||||||
|
|
||||||
|
if (selected.gender == "М") rbMale.IsChecked = true;
|
||||||
|
else rbFemale.IsChecked = true;
|
||||||
|
|
||||||
|
tbSurname.IsReadOnly = true;
|
||||||
|
tbName.IsReadOnly = true;
|
||||||
|
tbPatronymic.IsReadOnly = true;
|
||||||
|
tbPolis.IsReadOnly = true;
|
||||||
|
dpBirthday.IsEnabled = false;
|
||||||
|
|
||||||
|
tbAddress.IsReadOnly = false;
|
||||||
|
tbPhone.IsReadOnly = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void BtnRecord_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (lvPatients.SelectedItem is Patient selected)
|
||||||
|
{
|
||||||
|
// Передаем выбранного пациента в конструктор нового окна
|
||||||
|
AppointmentWindow appointWin = new AppointmentWindow(selected);
|
||||||
|
appointWin.ShowDialog();
|
||||||
|
}
|
||||||
|
else { MessageBox.Show("Выберите пациента!"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
PR14/PR14/Models/Doctor.cs
Normal file
33
PR14/PR14/Models/Doctor.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан по шаблону.
|
||||||
|
//
|
||||||
|
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||||
|
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace PR14.Models
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class Doctor
|
||||||
|
{
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||||
|
public Doctor()
|
||||||
|
{
|
||||||
|
this.Records = new HashSet<Record>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int id_doctor { get; set; }
|
||||||
|
public string last_name { get; set; }
|
||||||
|
public string first_name { get; set; }
|
||||||
|
public string middle_name { get; set; }
|
||||||
|
public int id_speciality { get; set; }
|
||||||
|
|
||||||
|
public virtual Speciality Speciality { get; set; }
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||||
|
public virtual ICollection<Record> Records { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
33
PR14/PR14/Models/Model1.Context.cs
Normal file
33
PR14/PR14/Models/Model1.Context.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан по шаблону.
|
||||||
|
//
|
||||||
|
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||||
|
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace PR14.Models
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Data.Entity;
|
||||||
|
using System.Data.Entity.Infrastructure;
|
||||||
|
|
||||||
|
public partial class DBPR14Entities : DbContext
|
||||||
|
{
|
||||||
|
public DBPR14Entities()
|
||||||
|
: base("name=DBPR14Entities")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
throw new UnintentionalCodeFirstException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual DbSet<Doctor> Doctors { get; set; }
|
||||||
|
public virtual DbSet<Patient> Patients { get; set; }
|
||||||
|
public virtual DbSet<Record> Records { get; set; }
|
||||||
|
public virtual DbSet<Speciality> Specialities { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
636
PR14/PR14/Models/Model1.Context.tt
Normal file
636
PR14/PR14/Models/Model1.Context.tt
Normal file
@@ -0,0 +1,636 @@
|
|||||||
|
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||||
|
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||||
|
output extension=".cs"#><#
|
||||||
|
|
||||||
|
const string inputFile = @"Model1.edmx";
|
||||||
|
var textTransform = DynamicTextTransformation.Create(this);
|
||||||
|
var code = new CodeGenerationTools(this);
|
||||||
|
var ef = new MetadataTools(this);
|
||||||
|
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||||
|
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
|
||||||
|
var itemCollection = loader.CreateEdmItemCollection(inputFile);
|
||||||
|
var modelNamespace = loader.GetModelNamespace(inputFile);
|
||||||
|
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||||
|
|
||||||
|
var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
|
||||||
|
if (container == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||||
|
//
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
<#
|
||||||
|
|
||||||
|
var codeNamespace = code.VsNamespaceSuggestion();
|
||||||
|
if (!String.IsNullOrEmpty(codeNamespace))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
PushIndent(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
#>
|
||||||
|
using System;
|
||||||
|
using System.Data.Entity;
|
||||||
|
using System.Data.Entity.Infrastructure;
|
||||||
|
<#
|
||||||
|
if (container.FunctionImports.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
using System.Data.Entity.Core.Objects;
|
||||||
|
using System.Linq;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
|
||||||
|
{
|
||||||
|
public <#=code.Escape(container)#>()
|
||||||
|
: base("name=<#=container.Name#>")
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
if (!loader.IsLazyLoadingEnabled(container))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.Configuration.LazyLoadingEnabled = false;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||||
|
{
|
||||||
|
// Note: the DbSet members are defined below such that the getter and
|
||||||
|
// setter always have the same accessibility as the DbSet definition
|
||||||
|
if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.DbSetInitializer(entitySet)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
throw new UnintentionalCodeFirstException();
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.DbSet(entitySet)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var edmFunction in container.FunctionImports)
|
||||||
|
{
|
||||||
|
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(codeNamespace))
|
||||||
|
{
|
||||||
|
PopIndent();
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
<#+
|
||||||
|
|
||||||
|
private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
if (typeMapper.IsComposable(edmFunction))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
[DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
|
||||||
|
<#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
|
||||||
|
{
|
||||||
|
<#+
|
||||||
|
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
|
||||||
|
}
|
||||||
|
<#+
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
|
||||||
|
{
|
||||||
|
<#+
|
||||||
|
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
|
||||||
|
}
|
||||||
|
<#+
|
||||||
|
if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
|
||||||
|
{
|
||||||
|
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
var <#=name#> = <#=isNotNull#> ?
|
||||||
|
<#=notNullInit#> :
|
||||||
|
<#=nullInit#>;
|
||||||
|
|
||||||
|
<#+
|
||||||
|
}
|
||||||
|
|
||||||
|
public const string TemplateId = "CSharp_DbContext_Context_EF6";
|
||||||
|
|
||||||
|
public class CodeStringGenerator
|
||||||
|
{
|
||||||
|
private readonly CodeGenerationTools _code;
|
||||||
|
private readonly TypeMapper _typeMapper;
|
||||||
|
private readonly MetadataTools _ef;
|
||||||
|
|
||||||
|
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(code, "code");
|
||||||
|
ArgumentNotNull(typeMapper, "typeMapper");
|
||||||
|
ArgumentNotNull(ef, "ef");
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_typeMapper = typeMapper;
|
||||||
|
_ef = ef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Property(EdmProperty edmProperty)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||||
|
Accessibility.ForProperty(edmProperty),
|
||||||
|
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||||
|
_code.Escape(edmProperty),
|
||||||
|
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||||
|
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NavigationProperty(NavigationProperty navProp)
|
||||||
|
{
|
||||||
|
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||||
|
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||||
|
_code.Escape(navProp),
|
||||||
|
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||||
|
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AccessibilityAndVirtual(string accessibility)
|
||||||
|
{
|
||||||
|
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EntityClassOpening(EntityType entity)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1}partial class {2}{3}",
|
||||||
|
Accessibility.ForType(entity),
|
||||||
|
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||||
|
_code.Escape(entity),
|
||||||
|
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EnumOpening(SimpleType enumType)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} enum {1} : {2}",
|
||||||
|
Accessibility.ForType(enumType),
|
||||||
|
_code.Escape(enumType),
|
||||||
|
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||||
|
{
|
||||||
|
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||||
|
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||||
|
{
|
||||||
|
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||||
|
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||||
|
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||||
|
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} IQueryable<{1}> {2}({3})",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||||
|
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||||
|
_code.Escape(edmFunction),
|
||||||
|
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||||
|
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||||
|
edmFunction.NamespaceName,
|
||||||
|
edmFunction.Name,
|
||||||
|
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||||
|
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||||
|
|
||||||
|
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||||
|
if (includeMergeOption)
|
||||||
|
{
|
||||||
|
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2}({3})",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||||
|
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||||
|
_code.Escape(edmFunction),
|
||||||
|
paramList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||||
|
|
||||||
|
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||||
|
if (includeMergeOption)
|
||||||
|
{
|
||||||
|
callParams = ", mergeOption" + callParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||||
|
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||||
|
edmFunction.Name,
|
||||||
|
callParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DbSet(EntitySet entitySet)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||||
|
Accessibility.ForReadOnlyProperty(entitySet),
|
||||||
|
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||||
|
_code.Escape(entitySet));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DbSetInitializer(EntitySet entitySet)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} = Set<{1}>();",
|
||||||
|
_code.Escape(entitySet),
|
||||||
|
_typeMapper.GetTypeName(entitySet.ElementType));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||||
|
{
|
||||||
|
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||||
|
? string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0}using System;{1}" +
|
||||||
|
"{2}",
|
||||||
|
inHeader ? Environment.NewLine : "",
|
||||||
|
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||||
|
inHeader ? "" : Environment.NewLine)
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TypeMapper
|
||||||
|
{
|
||||||
|
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||||
|
|
||||||
|
private readonly System.Collections.IList _errors;
|
||||||
|
private readonly CodeGenerationTools _code;
|
||||||
|
private readonly MetadataTools _ef;
|
||||||
|
|
||||||
|
public static string FixNamespaces(string typeName)
|
||||||
|
{
|
||||||
|
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(code, "code");
|
||||||
|
ArgumentNotNull(ef, "ef");
|
||||||
|
ArgumentNotNull(errors, "errors");
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_ef = ef;
|
||||||
|
_errors = errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(TypeUsage typeUsage)
|
||||||
|
{
|
||||||
|
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType)
|
||||||
|
{
|
||||||
|
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||||
|
{
|
||||||
|
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||||
|
{
|
||||||
|
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||||
|
{
|
||||||
|
if (edmType == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var collectionType = edmType as CollectionType;
|
||||||
|
if (collectionType != null)
|
||||||
|
{
|
||||||
|
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||||
|
}
|
||||||
|
|
||||||
|
var typeName = _code.Escape(edmType.MetadataProperties
|
||||||
|
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||||
|
.Select(p => (string)p.Value)
|
||||||
|
.FirstOrDefault())
|
||||||
|
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||||
|
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||||
|
_code.Escape(edmType));
|
||||||
|
|
||||||
|
if (edmType is StructuralType)
|
||||||
|
{
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edmType is SimpleType)
|
||||||
|
{
|
||||||
|
var clrType = UnderlyingClrType(edmType);
|
||||||
|
if (!IsEnumType(edmType))
|
||||||
|
{
|
||||||
|
typeName = _code.Escape(clrType);
|
||||||
|
}
|
||||||
|
|
||||||
|
typeName = FixNamespaces(typeName);
|
||||||
|
|
||||||
|
return clrType.IsValueType && isNullable == true ?
|
||||||
|
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||||
|
typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("edmType");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type UnderlyingClrType(EdmType edmType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmType, "edmType");
|
||||||
|
|
||||||
|
var primitiveType = edmType as PrimitiveType;
|
||||||
|
if (primitiveType != null)
|
||||||
|
{
|
||||||
|
return primitiveType.ClrEquivalentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsEnumType(edmType))
|
||||||
|
{
|
||||||
|
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumMember, "enumMember");
|
||||||
|
|
||||||
|
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||||
|
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetEnumMemberName(MetadataItem enumMember)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumMember, "enumMember");
|
||||||
|
|
||||||
|
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||||
|
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||||
|
return membersProperty != null
|
||||||
|
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||||
|
: Enumerable.Empty<MetadataItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EnumIsFlags(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||||
|
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEnumType(GlobalItem edmType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmType, "edmType");
|
||||||
|
|
||||||
|
return edmType.GetType().Name == "EnumType";
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CreateLiteral(object value)
|
||||||
|
{
|
||||||
|
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||||
|
{
|
||||||
|
return _code.CreateLiteral(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(types, "types");
|
||||||
|
ArgumentNotNull(sourceFile, "sourceFile");
|
||||||
|
|
||||||
|
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||||
|
if (types.Any(item => !hash.Add(item)))
|
||||||
|
{
|
||||||
|
_errors.Add(
|
||||||
|
new CompilerError(sourceFile, -1, -1, "6023",
|
||||||
|
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||||
|
{
|
||||||
|
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||||
|
.Where(e => IsEnumType(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||||
|
{
|
||||||
|
return itemCollection
|
||||||
|
.OfType<T>()
|
||||||
|
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||||
|
.OrderBy(i => i.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||||
|
{
|
||||||
|
return itemCollection
|
||||||
|
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||||
|
.Select(g => GetGlobalItemName(g));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetGlobalItemName(GlobalItem item)
|
||||||
|
{
|
||||||
|
if (item is EdmType)
|
||||||
|
{
|
||||||
|
return ((EdmType)item).Name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ((EntityContainer)item).Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmFunction, "edmFunction");
|
||||||
|
|
||||||
|
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||||
|
return returnParamsProperty == null
|
||||||
|
? edmFunction.ReturnParameter
|
||||||
|
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsComposable(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmFunction, "edmFunction");
|
||||||
|
|
||||||
|
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||||
|
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
var returnParam = GetReturnParameter(edmFunction);
|
||||||
|
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var returnType = GetReturnType(edmFunction);
|
||||||
|
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||||
|
{
|
||||||
|
if (arg == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
10
PR14/PR14/Models/Model1.Designer.cs
generated
Normal file
10
PR14/PR14/Models/Model1.Designer.cs
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// Создание кода T4 для модели "C:\Users\usersql\Source\Repos\MDK0101\PR14\PR14\Models\Model1.edmx" включено.
|
||||||
|
// Чтобы включить формирование кода прежних версий, измените значение свойства "Стратегия создания кода" конструктора
|
||||||
|
// на "Legacy ObjectContext". Это свойство доступно в окне "Свойства", если модель
|
||||||
|
// открыта в конструкторе.
|
||||||
|
|
||||||
|
// Если не сформированы контекст и классы сущности, возможная причина в том, что вы создали пустую модель, но
|
||||||
|
// еще не выбрали версию Entity Framework для использования. Чтобы сформировать класс контекста и классы сущностей
|
||||||
|
// для своей модели, откройте модель в конструкторе, щелкните правой кнопкой область конструктора и
|
||||||
|
// выберите "Обновить модель из базы данных", "Сформировать базу данных из модели" или "Добавить элемент формирования
|
||||||
|
// кода...".
|
||||||
9
PR14/PR14/Models/Model1.cs
Normal file
9
PR14/PR14/Models/Model1.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан по шаблону.
|
||||||
|
//
|
||||||
|
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||||
|
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
282
PR14/PR14/Models/Model1.edmx
Normal file
282
PR14/PR14/Models/Model1.edmx
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||||
|
<!-- EF Runtime content -->
|
||||||
|
<edmx:Runtime>
|
||||||
|
<!-- SSDL content -->
|
||||||
|
<edmx:StorageModels>
|
||||||
|
<Schema Namespace="Хранилище DBPR14Model" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||||
|
<EntityType Name="Doctor">
|
||||||
|
<Key>
|
||||||
|
<PropertyRef Name="id_doctor" />
|
||||||
|
</Key>
|
||||||
|
<Property Name="id_doctor" Type="int" Nullable="false" />
|
||||||
|
<Property Name="last_name" Type="nvarchar" MaxLength="100" Nullable="false" />
|
||||||
|
<Property Name="first_name" Type="nvarchar" MaxLength="100" Nullable="false" />
|
||||||
|
<Property Name="middle_name" Type="nvarchar" MaxLength="100" />
|
||||||
|
<Property Name="id_speciality" Type="int" Nullable="false" />
|
||||||
|
</EntityType>
|
||||||
|
<EntityType Name="Patient">
|
||||||
|
<Key>
|
||||||
|
<PropertyRef Name="id_patient" />
|
||||||
|
</Key>
|
||||||
|
<Property Name="id_patient" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||||
|
<Property Name="last_name" Type="nvarchar" MaxLength="100" Nullable="false" />
|
||||||
|
<Property Name="first_name" Type="nvarchar" MaxLength="100" Nullable="false" />
|
||||||
|
<Property Name="middle_name" Type="nvarchar" MaxLength="100" />
|
||||||
|
<Property Name="gender" Type="nchar" MaxLength="10" />
|
||||||
|
<Property Name="birth_date" Type="date" />
|
||||||
|
<Property Name="address" Type="nvarchar" MaxLength="255" />
|
||||||
|
<Property Name="policy_number" Type="nvarchar" MaxLength="20" />
|
||||||
|
<Property Name="phone_number" Type="nvarchar" MaxLength="20" />
|
||||||
|
</EntityType>
|
||||||
|
<EntityType Name="Record">
|
||||||
|
<Key>
|
||||||
|
<PropertyRef Name="id_appointment" />
|
||||||
|
</Key>
|
||||||
|
<Property Name="id_appointment" Type="int" Nullable="false" />
|
||||||
|
<Property Name="id_patient" Type="int" Nullable="false" />
|
||||||
|
<Property Name="id_doctor" Type="int" Nullable="false" />
|
||||||
|
<Property Name="appointment_date" Type="date" Nullable="false" />
|
||||||
|
<Property Name="appointment_time" Type="time" Precision="7" Nullable="false" />
|
||||||
|
</EntityType>
|
||||||
|
<EntityType Name="Speciality">
|
||||||
|
<Key>
|
||||||
|
<PropertyRef Name="id_speciality" />
|
||||||
|
</Key>
|
||||||
|
<Property Name="id_speciality" Type="int" Nullable="false" />
|
||||||
|
<Property Name="name_speciality" Type="nvarchar" MaxLength="100" Nullable="false" />
|
||||||
|
</EntityType>
|
||||||
|
<Association Name="FK__Doctor__id_speci__3E52440B">
|
||||||
|
<End Role="Speciality" Type="Self.Speciality" Multiplicity="1" />
|
||||||
|
<End Role="Doctor" Type="Self.Doctor" Multiplicity="*" />
|
||||||
|
<ReferentialConstraint>
|
||||||
|
<Principal Role="Speciality">
|
||||||
|
<PropertyRef Name="id_speciality" />
|
||||||
|
</Principal>
|
||||||
|
<Dependent Role="Doctor">
|
||||||
|
<PropertyRef Name="id_speciality" />
|
||||||
|
</Dependent>
|
||||||
|
</ReferentialConstraint>
|
||||||
|
</Association>
|
||||||
|
<Association Name="FK__Record__id_docto__3F466844">
|
||||||
|
<End Role="Doctor" Type="Self.Doctor" Multiplicity="1" />
|
||||||
|
<End Role="Record" Type="Self.Record" Multiplicity="*" />
|
||||||
|
<ReferentialConstraint>
|
||||||
|
<Principal Role="Doctor">
|
||||||
|
<PropertyRef Name="id_doctor" />
|
||||||
|
</Principal>
|
||||||
|
<Dependent Role="Record">
|
||||||
|
<PropertyRef Name="id_doctor" />
|
||||||
|
</Dependent>
|
||||||
|
</ReferentialConstraint>
|
||||||
|
</Association>
|
||||||
|
<Association Name="FK__Record__id_patie__403A8C7D">
|
||||||
|
<End Role="Patient" Type="Self.Patient" Multiplicity="1" />
|
||||||
|
<End Role="Record" Type="Self.Record" Multiplicity="*" />
|
||||||
|
<ReferentialConstraint>
|
||||||
|
<Principal Role="Patient">
|
||||||
|
<PropertyRef Name="id_patient" />
|
||||||
|
</Principal>
|
||||||
|
<Dependent Role="Record">
|
||||||
|
<PropertyRef Name="id_patient" />
|
||||||
|
</Dependent>
|
||||||
|
</ReferentialConstraint>
|
||||||
|
</Association>
|
||||||
|
<EntityContainer Name="Хранилище DBPR14ModelContainer">
|
||||||
|
<EntitySet Name="Doctor" EntityType="Self.Doctor" Schema="dbo" store:Type="Tables" />
|
||||||
|
<EntitySet Name="Patient" EntityType="Self.Patient" Schema="dbo" store:Type="Tables" />
|
||||||
|
<EntitySet Name="Record" EntityType="Self.Record" Schema="dbo" store:Type="Tables" />
|
||||||
|
<EntitySet Name="Speciality" EntityType="Self.Speciality" Schema="dbo" store:Type="Tables" />
|
||||||
|
<AssociationSet Name="FK__Doctor__id_speci__3E52440B" Association="Self.FK__Doctor__id_speci__3E52440B">
|
||||||
|
<End Role="Speciality" EntitySet="Speciality" />
|
||||||
|
<End Role="Doctor" EntitySet="Doctor" />
|
||||||
|
</AssociationSet>
|
||||||
|
<AssociationSet Name="FK__Record__id_docto__3F466844" Association="Self.FK__Record__id_docto__3F466844">
|
||||||
|
<End Role="Doctor" EntitySet="Doctor" />
|
||||||
|
<End Role="Record" EntitySet="Record" />
|
||||||
|
</AssociationSet>
|
||||||
|
<AssociationSet Name="FK__Record__id_patie__403A8C7D" Association="Self.FK__Record__id_patie__403A8C7D">
|
||||||
|
<End Role="Patient" EntitySet="Patient" />
|
||||||
|
<End Role="Record" EntitySet="Record" />
|
||||||
|
</AssociationSet>
|
||||||
|
</EntityContainer>
|
||||||
|
</Schema></edmx:StorageModels>
|
||||||
|
<!-- CSDL content -->
|
||||||
|
<edmx:ConceptualModels>
|
||||||
|
<Schema Namespace="DBPR14Model" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
|
||||||
|
<EntityType Name="Doctor">
|
||||||
|
<Key>
|
||||||
|
<PropertyRef Name="id_doctor" />
|
||||||
|
</Key>
|
||||||
|
<Property Name="id_doctor" Type="Int32" Nullable="false" />
|
||||||
|
<Property Name="last_name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" Nullable="false" />
|
||||||
|
<Property Name="first_name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" Nullable="false" />
|
||||||
|
<Property Name="middle_name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||||
|
<Property Name="id_speciality" Type="Int32" Nullable="false" />
|
||||||
|
<NavigationProperty Name="Speciality" Relationship="Self.FK__Doctor__id_speci__3E52440B" FromRole="Doctor" ToRole="Speciality" />
|
||||||
|
<NavigationProperty Name="Records" Relationship="Self.FK__Record__id_docto__3F466844" FromRole="Doctor" ToRole="Record" />
|
||||||
|
</EntityType>
|
||||||
|
<EntityType Name="Patient">
|
||||||
|
<Key>
|
||||||
|
<PropertyRef Name="id_patient" />
|
||||||
|
</Key>
|
||||||
|
<Property Name="id_patient" Type="Int32" Nullable="false" />
|
||||||
|
<Property Name="last_name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" Nullable="false" />
|
||||||
|
<Property Name="first_name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" Nullable="false" />
|
||||||
|
<Property Name="middle_name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||||
|
<Property Name="gender" Type="String" MaxLength="10" FixedLength="true" Unicode="true" />
|
||||||
|
<Property Name="birth_date" Type="DateTime" Precision="0" />
|
||||||
|
<Property Name="address" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||||
|
<Property Name="policy_number" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
|
||||||
|
<Property Name="phone_number" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
|
||||||
|
<NavigationProperty Name="Records" Relationship="Self.FK__Record__id_patie__403A8C7D" FromRole="Patient" ToRole="Record" />
|
||||||
|
</EntityType>
|
||||||
|
<EntityType Name="Record">
|
||||||
|
<Key>
|
||||||
|
<PropertyRef Name="id_appointment" />
|
||||||
|
</Key>
|
||||||
|
<Property Name="id_appointment" Type="Int32" Nullable="false" />
|
||||||
|
<Property Name="id_patient" Type="Int32" Nullable="false" />
|
||||||
|
<Property Name="id_doctor" Type="Int32" Nullable="false" />
|
||||||
|
<Property Name="appointment_date" Type="DateTime" Nullable="false" Precision="0" />
|
||||||
|
<Property Name="appointment_time" Type="Time" Nullable="false" Precision="7" />
|
||||||
|
<NavigationProperty Name="Doctor" Relationship="Self.FK__Record__id_docto__3F466844" FromRole="Record" ToRole="Doctor" />
|
||||||
|
<NavigationProperty Name="Patient" Relationship="Self.FK__Record__id_patie__403A8C7D" FromRole="Record" ToRole="Patient" />
|
||||||
|
</EntityType>
|
||||||
|
<EntityType Name="Speciality">
|
||||||
|
<Key>
|
||||||
|
<PropertyRef Name="id_speciality" />
|
||||||
|
</Key>
|
||||||
|
<Property Name="id_speciality" Type="Int32" Nullable="false" />
|
||||||
|
<Property Name="name_speciality" Type="String" MaxLength="100" FixedLength="false" Unicode="true" Nullable="false" />
|
||||||
|
<NavigationProperty Name="Doctors" Relationship="Self.FK__Doctor__id_speci__3E52440B" FromRole="Speciality" ToRole="Doctor" />
|
||||||
|
</EntityType>
|
||||||
|
<Association Name="FK__Doctor__id_speci__3E52440B">
|
||||||
|
<End Role="Speciality" Type="Self.Speciality" Multiplicity="1" />
|
||||||
|
<End Role="Doctor" Type="Self.Doctor" Multiplicity="*" />
|
||||||
|
<ReferentialConstraint>
|
||||||
|
<Principal Role="Speciality">
|
||||||
|
<PropertyRef Name="id_speciality" />
|
||||||
|
</Principal>
|
||||||
|
<Dependent Role="Doctor">
|
||||||
|
<PropertyRef Name="id_speciality" />
|
||||||
|
</Dependent>
|
||||||
|
</ReferentialConstraint>
|
||||||
|
</Association>
|
||||||
|
<Association Name="FK__Record__id_docto__3F466844">
|
||||||
|
<End Role="Doctor" Type="Self.Doctor" Multiplicity="1" />
|
||||||
|
<End Role="Record" Type="Self.Record" Multiplicity="*" />
|
||||||
|
<ReferentialConstraint>
|
||||||
|
<Principal Role="Doctor">
|
||||||
|
<PropertyRef Name="id_doctor" />
|
||||||
|
</Principal>
|
||||||
|
<Dependent Role="Record">
|
||||||
|
<PropertyRef Name="id_doctor" />
|
||||||
|
</Dependent>
|
||||||
|
</ReferentialConstraint>
|
||||||
|
</Association>
|
||||||
|
<Association Name="FK__Record__id_patie__403A8C7D">
|
||||||
|
<End Role="Patient" Type="Self.Patient" Multiplicity="1" />
|
||||||
|
<End Role="Record" Type="Self.Record" Multiplicity="*" />
|
||||||
|
<ReferentialConstraint>
|
||||||
|
<Principal Role="Patient">
|
||||||
|
<PropertyRef Name="id_patient" />
|
||||||
|
</Principal>
|
||||||
|
<Dependent Role="Record">
|
||||||
|
<PropertyRef Name="id_patient" />
|
||||||
|
</Dependent>
|
||||||
|
</ReferentialConstraint>
|
||||||
|
</Association>
|
||||||
|
<EntityContainer Name="DBPR14Entities" annotation:LazyLoadingEnabled="true">
|
||||||
|
<EntitySet Name="Doctors" EntityType="Self.Doctor" />
|
||||||
|
<EntitySet Name="Patients" EntityType="Self.Patient" />
|
||||||
|
<EntitySet Name="Records" EntityType="Self.Record" />
|
||||||
|
<EntitySet Name="Specialities" EntityType="Self.Speciality" />
|
||||||
|
<AssociationSet Name="FK__Doctor__id_speci__3E52440B" Association="Self.FK__Doctor__id_speci__3E52440B">
|
||||||
|
<End Role="Speciality" EntitySet="Specialities" />
|
||||||
|
<End Role="Doctor" EntitySet="Doctors" />
|
||||||
|
</AssociationSet>
|
||||||
|
<AssociationSet Name="FK__Record__id_docto__3F466844" Association="Self.FK__Record__id_docto__3F466844">
|
||||||
|
<End Role="Doctor" EntitySet="Doctors" />
|
||||||
|
<End Role="Record" EntitySet="Records" />
|
||||||
|
</AssociationSet>
|
||||||
|
<AssociationSet Name="FK__Record__id_patie__403A8C7D" Association="Self.FK__Record__id_patie__403A8C7D">
|
||||||
|
<End Role="Patient" EntitySet="Patients" />
|
||||||
|
<End Role="Record" EntitySet="Records" />
|
||||||
|
</AssociationSet>
|
||||||
|
</EntityContainer>
|
||||||
|
</Schema>
|
||||||
|
</edmx:ConceptualModels>
|
||||||
|
<!-- C-S mapping content -->
|
||||||
|
<edmx:Mappings>
|
||||||
|
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
|
||||||
|
<EntityContainerMapping StorageEntityContainer="Хранилище DBPR14ModelContainer" CdmEntityContainer="DBPR14Entities">
|
||||||
|
<EntitySetMapping Name="Doctors">
|
||||||
|
<EntityTypeMapping TypeName="DBPR14Model.Doctor">
|
||||||
|
<MappingFragment StoreEntitySet="Doctor">
|
||||||
|
<ScalarProperty Name="id_doctor" ColumnName="id_doctor" />
|
||||||
|
<ScalarProperty Name="last_name" ColumnName="last_name" />
|
||||||
|
<ScalarProperty Name="first_name" ColumnName="first_name" />
|
||||||
|
<ScalarProperty Name="middle_name" ColumnName="middle_name" />
|
||||||
|
<ScalarProperty Name="id_speciality" ColumnName="id_speciality" />
|
||||||
|
</MappingFragment>
|
||||||
|
</EntityTypeMapping>
|
||||||
|
</EntitySetMapping>
|
||||||
|
<EntitySetMapping Name="Patients">
|
||||||
|
<EntityTypeMapping TypeName="DBPR14Model.Patient">
|
||||||
|
<MappingFragment StoreEntitySet="Patient">
|
||||||
|
<ScalarProperty Name="id_patient" ColumnName="id_patient" />
|
||||||
|
<ScalarProperty Name="last_name" ColumnName="last_name" />
|
||||||
|
<ScalarProperty Name="first_name" ColumnName="first_name" />
|
||||||
|
<ScalarProperty Name="middle_name" ColumnName="middle_name" />
|
||||||
|
<ScalarProperty Name="gender" ColumnName="gender" />
|
||||||
|
<ScalarProperty Name="birth_date" ColumnName="birth_date" />
|
||||||
|
<ScalarProperty Name="address" ColumnName="address" />
|
||||||
|
<ScalarProperty Name="policy_number" ColumnName="policy_number" />
|
||||||
|
<ScalarProperty Name="phone_number" ColumnName="phone_number" />
|
||||||
|
</MappingFragment>
|
||||||
|
</EntityTypeMapping>
|
||||||
|
</EntitySetMapping>
|
||||||
|
<EntitySetMapping Name="Records">
|
||||||
|
<EntityTypeMapping TypeName="DBPR14Model.Record">
|
||||||
|
<MappingFragment StoreEntitySet="Record">
|
||||||
|
<ScalarProperty Name="id_appointment" ColumnName="id_appointment" />
|
||||||
|
<ScalarProperty Name="id_patient" ColumnName="id_patient" />
|
||||||
|
<ScalarProperty Name="id_doctor" ColumnName="id_doctor" />
|
||||||
|
<ScalarProperty Name="appointment_date" ColumnName="appointment_date" />
|
||||||
|
<ScalarProperty Name="appointment_time" ColumnName="appointment_time" />
|
||||||
|
</MappingFragment>
|
||||||
|
</EntityTypeMapping>
|
||||||
|
</EntitySetMapping>
|
||||||
|
<EntitySetMapping Name="Specialities">
|
||||||
|
<EntityTypeMapping TypeName="DBPR14Model.Speciality">
|
||||||
|
<MappingFragment StoreEntitySet="Speciality">
|
||||||
|
<ScalarProperty Name="id_speciality" ColumnName="id_speciality" />
|
||||||
|
<ScalarProperty Name="name_speciality" ColumnName="name_speciality" />
|
||||||
|
</MappingFragment>
|
||||||
|
</EntityTypeMapping>
|
||||||
|
</EntitySetMapping>
|
||||||
|
</EntityContainerMapping>
|
||||||
|
</Mapping>
|
||||||
|
</edmx:Mappings>
|
||||||
|
</edmx:Runtime>
|
||||||
|
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||||
|
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||||
|
<Connection>
|
||||||
|
<DesignerInfoPropertySet>
|
||||||
|
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
|
||||||
|
</DesignerInfoPropertySet>
|
||||||
|
</Connection>
|
||||||
|
<Options>
|
||||||
|
<DesignerInfoPropertySet>
|
||||||
|
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
||||||
|
<DesignerProperty Name="EnablePluralization" Value="true" />
|
||||||
|
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
|
||||||
|
<DesignerProperty Name="UseLegacyProvider" Value="false" />
|
||||||
|
<DesignerProperty Name="CodeGenerationStrategy" Value="Нет" />
|
||||||
|
</DesignerInfoPropertySet>
|
||||||
|
</Options>
|
||||||
|
<!-- Diagram content (shape and connector positions) -->
|
||||||
|
<Diagrams></Diagrams>
|
||||||
|
</Designer>
|
||||||
|
</edmx:Edmx>
|
||||||
18
PR14/PR14/Models/Model1.edmx.diagram
Normal file
18
PR14/PR14/Models/Model1.edmx.diagram
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||||
|
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||||
|
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||||
|
<!-- Diagram content (shape and connector positions) -->
|
||||||
|
<edmx:Diagrams>
|
||||||
|
<Diagram DiagramId="a2a30e4d9b5d4e7082b8729ee1894b61" Name="Diagram1">
|
||||||
|
<EntityTypeShape EntityType="DBPR14Model.Doctor" Width="1.5" PointX="3" PointY="1" IsExpanded="true" />
|
||||||
|
<EntityTypeShape EntityType="DBPR14Model.Patient" Width="1.5" PointX="3" PointY="5.875" IsExpanded="true" />
|
||||||
|
<EntityTypeShape EntityType="DBPR14Model.Record" Width="1.5" PointX="5.25" PointY="1" IsExpanded="true" />
|
||||||
|
<EntityTypeShape EntityType="DBPR14Model.Speciality" Width="1.5" PointX="0.75" PointY="1.375" IsExpanded="true" />
|
||||||
|
<AssociationConnector Association="DBPR14Model.FK__Doctor__id_speci__3E52440B" ManuallyRouted="false" />
|
||||||
|
<AssociationConnector Association="DBPR14Model.FK__Record__id_docto__3F466844" ManuallyRouted="false" />
|
||||||
|
<AssociationConnector Association="DBPR14Model.FK__Record__id_patie__403A8C7D" ManuallyRouted="false" />
|
||||||
|
</Diagram>
|
||||||
|
</edmx:Diagrams>
|
||||||
|
</edmx:Designer>
|
||||||
|
</edmx:Edmx>
|
||||||
733
PR14/PR14/Models/Model1.tt
Normal file
733
PR14/PR14/Models/Model1.tt
Normal file
@@ -0,0 +1,733 @@
|
|||||||
|
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||||
|
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||||
|
output extension=".cs"#><#
|
||||||
|
|
||||||
|
const string inputFile = @"Model1.edmx";
|
||||||
|
var textTransform = DynamicTextTransformation.Create(this);
|
||||||
|
var code = new CodeGenerationTools(this);
|
||||||
|
var ef = new MetadataTools(this);
|
||||||
|
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||||
|
var fileManager = EntityFrameworkTemplateFileManager.Create(this);
|
||||||
|
var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
|
||||||
|
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||||
|
|
||||||
|
if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteHeader(codeStringGenerator, fileManager);
|
||||||
|
|
||||||
|
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
|
||||||
|
{
|
||||||
|
fileManager.StartNewFile(entity.Name + ".cs");
|
||||||
|
BeginNamespace(code);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
|
||||||
|
<#=codeStringGenerator.EntityClassOpening(entity)#>
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
|
||||||
|
var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
|
||||||
|
var complexProperties = typeMapper.GetComplexProperties(entity);
|
||||||
|
|
||||||
|
if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||||
|
public <#=code.Escape(entity)#>()
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var navigationProperty in collectionNavigationProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var complexProperty in complexProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
var simpleProperties = typeMapper.GetSimpleProperties(entity);
|
||||||
|
if (simpleProperties.Any())
|
||||||
|
{
|
||||||
|
foreach (var edmProperty in simpleProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.Property(edmProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (complexProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach(var complexProperty in complexProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.Property(complexProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var navigationProperties = typeMapper.GetNavigationProperties(entity);
|
||||||
|
if (navigationProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach (var navigationProperty in navigationProperties)
|
||||||
|
{
|
||||||
|
if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
EndNamespace(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
|
||||||
|
{
|
||||||
|
fileManager.StartNewFile(complex.Name + ".cs");
|
||||||
|
BeginNamespace(code);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||||
|
<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var complexProperties = typeMapper.GetComplexProperties(complex);
|
||||||
|
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
|
||||||
|
|
||||||
|
if (propertiesWithDefaultValues.Any() || complexProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
public <#=code.Escape(complex)#>()
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var complexProperty in complexProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
var simpleProperties = typeMapper.GetSimpleProperties(complex);
|
||||||
|
if (simpleProperties.Any())
|
||||||
|
{
|
||||||
|
foreach(var edmProperty in simpleProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.Property(edmProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (complexProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach(var edmProperty in complexProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.Property(edmProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
EndNamespace(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
|
||||||
|
{
|
||||||
|
fileManager.StartNewFile(enumType.Name + ".cs");
|
||||||
|
BeginNamespace(code);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||||
|
<#
|
||||||
|
if (typeMapper.EnumIsFlags(enumType))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
[Flags]
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.EnumOpening(enumType)#>
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var foundOne = false;
|
||||||
|
|
||||||
|
foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
|
||||||
|
{
|
||||||
|
foundOne = true;
|
||||||
|
#>
|
||||||
|
<#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundOne)
|
||||||
|
{
|
||||||
|
this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
EndNamespace(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
fileManager.Process();
|
||||||
|
|
||||||
|
#>
|
||||||
|
<#+
|
||||||
|
|
||||||
|
public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
|
||||||
|
{
|
||||||
|
fileManager.StartHeader();
|
||||||
|
#>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||||
|
//
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
|
||||||
|
<#+
|
||||||
|
fileManager.EndBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BeginNamespace(CodeGenerationTools code)
|
||||||
|
{
|
||||||
|
var codeNamespace = code.VsNamespaceSuggestion();
|
||||||
|
if (!String.IsNullOrEmpty(codeNamespace))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||||
|
{
|
||||||
|
<#+
|
||||||
|
PushIndent(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EndNamespace(CodeGenerationTools code)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
|
||||||
|
{
|
||||||
|
PopIndent();
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#+
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public const string TemplateId = "CSharp_DbContext_Types_EF6";
|
||||||
|
|
||||||
|
public class CodeStringGenerator
|
||||||
|
{
|
||||||
|
private readonly CodeGenerationTools _code;
|
||||||
|
private readonly TypeMapper _typeMapper;
|
||||||
|
private readonly MetadataTools _ef;
|
||||||
|
|
||||||
|
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(code, "code");
|
||||||
|
ArgumentNotNull(typeMapper, "typeMapper");
|
||||||
|
ArgumentNotNull(ef, "ef");
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_typeMapper = typeMapper;
|
||||||
|
_ef = ef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Property(EdmProperty edmProperty)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||||
|
Accessibility.ForProperty(edmProperty),
|
||||||
|
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||||
|
_code.Escape(edmProperty),
|
||||||
|
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||||
|
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NavigationProperty(NavigationProperty navProp)
|
||||||
|
{
|
||||||
|
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||||
|
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||||
|
_code.Escape(navProp),
|
||||||
|
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||||
|
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AccessibilityAndVirtual(string accessibility)
|
||||||
|
{
|
||||||
|
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EntityClassOpening(EntityType entity)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1}partial class {2}{3}",
|
||||||
|
Accessibility.ForType(entity),
|
||||||
|
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||||
|
_code.Escape(entity),
|
||||||
|
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EnumOpening(SimpleType enumType)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} enum {1} : {2}",
|
||||||
|
Accessibility.ForType(enumType),
|
||||||
|
_code.Escape(enumType),
|
||||||
|
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||||
|
{
|
||||||
|
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||||
|
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||||
|
{
|
||||||
|
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||||
|
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||||
|
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||||
|
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} IQueryable<{1}> {2}({3})",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||||
|
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||||
|
_code.Escape(edmFunction),
|
||||||
|
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||||
|
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||||
|
edmFunction.NamespaceName,
|
||||||
|
edmFunction.Name,
|
||||||
|
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||||
|
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||||
|
|
||||||
|
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||||
|
if (includeMergeOption)
|
||||||
|
{
|
||||||
|
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2}({3})",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||||
|
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||||
|
_code.Escape(edmFunction),
|
||||||
|
paramList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||||
|
|
||||||
|
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||||
|
if (includeMergeOption)
|
||||||
|
{
|
||||||
|
callParams = ", mergeOption" + callParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||||
|
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||||
|
edmFunction.Name,
|
||||||
|
callParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DbSet(EntitySet entitySet)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||||
|
Accessibility.ForReadOnlyProperty(entitySet),
|
||||||
|
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||||
|
_code.Escape(entitySet));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||||
|
{
|
||||||
|
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||||
|
? string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0}using System;{1}" +
|
||||||
|
"{2}",
|
||||||
|
inHeader ? Environment.NewLine : "",
|
||||||
|
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||||
|
inHeader ? "" : Environment.NewLine)
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TypeMapper
|
||||||
|
{
|
||||||
|
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||||
|
|
||||||
|
private readonly System.Collections.IList _errors;
|
||||||
|
private readonly CodeGenerationTools _code;
|
||||||
|
private readonly MetadataTools _ef;
|
||||||
|
|
||||||
|
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(code, "code");
|
||||||
|
ArgumentNotNull(ef, "ef");
|
||||||
|
ArgumentNotNull(errors, "errors");
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_ef = ef;
|
||||||
|
_errors = errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FixNamespaces(string typeName)
|
||||||
|
{
|
||||||
|
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(TypeUsage typeUsage)
|
||||||
|
{
|
||||||
|
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType)
|
||||||
|
{
|
||||||
|
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||||
|
{
|
||||||
|
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||||
|
{
|
||||||
|
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||||
|
{
|
||||||
|
if (edmType == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var collectionType = edmType as CollectionType;
|
||||||
|
if (collectionType != null)
|
||||||
|
{
|
||||||
|
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||||
|
}
|
||||||
|
|
||||||
|
var typeName = _code.Escape(edmType.MetadataProperties
|
||||||
|
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||||
|
.Select(p => (string)p.Value)
|
||||||
|
.FirstOrDefault())
|
||||||
|
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||||
|
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||||
|
_code.Escape(edmType));
|
||||||
|
|
||||||
|
if (edmType is StructuralType)
|
||||||
|
{
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edmType is SimpleType)
|
||||||
|
{
|
||||||
|
var clrType = UnderlyingClrType(edmType);
|
||||||
|
if (!IsEnumType(edmType))
|
||||||
|
{
|
||||||
|
typeName = _code.Escape(clrType);
|
||||||
|
}
|
||||||
|
|
||||||
|
typeName = FixNamespaces(typeName);
|
||||||
|
|
||||||
|
return clrType.IsValueType && isNullable == true ?
|
||||||
|
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||||
|
typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("edmType");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type UnderlyingClrType(EdmType edmType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmType, "edmType");
|
||||||
|
|
||||||
|
var primitiveType = edmType as PrimitiveType;
|
||||||
|
if (primitiveType != null)
|
||||||
|
{
|
||||||
|
return primitiveType.ClrEquivalentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsEnumType(edmType))
|
||||||
|
{
|
||||||
|
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumMember, "enumMember");
|
||||||
|
|
||||||
|
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||||
|
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetEnumMemberName(MetadataItem enumMember)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumMember, "enumMember");
|
||||||
|
|
||||||
|
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||||
|
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||||
|
return membersProperty != null
|
||||||
|
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||||
|
: Enumerable.Empty<MetadataItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EnumIsFlags(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||||
|
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEnumType(GlobalItem edmType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmType, "edmType");
|
||||||
|
|
||||||
|
return edmType.GetType().Name == "EnumType";
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CreateLiteral(object value)
|
||||||
|
{
|
||||||
|
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||||
|
{
|
||||||
|
return _code.CreateLiteral(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(types, "types");
|
||||||
|
ArgumentNotNull(sourceFile, "sourceFile");
|
||||||
|
|
||||||
|
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||||
|
if (types.Any(item => !hash.Add(item)))
|
||||||
|
{
|
||||||
|
_errors.Add(
|
||||||
|
new CompilerError(sourceFile, -1, -1, "6023",
|
||||||
|
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||||
|
{
|
||||||
|
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||||
|
.Where(e => IsEnumType(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||||
|
{
|
||||||
|
return itemCollection
|
||||||
|
.OfType<T>()
|
||||||
|
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||||
|
.OrderBy(i => i.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||||
|
{
|
||||||
|
return itemCollection
|
||||||
|
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||||
|
.Select(g => GetGlobalItemName(g));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetGlobalItemName(GlobalItem item)
|
||||||
|
{
|
||||||
|
if (item is EdmType)
|
||||||
|
{
|
||||||
|
return ((EdmType)item).Name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ((EntityContainer)item).Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmFunction, "edmFunction");
|
||||||
|
|
||||||
|
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||||
|
return returnParamsProperty == null
|
||||||
|
? edmFunction.ReturnParameter
|
||||||
|
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsComposable(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmFunction, "edmFunction");
|
||||||
|
|
||||||
|
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||||
|
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
var returnParam = GetReturnParameter(edmFunction);
|
||||||
|
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var returnType = GetReturnType(edmFunction);
|
||||||
|
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||||
|
{
|
||||||
|
if (arg == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
36
PR14/PR14/Models/Patient.cs
Normal file
36
PR14/PR14/Models/Patient.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан по шаблону.
|
||||||
|
//
|
||||||
|
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||||
|
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace PR14.Models
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class Patient
|
||||||
|
{
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||||
|
public Patient()
|
||||||
|
{
|
||||||
|
this.Records = new HashSet<Record>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int id_patient { get; set; }
|
||||||
|
public string last_name { get; set; }
|
||||||
|
public string first_name { get; set; }
|
||||||
|
public string middle_name { get; set; }
|
||||||
|
public string gender { get; set; }
|
||||||
|
public Nullable<System.DateTime> birth_date { get; set; }
|
||||||
|
public string address { get; set; }
|
||||||
|
public string policy_number { get; set; }
|
||||||
|
public string phone_number { get; set; }
|
||||||
|
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||||
|
public virtual ICollection<Record> Records { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
26
PR14/PR14/Models/Record.cs
Normal file
26
PR14/PR14/Models/Record.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан по шаблону.
|
||||||
|
//
|
||||||
|
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||||
|
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace PR14.Models
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class Record
|
||||||
|
{
|
||||||
|
public int id_appointment { get; set; }
|
||||||
|
public int id_patient { get; set; }
|
||||||
|
public int id_doctor { get; set; }
|
||||||
|
public System.DateTime appointment_date { get; set; }
|
||||||
|
public System.TimeSpan appointment_time { get; set; }
|
||||||
|
|
||||||
|
public virtual Doctor Doctor { get; set; }
|
||||||
|
public virtual Patient Patient { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
29
PR14/PR14/Models/Speciality.cs
Normal file
29
PR14/PR14/Models/Speciality.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан по шаблону.
|
||||||
|
//
|
||||||
|
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||||
|
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace PR14.Models
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class Speciality
|
||||||
|
{
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||||
|
public Speciality()
|
||||||
|
{
|
||||||
|
this.Doctors = new HashSet<Doctor>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int id_speciality { get; set; }
|
||||||
|
public string name_speciality { get; set; }
|
||||||
|
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||||
|
public virtual ICollection<Doctor> Doctors { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\EntityFramework.6.5.1\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.5.1\build\EntityFramework.props')" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -14,6 +15,8 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -35,8 +38,17 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\EntityFramework.6.5.1\lib\net45\EntityFramework.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\EntityFramework.6.5.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
|
<Reference Include="System.Security" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@@ -70,6 +82,10 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Page Include="AppointmentWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@@ -78,12 +94,42 @@
|
|||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="AppointmentWindow.xaml.cs">
|
||||||
|
<DependentUpon>AppointmentWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="MainWindow.xaml.cs">
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Models\Doctor.cs">
|
||||||
|
<DependentUpon>Model1.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Models\Model1.Context.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Model1.Context.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Models\Model1.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Model1.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Models\Model1.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Model1.edmx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Models\Patient.cs">
|
||||||
|
<DependentUpon>Model1.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Models\Record.cs">
|
||||||
|
<DependentUpon>Model1.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Models\Speciality.cs">
|
||||||
|
<DependentUpon>Model1.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -101,6 +147,13 @@
|
|||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EntityDeploy Include="Models\Model1.edmx">
|
||||||
|
<Generator>EntityModelCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Model1.Designer.cs</LastGenOutput>
|
||||||
|
</EntityDeploy>
|
||||||
|
<None Include="Models\Model1.edmx.diagram">
|
||||||
|
<DependentUpon>Model1.edmx</DependentUpon>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
@@ -110,5 +163,29 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Models\Model1.Context.tt">
|
||||||
|
<Generator>TextTemplatingFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Model1.Context.cs</LastGenOutput>
|
||||||
|
<DependentUpon>Model1.edmx</DependentUpon>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Models\Model1.tt">
|
||||||
|
<Generator>TextTemplatingFileGenerator</Generator>
|
||||||
|
<DependentUpon>Model1.edmx</DependentUpon>
|
||||||
|
<LastGenOutput>Model1.cs</LastGenOutput>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\EntityFramework.6.5.1\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.5.1\build\EntityFramework.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\EntityFramework.6.5.1\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.5.1\build\EntityFramework.targets'))" />
|
||||||
|
</Target>
|
||||||
|
<Import Project="..\packages\EntityFramework.6.5.1\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.5.1\build\EntityFramework.targets')" />
|
||||||
</Project>
|
</Project>
|
||||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "F9FCE631641E7289F19E694FBE5CD8539BF472CDAFF29FED1E7329E99B4BF64A"
|
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "0C7DAB16E7F78393B4927CAAE8AFA28B449B4DC4D4F03AC006B0BB730D29D630"
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// Этот код создан программой.
|
// Этот код создан программой.
|
||||||
@@ -40,6 +40,86 @@ namespace PR14 {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
|
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
|
||||||
|
|
||||||
|
|
||||||
|
#line 21 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.ListView lvPatients;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 35 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbSurname;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 38 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbName;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 41 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbPatronymic;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 45 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.RadioButton rbMale;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 46 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.RadioButton rbFemale;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 50 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.DatePicker dpBirthday;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 53 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbAddress;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 56 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbPolis;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 59 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbPhone;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
private bool _contentLoaded;
|
private bool _contentLoaded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -68,6 +148,53 @@ namespace PR14 {
|
|||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
||||||
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
|
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
|
||||||
|
switch (connectionId)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
this.lvPatients = ((System.Windows.Controls.ListView)(target));
|
||||||
|
|
||||||
|
#line 21 "..\..\MainWindow.xaml"
|
||||||
|
this.lvPatients.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.lvPatients_SelectionChanged);
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
return;
|
||||||
|
case 2:
|
||||||
|
this.tbSurname = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 3:
|
||||||
|
this.tbName = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 4:
|
||||||
|
this.tbPatronymic = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 5:
|
||||||
|
this.rbMale = ((System.Windows.Controls.RadioButton)(target));
|
||||||
|
return;
|
||||||
|
case 6:
|
||||||
|
this.rbFemale = ((System.Windows.Controls.RadioButton)(target));
|
||||||
|
return;
|
||||||
|
case 7:
|
||||||
|
this.dpBirthday = ((System.Windows.Controls.DatePicker)(target));
|
||||||
|
return;
|
||||||
|
case 8:
|
||||||
|
this.tbAddress = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 9:
|
||||||
|
this.tbPolis = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 10:
|
||||||
|
this.tbPhone = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 11:
|
||||||
|
|
||||||
|
#line 69 "..\..\MainWindow.xaml"
|
||||||
|
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.BtnAdd_Click);
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._contentLoaded = true;
|
this._contentLoaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// Updated by XamlIntelliSenseFileGenerator 20.04.2026 16:57:45
|
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "0C7DAB16E7F78393B4927CAAE8AFA28B449B4DC4D4F03AC006B0BB730D29D630"
|
||||||
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "F9FCE631641E7289F19E694FBE5CD8539BF472CDAFF29FED1E7329E99B4BF64A"
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// Этот код создан программой.
|
// Этот код создан программой.
|
||||||
@@ -33,57 +32,171 @@ using System.Windows.Shapes;
|
|||||||
using System.Windows.Shell;
|
using System.Windows.Shell;
|
||||||
|
|
||||||
|
|
||||||
namespace PR14
|
namespace PR14 {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MainWindow
|
/// MainWindow
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector
|
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
|
||||||
{
|
|
||||||
|
|
||||||
|
#line 21 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.ListView lvPatients;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 35 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbSurname;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 38 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbName;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 41 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbPatronymic;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 45 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.RadioButton rbMale;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 46 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.RadioButton rbFemale;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 50 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.DatePicker dpBirthday;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 53 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbAddress;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 56 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbPolis;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
|
#line 59 "..\..\MainWindow.xaml"
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
|
internal System.Windows.Controls.TextBox tbPhone;
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
private bool _contentLoaded;
|
private bool _contentLoaded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// InitializeComponent
|
/// InitializeComponent
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
|
||||||
public void InitializeComponent()
|
public void InitializeComponent() {
|
||||||
{
|
if (_contentLoaded) {
|
||||||
if (_contentLoaded)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_contentLoaded = true;
|
_contentLoaded = true;
|
||||||
System.Uri resourceLocater = new System.Uri("/PR14;component/mainwindow.xaml", System.UriKind.Relative);
|
System.Uri resourceLocater = new System.Uri("/PR14;component/mainwindow.xaml", System.UriKind.Relative);
|
||||||
|
|
||||||
#line 1 "..\..\MainWindow.xaml"
|
#line 1 "..\..\MainWindow.xaml"
|
||||||
System.Windows.Application.LoadComponent(this, resourceLocater);
|
System.Windows.Application.LoadComponent(this, resourceLocater);
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
|
||||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
|
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
||||||
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
|
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
|
||||||
{
|
switch (connectionId)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
this.lvPatients = ((System.Windows.Controls.ListView)(target));
|
||||||
|
|
||||||
|
#line 21 "..\..\MainWindow.xaml"
|
||||||
|
this.lvPatients.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.lvPatients_SelectionChanged);
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
return;
|
||||||
|
case 2:
|
||||||
|
this.tbSurname = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 3:
|
||||||
|
this.tbName = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 4:
|
||||||
|
this.tbPatronymic = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 5:
|
||||||
|
this.rbMale = ((System.Windows.Controls.RadioButton)(target));
|
||||||
|
return;
|
||||||
|
case 6:
|
||||||
|
this.rbFemale = ((System.Windows.Controls.RadioButton)(target));
|
||||||
|
return;
|
||||||
|
case 7:
|
||||||
|
this.dpBirthday = ((System.Windows.Controls.DatePicker)(target));
|
||||||
|
return;
|
||||||
|
case 8:
|
||||||
|
this.tbAddress = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 9:
|
||||||
|
this.tbPolis = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 10:
|
||||||
|
this.tbPhone = ((System.Windows.Controls.TextBox)(target));
|
||||||
|
return;
|
||||||
|
case 11:
|
||||||
|
|
||||||
|
#line 69 "..\..\MainWindow.xaml"
|
||||||
|
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.BtnAdd_Click);
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._contentLoaded = true;
|
this._contentLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal System.Windows.Controls.DatePicker dpBirthday;
|
|
||||||
internal System.Windows.Controls.TextBlock tbSurname;
|
|
||||||
internal System.Windows.Controls.TextBlock tbName;
|
|
||||||
internal System.Windows.Controls.TextBlock tbPatronymic;
|
|
||||||
internal System.Windows.Controls.TextBlock tbAdress;
|
|
||||||
internal System.Windows.Controls.TextBlock tbPolis;
|
|
||||||
internal System.Windows.Controls.TextBlock tbPhone;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -11,9 +11,9 @@ false
|
|||||||
DEBUG;TRACE
|
DEBUG;TRACE
|
||||||
C:\Users\usersql\Source\Repos\MDK0101\PR14\PR14\App.xaml
|
C:\Users\usersql\Source\Repos\MDK0101\PR14\PR14\App.xaml
|
||||||
1219584333
|
1219584333
|
||||||
|
2-1223955081
|
||||||
51579654133
|
12-8670233
|
||||||
18790512828
|
23-924788474
|
||||||
MainWindow.xaml;
|
MainWindow.xaml;
|
||||||
|
|
||||||
False
|
False
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="EntityFramework" version="6.5.1" targetFramework="net472" />
|
||||||
|
<package id="EntityFramework.ru" version="6.2.0" targetFramework="net472" />
|
||||||
<package id="Extended.Wpf.Toolkit" version="5.0.0" targetFramework="net472" />
|
<package id="Extended.Wpf.Toolkit" version="5.0.0" targetFramework="net472" />
|
||||||
</packages>
|
</packages>
|
||||||
Reference in New Issue
Block a user