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("Новаязаписьуспешнодобавлена");