예제 #1
0
파일: SYS_Role.cs 프로젝트: kkwkk/ybyzt
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 private Hi.Model.SYS_Role GetModel(DataRow r)
 {
     Hi.Model.SYS_Role model = new Hi.Model.SYS_Role();
     model.ID           = SqlHelper.GetInt(r["ID"]);
     model.CompID       = SqlHelper.GetInt(r["CompID"]);
     model.DisID        = SqlHelper.GetInt(r["DisID"]);
     model.RoleName     = SqlHelper.GetString(r["RoleName"]);
     model.Remark       = SqlHelper.GetString(r["Remark"]);
     model.SortIndex    = SqlHelper.GetString(r["SortIndex"]);
     model.IsEnabled    = SqlHelper.GetInt(r["IsEnabled"]);
     model.CreateUserID = SqlHelper.GetInt(r["CreateUserID"]);
     model.CreateDate   = SqlHelper.GetDateTime(r["CreateDate"]);
     model.ts           = SqlHelper.GetDateTime(r["ts"]);
     model.dr           = SqlHelper.GetInt(r["dr"]);
     model.modifyuser   = SqlHelper.GetInt(r["modifyuser"]);
     return(model);
 }
예제 #2
0
파일: SYS_Role.cs 프로젝트: kkwkk/ybyzt
        /// <summary>
        /// 增加一条数据 带有事物
        /// </summary>
        public int Add(Hi.Model.SYS_Role model, SqlTransaction Tran)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [SYS_Role](");
            strSql.Append("[CompID],[DisID],[RoleName],[Remark],[SortIndex],[IsEnabled],[CreateUserID],[CreateDate],[ts],[modifyuser])");
            strSql.Append(" values (");
            strSql.Append("@CompID,@DisID,@RoleName,@Remark,@SortIndex,@IsEnabled,@CreateUserID,@CreateDate,@ts,@modifyuser)");
            strSql.Append(";select @@Identity");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CompID",       SqlDbType.Int),
                new SqlParameter("@DisID",        SqlDbType.Int),
                new SqlParameter("@RoleName",     SqlDbType.VarChar,    50),
                new SqlParameter("@Remark",       SqlDbType.VarChar,   500),
                new SqlParameter("@SortIndex",    SqlDbType.VarChar,    50),
                new SqlParameter("@IsEnabled",    SqlDbType.Int),
                new SqlParameter("@CreateUserID", SqlDbType.Int),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime),
                new SqlParameter("@ts",           SqlDbType.DateTime),
                new SqlParameter("@modifyuser",   SqlDbType.Int)
            };
            parameters[0].Value = model.CompID;

            parameters[1].Value = model.DisID;

            if (model.RoleName != null)
            {
                parameters[2].Value = model.RoleName;
            }
            else
            {
                parameters[2].Value = DBNull.Value;
            }


            if (model.Remark != null)
            {
                parameters[3].Value = model.Remark;
            }
            else
            {
                parameters[3].Value = DBNull.Value;
            }


            if (model.SortIndex != null)
            {
                parameters[4].Value = model.SortIndex;
            }
            else
            {
                parameters[4].Value = DBNull.Value;
            }

            parameters[5].Value = model.IsEnabled;
            parameters[6].Value = model.CreateUserID;

            if (model.CreateDate != DateTime.MinValue)
            {
                parameters[7].Value = model.CreateDate;
            }
            else
            {
                parameters[7].Value = DBNull.Value;
            }


            if (model.ts != DateTime.MinValue)
            {
                parameters[8].Value = model.ts;
            }
            else
            {
                parameters[8].Value = DBNull.Value;
            }

            parameters[9].Value = model.modifyuser;
            if (Tran != null)
            {
                return(SqlHelper.GetInt(SqlHelper.GetSingle(strSql.ToString(), Tran, parameters)));
            }
            return(SqlHelper.GetInt(SqlHelper.GetSingle(SqlHelper.LocalSqlServer, strSql.ToString(), parameters)));
        }
예제 #3
0
파일: SYS_Role.cs 프로젝트: kkwkk/ybyzt
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hi.Model.SYS_Role model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [SYS_Role] set ");
            strSql.Append("[CompID]=@CompID,");
            strSql.Append("[DisID]=@DisID,");
            strSql.Append("[RoleName]=@RoleName,");
            strSql.Append("[Remark]=@Remark,");
            strSql.Append("[SortIndex]=@SortIndex,");
            strSql.Append("[IsEnabled]=@IsEnabled,");
            strSql.Append("[CreateUserID]=@CreateUserID,");
            strSql.Append("[CreateDate]=@CreateDate,");
            strSql.Append("[ts]=@ts,");
            strSql.Append("[dr]=@dr,");
            strSql.Append("[modifyuser]=@modifyuser");
            strSql.Append(" where [ID]=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.Int),
                new SqlParameter("@CompID",       SqlDbType.Int),
                new SqlParameter("@DisID",        SqlDbType.Int),
                new SqlParameter("@RoleName",     SqlDbType.VarChar,    50),
                new SqlParameter("@Remark",       SqlDbType.VarChar,   500),
                new SqlParameter("@SortIndex",    SqlDbType.VarChar,    50),
                new SqlParameter("@IsEnabled",    SqlDbType.Int),
                new SqlParameter("@CreateUserID", SqlDbType.Int),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime),
                new SqlParameter("@ts",           SqlDbType.DateTime),
                new SqlParameter("@dr",           SqlDbType.SmallInt),
                new SqlParameter("@modifyuser",   SqlDbType.Int)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.CompID;
            parameters[2].Value = model.DisID;

            if (model.RoleName != null)
            {
                parameters[3].Value = model.RoleName;
            }
            else
            {
                parameters[3].Value = DBNull.Value;
            }


            if (model.Remark != null)
            {
                parameters[4].Value = model.Remark;
            }
            else
            {
                parameters[4].Value = DBNull.Value;
            }


            if (model.SortIndex != null)
            {
                parameters[5].Value = model.SortIndex;
            }
            else
            {
                parameters[5].Value = DBNull.Value;
            }

            parameters[6].Value = model.IsEnabled;
            parameters[7].Value = model.CreateUserID;

            if (model.CreateDate != DateTime.MinValue)
            {
                parameters[8].Value = model.CreateDate;
            }
            else
            {
                parameters[8].Value = DBNull.Value;
            }


            if (model.ts != DateTime.MinValue)
            {
                parameters[9].Value = model.ts;
            }
            else
            {
                parameters[9].Value = DBNull.Value;
            }

            parameters[10].Value = model.dr;
            parameters[11].Value = model.modifyuser;

            return(SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString(), parameters) > 0);
        }
예제 #4
0
파일: SYS_Role.cs 프로젝트: kkwkk/ybyzt
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.SYS_Role model, System.Data.SqlClient.SqlTransaction Tran)
 {
     return(dal.Add(model, Tran));
 }