private void cancelPatientMenuItem_Click(object sender, EventArgs e) { try { long patientID = Int64.Parse(dataGridView3.Rows[getSelectedRow(dataGridView3)].Cells[0].Value.ToString()); long illnessID = Int64.Parse(dataGridView4.Rows[getSelectedRow(dataGridView4)].Cells[0].Value.ToString()); Patient patient = new Patient() { PatientID = patientID }; Illness illness = new Illness() { IllnessID = illnessID }; if (!fachkonzept.UnLinkPatientIllness(patient, illness)) { throw new Exception("Patient konnte nicht ausgetragen werden."); } matchingPatients.RemoveAll(x => x.PatientID == patient.PatientID); matchingPatientBindingSource.ResetBindings(false); } catch (Exception ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void executeLinking() { try { int selectedPatientRow = getSelectedRow(dataGridView1); int selectedIllnessRow = getSelectedRow(dataGridView3); Patient patient = fachkonzept.GetPatient(Int64.Parse(dataGridView1.Rows[selectedPatientRow].Cells[0].Value.ToString())); Illness illness = fachkonzept.GetIllness(Int64.Parse(dataGridView3.Rows[selectedIllnessRow].Cells[0].Value.ToString())); if (!fachkonzept.LinkPatientIllness(patient, illness)) { throw new Exception("Fehler bei Zuordnung. \nZuordnung exisitert eventuell bereits."); } matchingIllnesses.Add(illness); matchingIllnessBindingSource.ResetBindings(false); matchingPatients.Add(patient); matchingPatientBindingSource.ResetBindings(false); linkingActive = false; lockTab = false; MakeButtonVisible(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Patient[] GetIllnessPatientsData(Illness illness, int page, int pageSize) { if (illness.IllnessID > 0) { using (SQLiteDataReader reader = this.Select("T_PatientsIllnesses AS pi", new String[4] { "p.patientID", "p.firstName", "p.lastName", "p.birthday" }, "T_Patients AS p", "pi.patientID = p.patientID", String.Format("pi.illnessID = {0}", illness.IllnessID), String.Format("{0}, {1}", page * pageSize, pageSize) ) ) { List <Patient> patients = new List <Patient>(); while (reader != null && reader.Read()) { patients.Add(this.GetPatientFromReader(reader)); } return(patients.ToArray()); } } else { return(new Patient[0]); } }
private void dataGridView3_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridViewRow currRow = ((DataGridView)sender).CurrentRow; try { long illnessID = Int64.Parse(currRow.Cells[0].Value.ToString()); string name = currRow.Cells[1].Value == null ? "" : currRow.Cells[1].Value.ToString(); bool contagious = currRow.Cells[2].Value == null ? false : (bool)currRow.Cells[2].Value; bool lethal = currRow.Cells[3].Value == null ? false : (bool)currRow.Cells[3].Value; bool curable = currRow.Cells[4].Value == null ? false : (bool)currRow.Cells[4].Value; DateTime birthdate; DateTime.TryParse(currRow.Cells[3].Value.ToString(), out birthdate); Illness illness = new Illness() { IllnessID = illnessID, Name = name, Contagious = contagious, Lethal = lethal, Curable = curable }; if (!fachkonzept.UpdateIllness(illness)) { throw new Exception("Änderung konnte nicht gespeichert werden."); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool LinkPatientIllnessData(Patient patient, Illness illness) { if (patient.PatientID > 0 && illness.IllnessID > 0) { SQLiteCommand exists = new SQLiteCommand( @"SELECT COUNT(*) FROM T_PatientsIllnesses WHERE (patientID = @patientID) AND (illnessID = @illnessID)", this.Connection ); exists.Parameters.Add("@patientID", DbType.Int64).Value = patient.PatientID; exists.Parameters.Add("@illnessID", DbType.Int64).Value = illness.IllnessID; if (Int32.Parse(exists.ExecuteScalar().ToString()) > 0) { return(false); } SQLiteCommand command = new SQLiteCommand( @"INSERT INTO T_PatientsIllnesses (patientID, illnessID) VALUES (@patientID, @illnessID)", this.Connection ); command.Parameters.Add("@patientID", DbType.Int64).Value = patient.PatientID; command.Parameters.Add("@illnessID", DbType.Int64).Value = illness.IllnessID; return(this.ExecuteNonQuery(command) == 1); } else { return(false); } }
public bool LinkPatientIllness(Patient patient, Illness illness) { if (patient.PatientID == 80 || illness.IllnessID == 80) { return(false); } return(true); }
public bool UpdateIllness(Illness illness) { if (illness.Name == "error") { return(false); } return(true); }
public bool DeleteIllness(Illness illness) { if (illness.IllnessID == 40) { return(false); } return(true); }
public bool CreateIllness(Illness illness) { if (illness.Name == "error") { return(false); } illness.IllnessID = 99; return(true); }
public Illness[] GetIllnesses(int pager, int number) { Illness[] illnesses = new Illness[5]; for (int i = 0; i < illnesses.Length; i++) { int id = i + pager * 5; illnesses[i] = GetIllness(id); } return(illnesses); }
public bool CreateIllness(Illness illness) { if (this.Datenhaltung.CreateIllnessData(illness)) { return((this.IllnessCache[illness.IllnessID] = illness) != null); } else { return(false); } }
public Illness GetIllness(long illnessID) { if (illnessID == 55) { return(null); } Illness illness = new Illness("name " + illnessID, (illnessID / 3 + 8) % 2 == 0, (illnessID / 8 + 3) % 3 == 0, (illnessID / 3 - 9) % 5 == 0); illness.IllnessID = illnessID; return(illness); }
public bool DeleteIllness(Illness illness) { long illnessID = illness.IllnessID; if (this.Datenhaltung.DeleteIllnessData(illness)) { return(this.IllnessCache.Remove(illnessID) || true); } else { return(false); } }
public int GetIllnessPatientsCountData(Illness illness) { if (illness.IllnessID > 0) { SQLiteCommand command = new SQLiteCommand("SELECT COUNT(*) FROM T_PatientsIllnesses WHERE illnessID = @illnessID", this.Connection); command.Parameters.Add("@illnessID", DbType.Int64).Value = illness.IllnessID; return(Int32.Parse(command.ExecuteScalar().ToString())); } else { return(0); } }
private void GetIllnesses() { illnesses.Clear(); illnesses = fachkonzept.GetIllnesses().ToList(); illnessBindingSource.DataSource = illnesses; illnessBindingSource.ResetBindings(false); // get matching patients for first illness Illness illness = illnesses.Count == 0 ? new Illness() : illnesses.First(); matchingPatients = fachkonzept.GetIllnessPatients(illness).ToList(); matchingPatientBindingSource.DataSource = matchingPatients; matchingPatientBindingSource.ResetBindings(false); }
public bool DeleteIllness(Illness illness) { int result = this.datenhaltung.GetIllnessPatientsCountData(illness); if (result == 0) { return(this.datenhaltung.DeleteIllnessData(illness)); } else if (result > 0) { // TODO create exception } return(false); }
private void createIllnessBtn_Click(object sender, EventArgs e) { Illness illness = new Illness(); if (fachkonzept.CreateIllness(illness)) { illnesses.Add(illness); illnessBindingSource.ResetBindings(false); dataGridView3.CurrentCell = dataGridView3.Rows[dataGridView3.Rows.Count - 1].Cells[1]; dataGridView3.BeginEdit(false); } else { MessageBox.Show("Krankheit konnte nicht angelegt werden.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool DeleteIllnessData(Illness illness) { if (illness.IllnessID > 0) { SQLiteCommand command = new SQLiteCommand( "DELETE FROM T_Illnesses WHERE illnessID = @illnessID", this.Connection ); command.Parameters.Add("@illnessID", DbType.Int64).Value = illness.IllnessID; return(this.ExecuteNonQuery(command) == 1 ? (illness.IllnessID = 0) == 0 : false); } else { return(false); } }
/* * Describe a Illness Row */ public string DescribeIllnessRow(Illness illness) { string row = illness.Name; if (illness.Contagious) { row += " : Contagious"; } if (illness.Curable) { row += " : Curable"; } if (illness.Lethal) { row += " : Lethal"; } return(row); }
public bool UnLinkPatientIllness(Patient patient, Illness illness) { if (patient.PatientID > 0 && illness.IllnessID > 0) { SQLiteCommand command = new SQLiteCommand( @"DELETE FROM T_PatientsIllnesses WHERE (patientID = @patientID) AND (illnessID = @illnessID)", this.Connection ); command.Parameters.Add("@patientID", DbType.Int64).Value = patient.PatientID; command.Parameters.Add("@illnessID", DbType.Int64).Value = illness.IllnessID; return(this.ExecuteNonQuery(command) == 1); } else { return(false); } }
public bool CreateIllnessData(Illness illness) { if (illness.IllnessID == 0) { SQLiteCommand command = new SQLiteCommand( @"INSERT INTO T_Illnesses (name, contagious, lethal, curable) VALUES (@name, @contagious, @lethal, @curable)", this.Connection ); command.Parameters.Add("@name", DbType.String).Value = illness.Name; command.Parameters.Add("@contagious", DbType.Boolean).Value = illness.Contagious; command.Parameters.Add("@lethal", DbType.Boolean).Value = illness.Lethal; command.Parameters.Add("@curable", DbType.Boolean).Value = illness.Curable; return(this.ExecuteNonQuery(command) == 1 ? (illness.IllnessID = this.GetLastInsertRowID()) > 0 : false); } else { return(false); } }
public bool UpdateIllnessData(Illness illness) { if (illness.IllnessID > 0) { SQLiteCommand command = new SQLiteCommand( @"UPDATE T_Illnesses SET name = @name, contagious = @contagious, lethal = @lethal, curable = @curable WHERE illnessID = @illnessID", this.Connection ); command.Parameters.Add("@name", DbType.String).Value = illness.Name; command.Parameters.Add("@contagious", DbType.Boolean).Value = illness.Contagious; command.Parameters.Add("@lethal", DbType.Boolean).Value = illness.Lethal; command.Parameters.Add("@curable", DbType.Boolean).Value = illness.Curable; command.Parameters.Add("@illnessID", DbType.Int64).Value = illness.IllnessID; return(this.ExecuteNonQuery(command) == 1); } else { return(false); } }
public int GetIllnessPatientsCountData(Illness illness) { throw new NotImplementedException(); }
public Patient[] GetIllnessPatientsData(Illness illness, int pager, int number) { throw new NotImplementedException(); }
public Patient[] GetIllnessPatientsData(Illness illness) { throw new NotImplementedException(); }
public bool UnLinkPatientIllness(Patient patient, Illness illness) { throw new NotImplementedException(); }
public bool DeleteIllnessData(Illness illness) { throw new NotImplementedException(); }
public bool DeleteIllness(Illness illness) { return(this.Datenhaltung.DeleteIllnessData(illness)); }
public bool UnLinkPatientIllness(Patient patient, Illness illness) { return(this.Datenhaltung.UnLinkPatientIllness(patient, illness)); }
public bool UpdateIllness(Illness illness) { return(this.Datenhaltung.UpdateIllnessData(illness)); }