/// <summary> /// 得到一个对象实体 /// </summary> public WTCJ.Model.Sys_User DataRowToModel(DataRow row) { WTCJ.Model.Sys_User model = new WTCJ.Model.Sys_User(); if (row != null) { if (row["UserID"] != null) { model.UserID = row["UserID"].ToString(); } if (row["LoginID"] != null) { model.LoginID = row["LoginID"].ToString(); } if (row["UserName"] != null) { model.UserName = row["UserName"].ToString(); } if (row["Sex"] != null) { model.Sex = row["Sex"].ToString(); } if (row["Mobile"] != null) { model.Mobile = row["Mobile"].ToString(); } if (row["EMail"] != null) { model.EMail = row["EMail"].ToString(); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["Password"] != null) { model.Password = row["Password"].ToString(); } if (row["IsValid"] != null) { model.IsValid = row["IsValid"].ToString(); } if (row["IsEmployee"] != null) { model.IsEmployee = row["IsEmployee"].ToString(); } if (row["OuID"] != null) { model.OuID = row["OuID"].ToString(); } if (row["OuType"] != null) { model.OuType = row["OuType"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WTCJ.Model.Sys_User model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Sys_User set "); strSql.Append("LoginID=@LoginID,"); strSql.Append("UserName=@UserName,"); strSql.Append("Sex=@Sex,"); strSql.Append("Mobile=@Mobile,"); strSql.Append("EMail=@EMail,"); strSql.Append("Remark=@Remark,"); strSql.Append("Password=@Password,"); strSql.Append("IsValid=@IsValid,"); strSql.Append("IsEmployee=@IsEmployee,"); strSql.Append("OuID=@OuID,"); strSql.Append("OuType=@OuType"); strSql.Append(" where UserID=@UserID "); SqlParameter[] parameters = { new SqlParameter("@LoginID", SqlDbType.VarChar, 50), new SqlParameter("@UserName", SqlDbType.VarChar, 50), new SqlParameter("@Sex", SqlDbType.VarChar, 50), new SqlParameter("@Mobile", SqlDbType.VarChar, 50), new SqlParameter("@EMail", SqlDbType.VarChar, 150), new SqlParameter("@Remark", SqlDbType.VarChar, 550), new SqlParameter("@Password", SqlDbType.VarChar, 100), new SqlParameter("@IsValid", SqlDbType.VarChar, 1), new SqlParameter("@IsEmployee", SqlDbType.VarChar, 1), new SqlParameter("@OuID", SqlDbType.VarChar, 50), new SqlParameter("@OuType", SqlDbType.VarChar, 50), new SqlParameter("@UserID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.LoginID; parameters[1].Value = model.UserName; parameters[2].Value = model.Sex; parameters[3].Value = model.Mobile; parameters[4].Value = model.EMail; parameters[5].Value = model.Remark; parameters[6].Value = model.Password; parameters[7].Value = model.IsValid; parameters[8].Value = model.IsEmployee; parameters[9].Value = model.OuID; parameters[10].Value = model.OuType; parameters[11].Value = model.UserID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(WTCJ.Model.Sys_User model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Sys_User("); strSql.Append("UserID,LoginID,UserName,Sex,Mobile,EMail,Remark,Password,IsValid,IsEmployee,OuID,OuType)"); strSql.Append(" values ("); strSql.Append("@UserID,@LoginID,@UserName,@Sex,@Mobile,@EMail,@Remark,@Password,@IsValid,@IsEmployee,@OuID,@OuType)"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.VarChar, 50), new SqlParameter("@LoginID", SqlDbType.VarChar, 50), new SqlParameter("@UserName", SqlDbType.VarChar, 50), new SqlParameter("@Sex", SqlDbType.VarChar, 50), new SqlParameter("@Mobile", SqlDbType.VarChar, 50), new SqlParameter("@EMail", SqlDbType.VarChar, 150), new SqlParameter("@Remark", SqlDbType.VarChar, 550), new SqlParameter("@Password", SqlDbType.VarChar, 100), new SqlParameter("@IsValid", SqlDbType.VarChar, 1), new SqlParameter("@IsEmployee", SqlDbType.VarChar, 1), new SqlParameter("@OuID", SqlDbType.VarChar, 50), new SqlParameter("@OuType", SqlDbType.VarChar, 50) }; parameters[0].Value = model.UserID; parameters[1].Value = model.LoginID; parameters[2].Value = model.UserName; parameters[3].Value = model.Sex; parameters[4].Value = model.Mobile; parameters[5].Value = model.EMail; parameters[6].Value = model.Remark; parameters[7].Value = model.Password; parameters[8].Value = model.IsValid; parameters[9].Value = model.IsEmployee; parameters[10].Value = model.OuID; parameters[11].Value = model.OuType; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WTCJ.Model.Sys_User GetModel(string UserID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 UserID,LoginID,UserName,Sex,Mobile,EMail,Remark,Password,IsValid,IsEmployee,OuID,OuType from Sys_User "); strSql.Append(" where UserID=@UserID "); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.VarChar, 50) }; parameters[0].Value = UserID; WTCJ.Model.Sys_User model = new WTCJ.Model.Sys_User(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }