예제 #1
0
        public static List <UnitModel> GetManageListByUserCode(string userCode, SqlConnection sqlConn)
        {
            List <UnitModel>    list    = new List <UnitModel>();
            UnitModel           item    = new UnitModel();
            DataSet             dataSet = new DataSet();
            ConferenceManageDAL edal    = new ConferenceManageDAL(sqlConn);
            string     cmdText          = "Select UnitCode,UnitName from Unit \r\n                                Where ParentUnitCode=\r\n                                (Select AccessRangeUnitCode from Station \r\n                                Where StationCode = (Select StationCode from UserRole Where UserCode=@UserCode))";
            SqlCommand selectCommand    = new SqlCommand(cmdText, sqlConn);

            selectCommand.Parameters.Add("@UserCode", SqlDbType.VarChar, 50).Value = userCode;
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);

            using (SqlConnection connection = sqlConn)
            {
                try
                {
                    sqlConn.Open();
                    adapter.Fill(dataSet);
                }
                catch (SqlException)
                {
                }
            }
            if (dataSet != null)
            {
                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    item          = new UnitModel();
                    item.UnitCode = row["UnitCode"].ToString();
                    item.UnitName = row["UnitName"].ToString();
                    list.Add(item);
                }
            }
            return(list);
        }
예제 #2
0
        public static List <UnitModel> GetAllDepts(SqlConnection sqlConn)
        {
            List <UnitModel>    list     = new List <UnitModel>();
            UnitModel           item     = new UnitModel();
            DataSet             dataSet  = new DataSet();
            ConferenceManageDAL edal     = new ConferenceManageDAL(sqlConn);
            string         cmdText       = "Select UnitCode,UnitName from Unit";
            SqlCommand     selectCommand = new SqlCommand(cmdText, sqlConn);
            SqlDataAdapter adapter       = new SqlDataAdapter(selectCommand);

            using (SqlConnection connection = sqlConn)
            {
                try
                {
                    sqlConn.Open();
                    adapter.Fill(dataSet);
                }
                catch (SqlException)
                {
                }
            }
            if (dataSet != null)
            {
                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    item          = new UnitModel();
                    item.UnitCode = row["UnitCode"].ToString();
                    item.UnitName = row["UnitName"].ToString();
                    list.Add(item);
                }
            }
            return(list);
        }