Дипломная работа: Автоматизация учета пациентов на примере ООО «АРХИДЕНТ»

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
122
Patient patient = null;
Procedure procedure = null;
Doctor doctor = null;
Context context = new Context() { dateTime = DateTime.Now };
public NewReception(Patient patient, SqlConnection connection)
{
InitializeComponent();
this.patient = patient;
this.connection = connection;
this.DataContext = context;
FIO.Text = patient.surname + " " + patient.namePatient + " " +
patient.patronymic;
//загрузкапроцедур
sqlExpression = "SELECT [Procedure].[Id_Procedure],
[Procedure].[nameProcedure], [Procedure].[price] FROM [Procedure]";
command = new SqlCommand(sqlExpression, connection);
reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
Procedure temp = new Procedure();
temp.Id = reader.GetInt32(0);
temp.nameProcedure = reader.GetString(1);
temp.price = reader.GetInt32(2);
123
ProcedureDataGrid.Items.Add(temp);
}
}
}
private void ProcedureDataGrid_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
Procedure procedure = ProcedureDataGrid.SelectedItem as
Procedure;
if (procedure != null)
{
this.procedure = procedure;
TBP.DataContext = this.procedure;
DoctorDataGrid.Items.Clear();
List<int> temp_position_id= new List<int>();
//получениеайдишникадолжности
sqlExpression = "SELECT [Position_Procedure].[position] FROM
[Position_Procedure] WHERE [Position_Procedure].[procedure] = " +
procedure.Id;
command = new SqlCommand(sqlExpression, connection);
reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
124
temp_position_id.Add(reader.GetInt32(0));
}
}
foreach (int tempId in temp_position_id)
{
//загрузкаврачей
sqlExpression = "SELECT [Doctor].[Id_doc],
[Doctor].[nameDoctor], [Doctor].[surname], [Doctor].[patronymic],
[Doctor].[position], [Position].[namePosition] FROM [Doctor] LEFT JOIN
[Position] ON [Doctor].[position] = [Position].[Id_position] WHERE
[Doctor].[position] = " + tempId;
command = new SqlCommand(sqlExpression, connection);
reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
Doctor temp = new Doctor();
temp.Id = reader.GetInt32(0);
temp.nameDoctor = reader.GetString(1);
temp.surname = reader.GetString(2);
temp.patronymic = reader.GetString(3);
temp.position_id = reader.GetInt32(4);
temp.positionname = reader.GetString(5);
DoctorDataGrid.Items.Add(temp);
}
}
}
125
}
}
private void DoctorDataGrid_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
Doctor doctor = DoctorDataGrid.SelectedItem as Doctor;
if (doctor != null)
{
this.doctor = doctor;
}
}
private void ButtonDone_Click(object sender, RoutedEventArgs e)
{
try
{
if (patient == null) { throw new Exception("непредвиденнаяошибка!"); }
if (procedure == null) { throw new Exception("Невыбранапроцедура."); }
if (doctor == null) { throw new Exception("Невыбранлечащаейврач."); }
if (procedure.price <= 0) { throw new Exception("Неназначенацена."); }
sqlExpression = string.Format("INSERT INTO [Reception] ([doctor],
[patient], [procedure], [status], [begin_reception], [price]) VALUES ({0}, {1},
{2}, 0, '{3}', {4})", this.doctor.Id, this.patient.Id, this.procedure.Id,
context.dateTime.ToString(), Convert.ToInt32(procedure.price));
command = new SqlCommand(sqlExpression, connection);
if (command.ExecuteNonQuery() == 1)
{
MessageBox.Show("Новаязаписьуспешнодобавлена");
126
}
else
{
throw new Exception("Ошибка добавлнеия новой записи в
базу данных.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "info", MessageBoxButton.OK,
MessageBoxImage.Information);
}
}
}
}
<Window x:Class="Reception.PatientCard"
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:Reception"
mc:Ignorable="d"
Title="карточкапациента" Height="450" Width="800">
<Window.Resources>
<Style TargetType="TextBlock" x:Key="LabelStyle">
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="Bold"/>
Источник: https://baza.diplomsite.ru/previewfile/286