Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// Author 2015-09-10
        /// </summary>
        public bool Update(object tran, UsersRoleInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UsersRole set ");

            strSql.Append("UserID=@UserID,");
            strSql.Append("RoleID=@RoleID");
            strSql.Append(" where UserID=@UserID and RoleID=@RoleID  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID", SqlDbType.Int, 4),
                new SqlParameter("@RoleID", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.UserID;
            parameters[1].Value = model.RoleID;
            int rows = SQLHelper.ExecuteNonQuery((SqlTransaction)tran, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// Author 2015-09-10
        /// </summary>
        public bool Add(object tran, UsersRoleInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UsersRole(");
            strSql.Append("UserID,RoleID");
            strSql.Append(") values (");
            strSql.Append("@UserID,@RoleID");
            strSql.Append(") ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID", SqlDbType.Int, 4),
                new SqlParameter("@RoleID", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.UserID;
            parameters[1].Value = model.RoleID;
            int rows = SQLHelper.ExecuteNonQuery((SqlTransaction)tran, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public static UsersRoleInfo InsertVendorUser_User_Role(UsersRoleInfo entity)
        {
            DataCommand dc = DataCommandManager.GetDataCommand("Insert_VendorUser_Role");

            dc.SetParameterValue("@UserSysNo", entity.UserSysNo);
            dc.SetParameterValue("@RoleSysNo", entity.RoleSysNo);
            dc.ExecuteNonQuery();
            return(entity);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// Author 2015-09-10
        /// </summary>
        public UsersRoleInfo GetModel(object tran, int UserID, int RoleID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select UserID,RoleID ");
            strSql.Append(" from UsersRole ");
            strSql.Append(" where UserID=@UserID and RoleID=@RoleID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID", SqlDbType.Int, 4),
                new SqlParameter("@RoleID", SqlDbType.Int, 4)
            };
            parameters[0].Value = UserID;
            parameters[1].Value = RoleID;


            UsersRoleInfo model = new UsersRoleInfo();
            DataSet       ds    = SQLHelper.GetDataSet((SqlTransaction)tran, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["UserID"].ToString() != "")
                {
                    model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["RoleID"].ToString() != "")
                {
                    model.RoleID = int.Parse(ds.Tables[0].Rows[0]["RoleID"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// Author 2015-09-10
 /// </summary>
 public bool Update(object tran, UsersRoleInfo model)
 {
     return(dal.Update(tran, model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// Author 2015-09-10
 /// </summary>
 public bool Add(object tran, UsersRoleInfo model)
 {
     return(dal.Add(tran, model));
 }