コード例 #1
0
        public void InsertRequest(string p_id, Request r)
        {
            Prescription er = (Prescription)r;
            if (er.Medicines.Count == 0)
            {
                throw new ApplicationException(ErrorMessages.Messages["REQ_P_medicines"]);
            }

            IDatabase db = new MSSqlDatabase();
            db.Connect();

            db.BeginTransaction();

            DbCommand command = db.CreateCommand(sqlINSERT);
            PrepareCommand(db, command, er, p_id);
            er.Id = db.ExecuteScalar(command);

            int added = this.InsertMedicines(er, db);

            db.EndTransaction();

            if (added != er.Medicines.Count)
            {
                db.Rollback();
            }

            db.Close();
        }
コード例 #2
0
        public void InsertRequest(string p_id, Request r)
        {
            SampleRequest er = (SampleRequest)r;
            IDatabase db = new MSSqlDatabase();
            db.Connect();

            DbCommand command = db.CreateCommand(sqlINSERT);
            PrepareCommand(db, command, er);
            er.Id = db.ExecuteScalar(command);

            db.Close();
        }
コード例 #3
0
        public void DeleteRequest(Request r)
        {
            SampleRequest er = (SampleRequest)r;
            IDatabase db = new MSSqlDatabase();
            db.Connect();

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

            db.ExecuteNonQuery(command);

            db.Close();
        }
コード例 #4
0
        public void DeleteRequest(Request r)
        {
            Prescription er = (Prescription)r;
            IDatabase db = new MSSqlDatabase();
            db.Connect();

            db.BeginTransaction();

            this.DeleteMedicines(er);

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

            db.ExecuteNonQuery(command);

            db.EndTransaction();

            db.Close();
        }
コード例 #5
0
 public void InsertRequest(string p_id, Request r)
 {
     if (r is Prescription)
     {
         PrescriptionMapper pm = new PrescriptionMapper();
         pm.InsertRequest(p_id, r);
     }
     else if (r is ExaminationRequest)
     {
         ExaminationRequestMapper erm = new ExaminationRequestMapper();
         erm.InsertRequest(p_id, r);
     }
     else if (r is SampleRequest)
     {
         SampleRequestMapper srm = new SampleRequestMapper();
         srm.InsertRequest(p_id, r);
     }
     else
     {
         throw new ApplicationException(ErrorMessages.Messages["REQ_type"]);
     }
 }
コード例 #6
0
        public void UpdateRequest(Request r)
        {
            ExaminationRequest er = (ExaminationRequest)r;
            IDatabase db = new MSSqlDatabase();
            db.Connect();

            DbCommand command = db.CreateCommand(sqlUPDATE);
            PrepareCommand(db, command, er);
            command.Parameters.Add(db.CreateParameter("@id", "int"));
            command.Parameters["@id"].Value = er.Id;
            db.ExecuteNonQuery(command);

            db.Close();
        }
コード例 #7
0
        public void UpdateRequest(Request r)
        {
            Prescription er = (Prescription)r;
            IDatabase db = new MSSqlDatabase();
            db.Connect();

            db.BeginTransaction();

            DbCommand command = db.CreateCommand(sqlUPDATE);
            command.Parameters.Add(db.CreateParameter("@date", "datetime"));
            command.Parameters["@date"].Value = er.Created;
            command.Parameters.Add(db.CreateParameter("@id", "int"));
            command.Parameters["@id"].Value = er.Id;
            db.ExecuteNonQuery(command);

            this.DeleteMedicines(er);
            int added = this.InsertMedicines(er, db);

            db.EndTransaction();

            if (added != er.Medicines.Count)
            {
                db.Rollback();
            }

            db.Close();
        }