public static void AddHealthStatus(string info, DateTime creatingTime, Patient owner) { HealthStatus status = new HealthStatus(); status.Status = string.Empty; status.CreatingTime = creatingTime; // задание времени создания // status.Number = GetHealthStatusCode(); // задание связи EntityModelContainer container = new EntityModelContainer(); owner = container.PatientSet.Find(owner.UserCode); status.Patient = owner; container.HealthStatusSet.Add(status); // добавление в базу данных container.SaveChanges(); status = container.HealthStatusSet.Find(status.Number); status.Status = info; // задание связи с пациентом owner.HealthStatus.Add(status); int code = owner.UserCode; status.OwnerCode = code; container.SaveChanges(); }
public static void GiveLoginPassword(string message, out string login, out string password, out bool exist) { login = string.Empty; password = string.Empty; exist = false; string messagePattern = @"Зарегистрирован\sновый\sпациент\s([\w,\s]*)\sс\sкодом\s([\d]*)\.\sТребуется\sпредоставление\sдоступа\."; string[] info = Regex.Split(message, messagePattern); EntityModelContainer container = new EntityModelContainer(); Patient patient = container.PatientSet.Find(int.Parse(info[2])); if (patient.Login != "none") { exist = true; } else { login = GetLogin(info[1]); password = GetPassword(info[1]); patient.Login = login; patient.Password = password; container.SaveChanges(); } }
private void Change_Click(object sender, EventArgs e) { HealthStatusForm statusForm = new HealthStatusForm(); statusForm.newStatus = false; int row = MedicalResults.SelectedCells[0].RowIndex; HealthStatus changed = _container.HealthStatusSet.Find(int.Parse(MedicalResults.Rows[row].Cells[3].Value.ToString())); statusForm.status = changed; statusForm.ShowDialog(); _container.SaveChanges(); RefreshMedicalResults(); }
public static void AddPatient(Patient newPatient, Doctor doctor) { EntityModelContainer container = new EntityModelContainer(); container.PatientSet.Add(newPatient); container.SaveChanges(); AddDoctorPatientConnection(doctor, newPatient); }
public static void ChangeHealthStatus(HealthStatus status, string newValue) { EntityModelContainer container = new EntityModelContainer(); status = container.HealthStatusSet.Find(status.Number); status.Status = newValue; // меняем значение container.Entry(status).State = EntityState.Modified; container.SaveChanges(); // сохранение изменений }
public static void DeleteHealthStatus(HealthStatus status) { EntityModelContainer container = new EntityModelContainer(); Patient owner = container.PatientSet.Find(status.OwnerCode); owner.HealthStatus.Remove(status); // удаление связей container.HealthStatusSet.Remove(status); // удаление сущности container.SaveChanges(); }
public static void AddDoctorPatientConnection(Doctor doctor, Patient patient) { EntityModelContainer container = new EntityModelContainer(); patient = container.PatientSet.Find(patient.UserCode); doctor = container.DoctorSet.Find(doctor.UserCode); doctor.Patient.Add(patient); patient.Doctor.Add(doctor); container.SaveChanges(); }
private void DeletePatient_Click(object sender, EventArgs e) { int row = PatientsList.SelectedCells[0].RowIndex; int code = int.Parse(PatientsList.Rows[row].Cells[0].Value.ToString()); Patient deletedPatient = _container.PatientSet.Find(code); deletedPatient.Doctor.Remove(_container.DoctorSet.Find(user.UserCode)); user = _container.DoctorSet.Find(user.UserCode); user.Patient.Remove(deletedPatient); _container.SaveChanges(); RefreshPatients(); }
public static void AddMeasuredData(MeasuredData data, Patient owner, Device device) { EntityModelContainer container = new EntityModelContainer(); container.MeasuredDataSet.Add(data); // container.SaveChanges(); owner = container.PatientSet.Find(owner.UserCode); data = container.MeasuredDataSet.Find(data.Number); device = container.DeviceSet.Find(device.DeviceCode); owner.MeasuredData.Add(data); data.Patient = owner; container.SaveChanges(); }
public static void AddDevice(Device newDevice, Patient owner) { EntityModelContainer container = new EntityModelContainer(); container.DeviceSet.Add(newDevice); // container.SaveChanges(); // создание связей между сущностями owner = container.PatientSet.Find(owner.UserCode); newDevice = container.DeviceSet.Find(newDevice.DeviceCode); owner.Device.Add(newDevice); newDevice.Patient = owner; container.SaveChanges(); }
private void AddPatient_Click(object sender, EventArgs e) { EntityModelContainer container = new EntityModelContainer(); int row = SearchResults.SelectedCells[0].RowIndex; Patient selectedPat = container.PatientSet.Find(int.Parse(SearchResults.Rows[row].Cells[0].Value.ToString())); AddDeviceForm newDeviceType = new AddDeviceForm(); if (newDeviceType.ShowDialog() == DialogResult.OK) { DeviceFunction type = newDeviceType.function; bool exist = false; foreach (Device d in selectedPat.Device) { if (d.Function == type) { exist = true; } } if (exist) { if (MessageBox.Show( "Данный тип прибора уже закреплен за пациентом. Добавить пациента в список пациентов?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { InformationSystem.AddDoctorPatientConnection(user, selectedPat); this.Close(); } } else { Device newDevice = InformationSystem.CreateDevice(selectedPat, type); InformationSystem.AddDevice(newDevice, selectedPat); InformationSystem.AddDoctorPatientConnection(user, selectedPat); this.Close(); } } container.SaveChanges(); }
static void AddDeviceMessage(DeviceMessage message) { EntityModelContainer container = new EntityModelContainer(); container.DeviceMessageSet.Add(message); DeviceMessage m = container.DeviceMessageSet.Find(message.Id); m.Administrator = container.AdministratorSet.Find(m.RecipientCode); m.Device = container.DeviceSet.Find(m.SenderCode); Administrator recipient = container.AdministratorSet.Find(m.RecipientCode); recipient.DeviceMessage.Add(m); container.SaveChanges(); }
private void MessageList_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int row = MessageList.SelectedCells[0].RowIndex; int messageCode = (int)MessageList.Rows[row].Cells[3].Value; if (MessageList.Rows[row].Cells[1].Value.ToString() == "Запрос доступа к системе") { DoctorMessage message = (from userMessage in _container.DoctorMessageSet.AsParallel() where userMessage.Id == messageCode select userMessage).ToList()[0]; message = _container.DoctorMessageSet.Find(message.Id); ReadMessageForm readMessage = new ReadMessageForm(); readMessage.needSignUp = true; readMessage.docMessage = message; readMessage.isDocMessage = true; DialogResult messageResult = readMessage.ShowDialog(); if (messageResult == DialogResult.OK) { message.Checked = true; _container.SaveChanges(); } else { if (messageResult == DialogResult.Ignore) { message.Checked = false; _container.SaveChanges(); } } } else { if (MessageList.Rows[row].Cells[1].Value.ToString() == "Зарегистрирован новый пациент") { DoctorMessage message = (from userMessage in _container.DoctorMessageSet.AsParallel() where userMessage.Id == messageCode select userMessage).ToList()[0]; message = _container.DoctorMessageSet.Find(message.Id); ReadMessageForm readMessage = new ReadMessageForm(); readMessage.needSignUp = false; readMessage.docMessage = message; readMessage.isDocMessage = true; DialogResult messageResult = readMessage.ShowDialog(); if (messageResult == DialogResult.OK) { message.Checked = true; _container.SaveChanges(); } else { if (messageResult == DialogResult.Ignore) { message.Checked = false; _container.SaveChanges(); } } } else { DeviceMessage message = (from userMessage in _container.DeviceMessageSet.AsParallel() where userMessage.Id == messageCode select userMessage).ToList()[0]; message = _container.DeviceMessageSet.Find(message.Id); ReadMessageForm readMessage = new ReadMessageForm(); readMessage.needSignUp = false; readMessage.deviceMessage = message; readMessage.isDocMessage = false; DialogResult messageResult = readMessage.ShowDialog(); if (messageResult == DialogResult.OK) { message.Checked = true; _container.SaveChanges(); } else { if (messageResult == DialogResult.Ignore) { message.Checked = false; _container.SaveChanges(); } } } } // MessageList.Update(); RefreshMessages(); MessageList.Columns[0].Width = 117; MessageList.Columns[1].Width = 170; MessageList.Columns[2].Width = 100; MessageList.Columns[3].Visible = false; }