コード例 #1
0
        public int GetStaffTypeByUsername(string userName)
        {
            var loginAdapter = new staff_credentialsTableAdapter();

            try
            {
                using (loginAdapter)
                {
                    var staffCredentialsRow =
                        loginAdapter.GetData().FirstOrDefault(login => login.username.Equals(userName));
                    if (staffCredentialsRow != null)
                    {
                        var id           = staffCredentialsRow.staff_staffID;
                        var staffadapter = new staffTableAdapter();
                        using (staffadapter)
                        {
                            var staffRow = staffadapter.GetData().FirstOrDefault(staff => staff.staffID == id);
                            if (staffRow != null)
                            {
                                return(staffRow.staffType);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(-1);
            }
            return(-1);
        }
コード例 #2
0
        public string GetNameByUsername(string userName)
        {
            var loginAdapter = new staff_credentialsTableAdapter();

            try
            {
                using (loginAdapter)
                {
                    var staffCredentialsRow =
                        loginAdapter.GetData().FirstOrDefault(login => login.username.Equals(userName));
                    if (staffCredentialsRow != null)
                    {
                        var id           = staffCredentialsRow.staff_staffID;
                        var staffadapter = new staffTableAdapter();
                        using (staffadapter)
                        {
                            var staffRow = staffadapter.GetData().FirstOrDefault(staff => staff.staffID == id);
                            if (staffRow != null)
                            {
                                return(staffRow.firstName + " " + staffRow.lastName);
                            }
                        }
                    }
                }
                return(null);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #3
0
        /// <summary>
        ///     Gets all patients.
        /// </summary>
        /// <returns>All patients</returns>
        public IList <Staff> GetAll()
        {
            var staffList = new List <Staff>();
            var adapter   = new staffTableAdapter();

            try
            {
                using (adapter)
                {
                    foreach (var row in adapter.GetData().Rows)
                    {
                        var staff = this.getStaffFromRow((cs3230f16bDataSet.staffRow)row);
                        staffList.Add(staff);
                    }
                }
                return(staffList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #4
0
        internal List <Staff> GetNurses()
        {
            var staffList = new List <Staff>();
            var adapter   = new staffTableAdapter();

            try
            {
                using (adapter)
                {
                    var nurses = adapter.GetData().Where(st => st.staffType == 2);
                    foreach (var nurse in nurses)
                    {
                        var staff = this.getStaffFromRow(nurse);
                        staffList.Add(staff);
                    }
                }
                return(staffList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #5
0
        internal List <Staff> GetDoctors()
        {
            var staffList = new List <Staff>();
            var adapter   = new staffTableAdapter();

            try
            {
                using (adapter)
                {
                    var doctors = adapter.GetData().Where(st => st.staffType == 3);
                    foreach (var doctor in doctors)
                    {
                        var staff = this.getStaffFromRow(doctor);
                        staffList.Add(staff);
                    }
                }
                return(staffList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #6
0
        /// <summary>
        ///     Gets the patient by patientID.
        /// </summary>
        /// <param name="id">The patientID.</param>
        /// <returns>Patient with specified patientID</returns>
        public Staff GetById(int id)
        {
            var adapter = new staffTableAdapter();

            try
            {
                using (adapter)
                {
                    try
                    {
                        var staff = adapter.GetData().First(st => st.staffID == id);
                        return(this.getStaffFromRow(staff));
                    }
                    catch (Exception)
                    {
                        return(null);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }