コード例 #1
0
 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);
     }
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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]);
     }
 }
コード例 #4
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);
            }
        }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
 public bool LinkPatientIllness(Patient patient, Illness illness)
 {
     if (patient.PatientID == 80 || illness.IllnessID == 80)
     {
         return(false);
     }
     return(true);
 }
コード例 #7
0
 public bool UpdateIllness(Illness illness)
 {
     if (illness.Name == "error")
     {
         return(false);
     }
     return(true);
 }
コード例 #8
0
 public bool DeleteIllness(Illness illness)
 {
     if (illness.IllnessID == 40)
     {
         return(false);
     }
     return(true);
 }
コード例 #9
0
 public bool CreateIllness(Illness illness)
 {
     if (illness.Name == "error")
     {
         return(false);
     }
     illness.IllnessID = 99;
     return(true);
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 public bool CreateIllness(Illness illness)
 {
     if (this.Datenhaltung.CreateIllnessData(illness))
     {
         return((this.IllnessCache[illness.IllnessID] = illness) != null);
     }
     else
     {
         return(false);
     }
 }
コード例 #12
0
        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);
        }
コード例 #13
0
        public bool DeleteIllness(Illness illness)
        {
            long illnessID = illness.IllnessID;

            if (this.Datenhaltung.DeleteIllnessData(illness))
            {
                return(this.IllnessCache.Remove(illnessID) || true);
            }
            else
            {
                return(false);
            }
        }
コード例 #14
0
 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);
     }
 }
コード例 #15
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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
0
 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);
     }
 }
コード例 #19
0
        /*
         * 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);
        }
コード例 #20
0
 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);
     }
 }
コード例 #21
0
 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);
     }
 }
コード例 #22
0
 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);
     }
 }
コード例 #23
0
 public int GetIllnessPatientsCountData(Illness illness)
 {
     throw new NotImplementedException();
 }
コード例 #24
0
 public Patient[] GetIllnessPatientsData(Illness illness, int pager, int number)
 {
     throw new NotImplementedException();
 }
コード例 #25
0
 public Patient[] GetIllnessPatientsData(Illness illness)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
 public bool UnLinkPatientIllness(Patient patient, Illness illness)
 {
     throw new NotImplementedException();
 }
コード例 #27
0
 public bool DeleteIllnessData(Illness illness)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
 public bool DeleteIllness(Illness illness)
 {
     return(this.Datenhaltung.DeleteIllnessData(illness));
 }
コード例 #29
0
 public bool UnLinkPatientIllness(Patient patient, Illness illness)
 {
     return(this.Datenhaltung.UnLinkPatientIllness(patient, illness));
 }
コード例 #30
0
 public bool UpdateIllness(Illness illness)
 {
     return(this.Datenhaltung.UpdateIllnessData(illness));
 }