public void Delete(ExaminationType e)
        {
            IDatabase db = new MSSqlDatabase();
            db.Connect();

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

            db.ExecuteNonQuery(command);

            db.Close();
        }
Пример #2
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();
        }
Пример #3
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();
        }
        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();
        }
Пример #5
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();
        }
Пример #6
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();
        }