Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CtlDBAccess.Model.User_ListModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update User_List set ");
            strSql.Append("UserPassWord=@UserPassWord,");
            strSql.Append("RoleID=@RoleID");
            strSql.Append(" where UserName=@UserName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserPassWord", SqlDbType.NVarChar, 50),
                new SqlParameter("@RoleID",       SqlDbType.Int,       4),
                new SqlParameter("@UserID",       SqlDbType.Int,       4),
                new SqlParameter("@UserName",     SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.UserPassWord;
            parameters[1].Value = model.RoleID;
            parameters[2].Value = model.UserID;
            parameters[3].Value = model.UserName;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CtlDBAccess.Model.User_ListModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into User_List(");
            strSql.Append("UserName,UserPassWord,RoleID)");
            strSql.Append(" values (");
            strSql.Append("@UserName,@UserPassWord,@RoleID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName",     SqlDbType.NVarChar, 50),
                new SqlParameter("@UserPassWord", SqlDbType.NVarChar, 50),
                new SqlParameter("@RoleID",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.UserPassWord;
            parameters[2].Value = model.RoleID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CtlDBAccess.Model.User_ListModel DataRowToModel(DataRow row)
 {
     CtlDBAccess.Model.User_ListModel model = new CtlDBAccess.Model.User_ListModel();
     if (row != null)
     {
         if (row["UserID"] != null && row["UserID"].ToString() != "")
         {
             model.UserID = int.Parse(row["UserID"].ToString());
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["UserPassWord"] != null)
         {
             model.UserPassWord = row["UserPassWord"].ToString();
         }
         if (row["RoleID"] != null && row["RoleID"].ToString() != "")
         {
             model.RoleID = int.Parse(row["RoleID"].ToString());
         }
     }
     return(model);
 }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CtlDBAccess.Model.User_ListModel GetModel(string UserName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 UserID,UserName,UserPassWord,RoleID from User_List ");
            strSql.Append(" where UserName=@UserName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = UserName;

            CtlDBAccess.Model.User_ListModel model = new CtlDBAccess.Model.User_ListModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(CtlDBAccess.Model.User_ListModel model)
 {
     return(dal.Update(model));
 }
Example #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(CtlDBAccess.Model.User_ListModel model)
 {
     return(dal.Add(model));
 }