示例#1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJS.Model.Role GetModel(int RoleId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select RoleId, IsDeleted, RoleName, RoleType, RoleStatus, Remark, CreateId, CreateDate, EditId, EditDate,IsManager  ");
            strSql.Append("  from Role ");
            strSql.Append(" where RoleId=@RoleId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleId", SqlDbType.Int, 4)
            };
            parameters[0].Value = RoleId;


            BWJS.Model.Role model = new BWJS.Model.Role();
            DataSet         ds    = BWJSHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJS.Model.Role model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [Role] set ");

            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" RoleName = @RoleName , ");
            strSql.Append(" RoleType = @RoleType , ");
            strSql.Append(" RoleStatus = @RoleStatus , ");
            strSql.Append(" ParentId = @ParentId , ");
            strSql.Append(" Remark = @Remark , ");
            strSql.Append(" EditId = @EditId , ");
            strSql.Append(" EditDate = @EditDate, ");
            strSql.Append(" IsManager = @IsManager   ");
            strSql.Append(" where RoleId=@RoleId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleId",     model.RoleId),
                new SqlParameter("@IsDeleted",  model.IsDeleted),
                new SqlParameter("@RoleName",   model.RoleName),
                new SqlParameter("@RoleType",   model.RoleType),
                new SqlParameter("@RoleStatus", model.RoleStatus),
                new SqlParameter("@Remark",     model.Remark),
                new SqlParameter("@ParentId",   model.ParentId),
                new SqlParameter("@IsManager",  model.IsManager),
                new SqlParameter("@EditId",     model.EditId),
                new SqlParameter("@EditDate",   model.EditDate)
            };

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJS.Model.Role model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Role(");
            strSql.Append("IsDeleted,RoleName,RoleType,RoleStatus,Remark,CreateId,CreateDate,EditId,EditDate,ParentId,IsManager");
            strSql.Append(") values (");
            strSql.Append("@IsDeleted,@RoleName,@RoleType,@RoleStatus,@Remark,@CreateId,@CreateDate,@EditId,@EditDate,@ParentId,@IsManager");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@IsDeleted",  model.IsDeleted),
                new SqlParameter("@RoleName",   model.RoleName),
                new SqlParameter("@RoleType",   model.RoleType),
                new SqlParameter("@RoleStatus", model.RoleStatus),
                new SqlParameter("@Remark",     model.Remark),
                new SqlParameter("@CreateId",   model.CreateId),
                new SqlParameter("@CreateDate", model.CreateDate),
                new SqlParameter("@EditId",     model.EditId),
                new SqlParameter("@ParentId",   model.ParentId),
                new SqlParameter("@IsManager",  model.IsManager),
                new SqlParameter("@EditDate",   model.EditDate)
            };


            object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#4
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJS.Model.Role DataRowToModel(DataRow row)
        {
            BWJS.Model.Role model = new BWJS.Model.Role();

            if (row != null)
            {
                if (row["RoleId"].ToString() != "")
                {
                    model.RoleId = int.Parse(row["RoleId"].ToString());
                }
                if (row["IsDeleted"].ToString() != "")
                {
                    model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
                }
                model.RoleName = row["RoleName"].ToString();
                if (row["RoleType"].ToString() != "")
                {
                    model.RoleType = int.Parse(row["RoleType"].ToString());
                }
                if (row["RoleStatus"].ToString() != "")
                {
                    model.RoleStatus = int.Parse(row["RoleStatus"].ToString());
                }
                model.Remark = row["Remark"].ToString();
                if (row["CreateId"].ToString() != "")
                {
                    model.CreateId = int.Parse(row["CreateId"].ToString());
                }
                if (row["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                }
                if (row["EditId"].ToString() != "")
                {
                    model.EditId = int.Parse(row["EditId"].ToString());
                }
                if (row["EditDate"].ToString() != "")
                {
                    model.EditDate = DateTime.Parse(row["EditDate"].ToString());
                }
                if (row["IsManager"].ToString() == "1" || row["IsManager"].ToString() == "true")
                {
                    model.IsManager = true;
                }
                if (row["IsManager"].ToString() != "")
                {
                    if ((row["IsManager"].ToString() == "1") || (row["IsManager"].ToString() == "true"))
                    {
                        model.IsManager = true;
                    }
                    else
                    {
                        model.IsManager = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BWJS.Model.Role model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(BWJS.Model.Role model)
 {
     return(dal.Add(model));
 }