Пример #1
0
        public async Task GetDoctorByNameAsync(string name, string location, IDoctorCallback callback)
        {
            if (DBHandler.db == null)
            {
                DBHandler.DBConnection();
            }
            List <Doctor> results = new List <Doctor>();

            try
            {
                results = await DBHandler.db.QueryAsync <Doctor>(String.Format("SELECT * FROM DOCTOR " +
                                                                               "WHERE NAME LIKE '{1}%' AND ID IN (" +
                                                                               "SELECT DOC_ID FROM ROSTER WHERE HOSP_ID IN(" +
                                                                               "SELECT ID FROM HOSPITAL WHERE LOCATION='{0}')" +
                                                                               ")", location, name));

                System.Diagnostics.Debug.WriteLine("Results val=" + results.Count);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Dept loc select exception " + e.Message);
            }
            if (results != null)
            {
                callback.ReadSuccess(results);
            }
            else
            {
                callback.ReadFail();
            }
        }
Пример #2
0
        //IDoctorCallback doctorCallback;
        public async Task GetDoctorsAsync(IDoctorCallback doctorCallback)
        {
            List <Doctor> results = new List <Doctor>();

            try
            {
                //var db = await dbHandler.DBConnection();
                if (DBHandler.db == null)
                {
                    DBHandler.DBConnection();
                }
                results = await DBHandler.db.QueryAsync <Doctor>(
                    "SELECT * FROM DOCTOR ");

                System.Diagnostics.Debug.WriteLine("results=" + results.Count());
                if (results != null)
                {
                    doctorCallback.ReadSuccess(results);
                    await DBHandler.db.CloseAsync();
                }
                else
                {
                    doctorCallback.ReadFail();
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("DOCTOR ASYNC SELECT EXCEPTION" + e.Message);
            }
        }
Пример #3
0
        public async Task GetDoctorByDeptLocationAsync(string location, int dept, IDoctorCallback doctorCallback,
                                                       int lexp = -1, int uexp = 200, int rating = -1)
        {
            if (DBHandler.db == null)
            {
                DBHandler.DBConnection();
            }
            List <Doctor> results = new List <Doctor>();

            try
            {
                if (dept > 0)
                {
                    results = await DBHandler.db.QueryAsync <Doctor>(String.Format("SELECT * FROM DOCTOR " +
                                                                                   "WHERE ID IN (" +
                                                                                   "SELECT DOC_ID FROM ROSTER WHERE HOSP_ID IN(" +
                                                                                   "SELECT ID FROM HOSPITAL WHERE LOCATION='{0}')" +
                                                                                   ")" +
                                                                                   "AND DEPT_ID ={1} AND EXPERIENCE >= {2} AND EXPERIENCE <= {3} AND RATING >= {4}", location, dept, lexp, uexp, rating));
                }
                else
                {
                    results = await DBHandler.db.QueryAsync <Doctor>(String.Format("SELECT * FROM DOCTOR " +
                                                                                   "WHERE ID IN (" +
                                                                                   "SELECT DOC_ID FROM ROSTER WHERE HOSP_ID IN(" +
                                                                                   "SELECT ID FROM HOSPITAL WHERE LOCATION='{0}')" +
                                                                                   ")" +
                                                                                   " AND EXPERIENCE >= {2} AND EXPERIENCE <= {3} AND RATING >= {4}", location, dept, lexp, uexp, rating));
                }
                System.Diagnostics.Debug.WriteLine("Results val=" + results.Count);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Dept loc select exception " + e.Message);
            }
            if (results != null)
            {
                doctorCallback.ReadSuccess(results);
                await DBHandler.db.CloseAsync();
            }
            else
            {
                doctorCallback.ReadFail();
            }
        }
Пример #4
0
        public async Task GetDoctorByHospitalNameAsync(string name, IDoctorCallback doctorCallback)
        {
            if (DBHandler.db == null)
            {
                DBHandler.DBConnection();
            }
            List <Doctor> results = await DBHandler.
                                    db.QueryAsync <Doctor>(String.Format("SELECT * FROM DOCTOR WHERE ID IN (" +
                                                                         "SELECT DOC_ID FROM ROSTER WHERE HOSP_ID IN (" +
                                                                         "SELECT ID FROM HOSPITAL WHERE NAME='{0}'))", name));

            System.Diagnostics.Debug.WriteLine("Hosp name " + results.Count());

            if (results != null)
            {
                doctorCallback.ReadSuccess(results);
                await DBHandler.db.CloseAsync();
            }
            else
            {
                doctorCallback.ReadFail();
            }
        }