示例#1
0
        /// <summary>
        /// 取得所有主管ID(Employee.ManagerID)
        /// </summary>
        /// <returns></returns>
        public List <SelectListItem> GetManagerID()
        {
            DataTable dt  = new DataTable();
            string    sql = @"Select Distinct FirstName + LastName AS CodeVal, EmployeeID AS CodeId 
                            From HR.Employees";

            using (SqlConnection conn = new SqlConnection(this.GetDBConnectionString()))
            {
                conn.Open();
                SqlCommand     cmd        = new SqlCommand(sql, conn);
                SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd);
                sqlAdapter.Fill(dt);
                conn.Close();
            }
            return(TableFactory.Table2SelectListItem(dt));
        }
示例#2
0
        /// <summary>
        /// 取得所有職稱(Employee.Title)
        /// </summary>
        /// <returns></returns>
        public List <SelectListItem> GetTitle()
        {
            DataTable dt  = new DataTable();
            string    sql = @"Select Distinct CodeVal, CodeId 
                            From CodeTable
                            WHERE CodeType = 'TITLE'";

            using (SqlConnection conn = new SqlConnection(this.GetDBConnectionString()))
            {
                conn.Open();
                SqlCommand     cmd        = new SqlCommand(sql, conn);
                SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd);
                sqlAdapter.Fill(dt);
                conn.Close();
            }
            return(TableFactory.Table2SelectListItem(dt));
        }