Exemplo n.º 1
0
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 private Hi.Model.SYS_Users GetModel(DataRow r)
 {
     Hi.Model.SYS_Users model = new Hi.Model.SYS_Users();
     model.ID            = SqlHelper.GetInt(r["ID"]);
     model.CompID        = SqlHelper.GetInt(r["CompID"]);
     model.DisID         = SqlHelper.GetInt(r["DisID"]);
     model.Type          = SqlHelper.GetInt(r["Type"]);
     model.OpenID        = SqlHelper.GetString(r["OpenID"]);
     model.AddType       = SqlHelper.GetInt(r["AddType"]);
     model.RoleID        = SqlHelper.GetInt(r["RoleID"]);
     model.UserName      = SqlHelper.GetString(r["UserName"]);
     model.UserPwd       = SqlHelper.GetString(r["UserPwd"]);
     model.UserLoginName = SqlHelper.GetString(r["UserLoginName"]);
     model.TrueName      = SqlHelper.GetString(r["TrueName"]);
     model.Sex           = SqlHelper.GetString(r["Sex"]);
     model.Phone         = SqlHelper.GetString(r["Phone"]);
     model.Tel           = SqlHelper.GetString(r["Tel"]);
     model.Identitys     = SqlHelper.GetString(r["Identitys"]);
     model.Address       = SqlHelper.GetString(r["Address"]);
     model.Email         = SqlHelper.GetString(r["Email"]);
     model.AuditState    = SqlHelper.GetInt(r["AuditState"]);
     model.AuditUser     = SqlHelper.GetString(r["AuditUser"]);
     model.IsFirst       = SqlHelper.GetInt(r["IsFirst"]);
     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);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.SYS_Users model, System.Data.SqlClient.SqlTransaction Tran)
 {
     return(dal.Update(model, Tran));
 }
Exemplo n.º 3
0
 public int Add(Hi.Model.SYS_Users model, System.Data.SqlClient.SqlTransaction Tran)
 {
     return(dal.Add(model, Tran));
 }
Exemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hi.Model.SYS_Users model, SqlTransaction Tran)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [SYS_Users] set ");
            strSql.Append("[CompID]=@CompID,");
            strSql.Append("[DisID]=@DisID,");
            strSql.Append("[Type]=@Type,");
            strSql.Append("[OpenID]=@OpenID,");
            strSql.Append("[AddType]=@AddType,");
            strSql.Append("[RoleID]=@RoleID,");
            strSql.Append("[UserName]=@UserName,");
            strSql.Append("[UserPwd]=@UserPwd,");
            strSql.Append("[UserLoginName]=@UserLoginName,");
            strSql.Append("[TrueName]=@TrueName,");
            strSql.Append("[Sex]=@Sex,");
            strSql.Append("[Phone]=@Phone,");
            strSql.Append("[Tel]=@Tel,");
            strSql.Append("[Identitys]=@Identitys,");
            strSql.Append("[Address]=@Address,");
            strSql.Append("[Email]=@Email,");
            strSql.Append("[AuditState]=@AuditState,");
            strSql.Append("[AuditUser]=@AuditUser,");
            strSql.Append("[IsFirst]=@IsFirst,");
            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("@Type",          SqlDbType.Int),
                new SqlParameter("@OpenID",        SqlDbType.VarChar,    50),
                new SqlParameter("@AddType",       SqlDbType.Int),
                new SqlParameter("@RoleID",        SqlDbType.Int),
                new SqlParameter("@UserName",      SqlDbType.VarChar,    50),
                new SqlParameter("@UserPwd",       SqlDbType.VarChar,    50),
                new SqlParameter("@UserLoginName", SqlDbType.VarChar,    50),
                new SqlParameter("@TrueName",      SqlDbType.VarChar,    50),
                new SqlParameter("@Sex",           SqlDbType.VarChar,    50),
                new SqlParameter("@Phone",         SqlDbType.VarChar,    50),
                new SqlParameter("@Tel",           SqlDbType.VarChar,    50),
                new SqlParameter("@Identitys",     SqlDbType.VarChar,    50),
                new SqlParameter("@Address",       SqlDbType.VarChar,   200),
                new SqlParameter("@Email",         SqlDbType.VarChar,    50),
                new SqlParameter("@AuditState",    SqlDbType.Int),
                new SqlParameter("@AuditUser",     SqlDbType.VarChar,    50),
                new SqlParameter("@IsFirst",       SqlDbType.Int),
                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;
            parameters[3].Value = model.Type;

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

            parameters[5].Value = model.AddType;
            parameters[6].Value = model.RoleID;

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


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


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


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


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


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


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


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


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


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

            parameters[17].Value = model.AuditState;

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

            parameters[19].Value = model.IsFirst;
            parameters[20].Value = model.IsEnabled;
            parameters[21].Value = model.CreateUserID;

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


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

            parameters[24].Value = model.dr;
            parameters[25].Value = model.modifyuser;

            if (Tran != null)
            {
                return(SqlHelper.ExecuteSql(strSql.ToString(), Tran, parameters) > 0);
            }
            return(SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString(), parameters) > 0);
        }
Exemplo n.º 5
0
        public int Add(Hi.Model.SYS_Users model, SqlTransaction Tran)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [SYS_Users](");
            strSql.Append("[CompID],[DisID],[Type],[OpenID],[AddType],[RoleID],[UserName],[UserPwd],[UserLoginName],[TrueName],[Sex],[Phone],[Tel],[Identitys],[Address],[Email],[AuditState],[AuditUser],[IsFirst],[IsEnabled],[CreateUserID],[CreateDate],[ts],[modifyuser])");
            strSql.Append(" values (");
            strSql.Append("@CompID,@DisID,@Type,@OpenID,@AddType,@RoleID,@UserName,@UserPwd,@UserLoginName,@TrueName,@Sex,@Phone,@Tel,@Identitys,@Address,@Email,@AuditState,@AuditUser,@IsFirst,@IsEnabled,@CreateUserID,@CreateDate,@ts,@modifyuser)");
            strSql.Append(";select @@Identity");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CompID",        SqlDbType.Int),
                new SqlParameter("@DisID",         SqlDbType.Int),
                new SqlParameter("@Type",          SqlDbType.Int),
                new SqlParameter("@OpenID",        SqlDbType.VarChar,    50),
                new SqlParameter("@AddType",       SqlDbType.Int),
                new SqlParameter("@RoleID",        SqlDbType.Int),
                new SqlParameter("@UserName",      SqlDbType.VarChar,    50),
                new SqlParameter("@UserPwd",       SqlDbType.VarChar,    50),
                new SqlParameter("@UserLoginName", SqlDbType.VarChar,    50),
                new SqlParameter("@TrueName",      SqlDbType.VarChar,    50),
                new SqlParameter("@Sex",           SqlDbType.VarChar,    50),
                new SqlParameter("@Phone",         SqlDbType.VarChar,    50),
                new SqlParameter("@Tel",           SqlDbType.VarChar,    50),
                new SqlParameter("@Identitys",     SqlDbType.VarChar,    50),
                new SqlParameter("@Address",       SqlDbType.VarChar,   200),
                new SqlParameter("@Email",         SqlDbType.VarChar,    50),
                new SqlParameter("@AuditState",    SqlDbType.Int),
                new SqlParameter("@AuditUser",     SqlDbType.VarChar,    50),
                new SqlParameter("@IsFirst",       SqlDbType.Int),
                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;
            parameters[2].Value = model.Type;

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

            parameters[4].Value = model.AddType;
            parameters[5].Value = model.RoleID;

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


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


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


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


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


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


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


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


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


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

            parameters[16].Value = model.AuditState;

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

            parameters[18].Value = model.IsFirst;
            parameters[19].Value = model.IsEnabled;
            parameters[20].Value = model.CreateUserID;

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


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

            parameters[23].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)));
        }