예제 #1
0
 private void bCreate_Click(object sender, EventArgs e)
 {
     this.rForm = new RequestForm();
     if (rForm.ShowDialog(this) == DialogResult.OK)
     {
         Prescription p = new Prescription();
         p.Created = rForm.Date;
         rForm.Medicines.ForEach(m => p.Add(m));
         try
         {
             this.service.AddPrescription(this.patient, p);
             this.prescriptionBindingSource.Insert(0, p);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
예제 #2
0
 public void AddPrescription(Patient p, Prescription pres)
 {
     pm.InsertRequest(p, pres);
 }
예제 #3
0
 public void RemovePrescription(Prescription p)
 {
     pm.DeleteRequest(p);
 }
예제 #4
0
        private List<Request> Read(DbDataReader reader, IDatabase db)
        {
            List<Request> requests = new List<Request>();
            MedicineMapper medcat = MedicineMapper.GetInstance();

            while (reader.Read())
            {
                Prescription er = new Prescription();
                er.Id = reader.GetInt32(0);
                er.Created = reader.GetDateTime(1);

                DbCommand command = db.CreateCommand(sqlSELECTMEDICINE);
                command.Parameters.Add(db.CreateParameter("@id", "int"));
                command.Parameters["@id"].Value = er.Id;
                DbDataReader medicines = db.Select(command);
                er.Medicines = this.ReadMedicines(medicines, medcat);

                medicines.Close();

                requests.Add(er);
            }

            return requests;
        }
예제 #5
0
        private void PrepareCommand(IDatabase db, DbCommand cmd, Prescription er, string p_id)
        {
            cmd.Parameters.Add(db.CreateParameter("@date", "datetime"));
            cmd.Parameters["@date"].Value = er.Created;

            cmd.Parameters.Add(db.CreateParameter("@person", "char", p_id.Length));
            cmd.Parameters["@person"].Value = p_id;
        }
예제 #6
0
        private int InsertMedicines(Prescription p, IDatabase db)
        {
            int added = 0;
            DbCommand command;

            foreach (Medicine m in p.Medicines)
            {
                command = db.CreateCommand(sqlINSERTMEDICINE);
                command.Parameters.Add(db.CreateParameter("@id", "int"));
                command.Parameters["@id"].Value = p.Id;

                command.Parameters.Add(db.CreateParameter("@medicineid", "int"));
                command.Parameters["@medicineid"].Value = m.Id;

                added += db.ExecuteNonQuery(command);
            }

            return added;
        }
예제 #7
0
        private void DeleteMedicines(Prescription p)
        {
            IDatabase db = new MSSqlDatabase();
            db.Connect();

            DbCommand command = db.CreateCommand(sqlDELETEMEDICINES);
            command.Parameters.Add(db.CreateParameter("@id", "int"));
            command.Parameters["@id"].Value = p.Id;

            db.ExecuteNonQuery(command);

            db.Close();
        }