Esempio n. 1
0
        public RoleInfo GetRoleByName(string roleName)
        {
            RoleDal dal = new RoleDal();

            DataSet ds = dal.GetRoleByName(roleName);
            RoleInfo roleInfo = new RoleInfo();
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                roleInfo = ConvertToModel(ds.Tables[0].Rows[0]);
            }

            return roleInfo;
        }
Esempio n. 2
0
        public void AddRole(RoleInfo roleInfo)
        {
            string sql = "insert into U_RoleInfo(RoleName,Introduction)values(@RoleName,@Introduction)";

            List<SqlParameter> lstParamter = new List<SqlParameter>();

            SqlParameter paramter = new SqlParameter("@RoleName", roleInfo.RoleName);
            lstParamter.Add(paramter);
            paramter = new SqlParameter("@Introduction", roleInfo.Introduction);
            lstParamter.Add(paramter);

            SQLHelp.ExecuteNonQuery(sql, lstParamter);
        }
Esempio n. 3
0
        public void UpdateRole(RoleInfo roleInfo)
        {
            string sql = "update U_RoleInfo set RoleName=@RoleName,Introduction=@Introduction where RoleId=@RoleId";

            List<SqlParameter> lstParamter = new List<SqlParameter>();

            SqlParameter paramter = new SqlParameter("@RoleName", roleInfo.RoleName);
            lstParamter.Add(paramter);
            paramter = new SqlParameter("@Introduction", roleInfo.Introduction);
            lstParamter.Add(paramter);
            paramter = new SqlParameter("@RoleId", roleInfo.RoleId);
            lstParamter.Add(paramter);
            SQLHelp.ExecuteNonQuery(sql, lstParamter);
        }
Esempio n. 4
0
        public void UpdateRole(RoleInfo roleInfo)
        {
            RoleDal dal = new RoleDal();

            dal.UpdateRole(roleInfo);
        }
Esempio n. 5
0
        public void AddRole(RoleInfo roleInfo)
        {
            RoleDal dal = new RoleDal();

            dal.AddRole(roleInfo);
        }
Esempio n. 6
0
        private RoleInfo ConvertToModel(DataRow dr)
        {
            RoleInfo roleInfo = new RoleInfo();

            if(dr!=null)
            {
                if (dr["RoleId"] is DBNull == false)
                {
                    int roleId = 0;
                    int.TryParse(dr["RoleId"].ToString(), out roleId);
                    roleInfo.RoleId = roleId;
                }

                if (dr["RoleName"] is DBNull == false)
                {
                    roleInfo.RoleName = dr["RoleName"].ToString();
                }

                if (dr["Introduction"] is DBNull == false)
                {
                    roleInfo.Introduction = dr["Introduction"].ToString();
                }
            }
            return roleInfo;
        }
        private RoleInfo GetModel()
        {
            RoleInfo roleInfo = new RoleInfo();

            roleInfo.RoleName = txtRoleName.Text.Trim();
            roleInfo.Introduction = txtRoleName.Text.Trim();

            return roleInfo;
        }