コード例 #1
0
ファイル: RequestList.cs プロジェクト: thompsonx/vis_ordinace
 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();
        }