первая лаба возможно всё
This commit is contained in:
parent
ae9315ebed
commit
7605195b62
@ -18,9 +18,9 @@ public class Doctor
|
||||
|
||||
public int Room { get; private set; }
|
||||
|
||||
public Specialization Specialization { get; private set; } //свойство Specialization, которое имеет тип Specialization
|
||||
public Specialization Specialization { get; private set; }
|
||||
|
||||
public SpecializationLevel SpecializationLevel { get; private set; } //свойство SpecializationLevel, которое имеет тип SpecializationLevel
|
||||
public SpecializationLevel SpecializationLevel { get; private set; }
|
||||
|
||||
public static Doctor CreateEntity(int id, string first_Name, string last_Name, int room, Specialization specialization, SpecializationLevel specializationLevel)
|
||||
{
|
||||
|
@ -36,18 +36,15 @@ public partial class FormDoctorPayment : Form
|
||||
throw new Exception("Имеются не заполненные поля");
|
||||
}
|
||||
|
||||
// Получаем значение из первой строки колонки ColumnMonth
|
||||
string month = dataGridViewPay.Rows[0].Cells["ColumnMonth"].Value?.ToString();
|
||||
int countPatient = int.Parse(dataGridViewPay.Rows[0].Cells["Column2"].Value?.ToString() ?? "0");
|
||||
int payment = int.Parse(dataGridViewPay.Rows[0].Cells["Column3"].Value?.ToString() ?? "0");
|
||||
|
||||
// Проверяем, что месяц не пустой
|
||||
if (string.IsNullOrEmpty(month))
|
||||
{
|
||||
throw new Exception("Месяц не заполнен");
|
||||
}
|
||||
|
||||
// Создаем элемент DoctorPayments
|
||||
_doctorPayRepository.CreateDoctorPayments(DoctorPay.CreateElement(0, (int)comboBoxDoctor.SelectedValue!, month, countPatient, payment));
|
||||
|
||||
|
||||
@ -61,24 +58,4 @@ public partial class FormDoctorPayment : Form
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<DoctorPay> CreateListDoctorPaymentsFromDataGrid()
|
||||
{
|
||||
var list = new List<DoctorPay>();
|
||||
foreach (DataGridViewRow row in dataGridViewPay.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnMonth"].Value == null || row.Cells["ColumnCount"].Value == null || row.Cells["ColumnPayment"] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// ДОДЕЛАТЬ!!!
|
||||
list.Add(DoctorPay.CreateElement(0, 0, row.Cells["ColumnMonth"].Value.ToString(), Convert.ToInt32(row.Cells["ColumnCount"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnPayment"].Value)));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -58,10 +58,9 @@ public partial class FormDrug : Form
|
||||
InitializeComponent();
|
||||
_drugRepository = drugRepository ??
|
||||
throw new ArgumentNullException(nameof(drugRepository));
|
||||
// вытаскиваем все значения
|
||||
foreach (var elem in Enum.GetValues(typeof(DrugsNames)))
|
||||
{
|
||||
checkedListBoxName.Items.Add(elem); // заполняем поэлементно значения
|
||||
checkedListBoxName.Items.Add(elem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,16 +60,6 @@ public partial class FormMedicalHistories : Form
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
// _container.Resolve<FormMedicalHistory>().ShowDialog();
|
||||
// LoadList();
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormMedicalHistory>().ShowDialog();
|
||||
|
@ -32,7 +32,6 @@ public partial class FormMedicalHistory : Form
|
||||
_medicalHistoryRepository = medicalHistoryRepository ??
|
||||
throw new ArgumentNullException(nameof(medicalHistoryRepository));
|
||||
|
||||
// Настройка ComboBox
|
||||
comboBoxPacient.DataSource = patientRepository.ReadPatient();
|
||||
comboBoxPacient.DisplayMember = "First_Name";
|
||||
comboBoxPacient.ValueMember = "Id";
|
||||
|
@ -30,18 +30,17 @@ public partial class FormPatient : Form
|
||||
|
||||
|
||||
|
||||
public int Id // свойство
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var patient = _patientRepository.ReadPatientById(value); // value - некое значение
|
||||
if (patient == null) // по этому значению пытаемся найти запись в репозитории
|
||||
var patient = _patientRepository.ReadPatientById(value);
|
||||
if (patient == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(patient)); // если не находим выкидываем ошибку
|
||||
throw new InvalidDataException(nameof(patient));
|
||||
}
|
||||
// Если все норм, то пытаемся заполнить поля
|
||||
textBoxFirstName.Text = patient.First_Name;
|
||||
textBoxLastName.Text = patient.Last_Name;
|
||||
textBoxAdress.Text = patient.Address;
|
||||
@ -62,24 +61,19 @@ public partial class FormPatient : Form
|
||||
{
|
||||
try
|
||||
{
|
||||
// проверяем что поля заполнены
|
||||
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text) || string.IsNullOrWhiteSpace(textBoxNumPhone.Text)
|
||||
|| string.IsNullOrWhiteSpace(textBoxAdress.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
// проверка есть ли у нас id
|
||||
if (_patientId.HasValue)
|
||||
{
|
||||
// мы создаем запись и передаем id
|
||||
_patientRepository.UpdatePatient(CreatePatient(_patientId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
// если id нет, то мы создаем запись, с id ноль
|
||||
_patientRepository.CreatPatient(CreatePatient(0));
|
||||
}
|
||||
// закрываем форму
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -55,11 +55,10 @@ public partial class FormPatients : Form
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
// мы получаем через container объект FormPatient и вызываем его
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormPatient>().ShowDialog();
|
||||
LoadList(); // обновление списка
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user