Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Bitshare.DataDecision.Model.tblUser_Roles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tblUser_Roles(");
            strSql.Append("LoginName,Role_Id,Remark,IsDefault)");
            strSql.Append(" values (");
            strSql.Append("@LoginName,@Role_Id,@Remark,@IsDefault)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LoginName", SqlDbType.VarChar,  50),
                new SqlParameter("@Role_Id",   SqlDbType.Int,       4),
                new SqlParameter("@Remark",    SqlDbType.VarChar, 500),
                new SqlParameter("@IsDefault", SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.LoginName;
            parameters[1].Value = model.Role_Id;
            parameters[2].Value = model.Remark;
            parameters[3].Value = model.IsDefault;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Bitshare.DataDecision.Model.tblUser_Roles DataRowToModel(DataRow row)
 {
     Bitshare.DataDecision.Model.tblUser_Roles model = new Bitshare.DataDecision.Model.tblUser_Roles();
     if (row != null)
     {
         if (row["Rid"] != null && row["Rid"].ToString() != "")
         {
             model.Rid = int.Parse(row["Rid"].ToString());
         }
         if (row["LoginName"] != null)
         {
             model.LoginName = row["LoginName"].ToString();
         }
         if (row["Role_Id"] != null && row["Role_Id"].ToString() != "")
         {
             model.Role_Id = int.Parse(row["Role_Id"].ToString());
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
         if (row["IsDefault"] != null)
         {
             model.IsDefault = Convert.ToBoolean(row["IsDefault"]);
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Bitshare.DataDecision.Model.tblUser_Roles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tblUser_Roles set ");
            strSql.Append("LoginName=@LoginName,");
            strSql.Append("Role_Id=@Role_Id,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("IsDefault=@IsDefault");
            strSql.Append(" where Rid=@Rid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LoginName", SqlDbType.VarChar,  50),
                new SqlParameter("@Role_Id",   SqlDbType.Int,       4),
                new SqlParameter("@Remark",    SqlDbType.VarChar, 500),
                new SqlParameter("@IsDefault", SqlDbType.Bit,       1),
                new SqlParameter("@Rid",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.LoginName;
            parameters[1].Value = model.Role_Id;
            parameters[2].Value = model.Remark;
            parameters[3].Value = model.IsDefault;
            parameters[4].Value = model.Rid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Bitshare.DataDecision.Model.tblUser_Roles GetModel(int Rid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Rid,LoginName,Role_Id,Remark,IsDefault from tblUser_Roles ");
            strSql.Append(" where Rid=@Rid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Rid", SqlDbType.Int, 4)
            };
            parameters[0].Value = Rid;

            Bitshare.DataDecision.Model.tblUser_Roles model = new Bitshare.DataDecision.Model.tblUser_Roles();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Bitshare.DataDecision.Model.tblUser_Roles model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Bitshare.DataDecision.Model.tblUser_Roles model)
 {
     return(dal.Add(model));
 }