/// <summary> /// 更新一条数据 /// </summary> public bool Update(SchSystem.Model.SchUserRoleXXT model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SchUserRoleXXT set "); strSql.Append("RoleID=@RoleID,"); strSql.Append("UserName=@UserName,"); strSql.Append("RecTime=@RecTime,"); strSql.Append("RecUser=@RecUser,"); strSql.Append("LastRecTime=@LastRecTime,"); strSql.Append("LastRecUser=@LastRecUser,"); strSql.Append("SchId=@SchId"); strSql.Append(" where AutoId=@AutoId"); SqlParameter[] parameters = { new SqlParameter("@RoleID", SqlDbType.Int, 4), new SqlParameter("@UserName", SqlDbType.VarChar, 20), new SqlParameter("@RecTime", SqlDbType.SmallDateTime), new SqlParameter("@RecUser", SqlDbType.VarChar, 50), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@AutoId", SqlDbType.Int, 4) }; parameters[0].Value = model.RoleID; parameters[1].Value = model.UserName; parameters[2].Value = model.RecTime; parameters[3].Value = model.RecUser; parameters[4].Value = model.LastRecTime; parameters[5].Value = model.LastRecUser; parameters[6].Value = model.SchId; parameters[7].Value = model.AutoId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchUserRoleXXT DataRowToModel(DataRow row) { SchSystem.Model.SchUserRoleXXT model = new SchSystem.Model.SchUserRoleXXT(); if (row != null) { if (row["AutoId"] != null && row["AutoId"].ToString() != "") { model.AutoId = int.Parse(row["AutoId"].ToString()); } if (row["RoleID"] != null && row["RoleID"].ToString() != "") { model.RoleID = int.Parse(row["RoleID"].ToString()); } if (row["UserName"] != null) { model.UserName = row["UserName"].ToString(); } if (row["RecTime"] != null && row["RecTime"].ToString() != "") { model.RecTime = DateTime.Parse(row["RecTime"].ToString()); } if (row["RecUser"] != null) { model.RecUser = row["RecUser"].ToString(); } if (row["LastRecTime"] != null && row["LastRecTime"].ToString() != "") { model.LastRecTime = DateTime.Parse(row["LastRecTime"].ToString()); } if (row["LastRecUser"] != null) { model.LastRecUser = row["LastRecUser"].ToString(); } if (row["SchId"] != null && row["SchId"].ToString() != "") { model.SchId = int.Parse(row["SchId"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SchSystem.Model.SchUserRoleXXT model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SchUserRoleXXT("); strSql.Append("RoleID,UserName,RecTime,RecUser,LastRecTime,LastRecUser,SchId)"); strSql.Append(" values ("); strSql.Append("@RoleID,@UserName,@RecTime,@RecUser,@LastRecTime,@LastRecUser,@SchId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@RoleID", SqlDbType.Int, 4), new SqlParameter("@UserName", SqlDbType.VarChar, 20), new SqlParameter("@RecTime", SqlDbType.SmallDateTime), new SqlParameter("@RecUser", SqlDbType.VarChar, 50), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20), new SqlParameter("@SchId", SqlDbType.Int, 4) }; parameters[0].Value = model.RoleID; parameters[1].Value = model.UserName; parameters[2].Value = model.RecTime; parameters[3].Value = model.RecUser; parameters[4].Value = model.LastRecTime; parameters[5].Value = model.LastRecUser; parameters[6].Value = model.SchId; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchUserRoleXXT GetModel(int AutoId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 AutoId,RoleID,UserName,RecTime,RecUser,LastRecTime,LastRecUser,SchId from SchUserRoleXXT "); strSql.Append(" where AutoId=@AutoId"); SqlParameter[] parameters = { new SqlParameter("@AutoId", SqlDbType.Int, 4) }; parameters[0].Value = AutoId; SchSystem.Model.SchUserRoleXXT model = new SchSystem.Model.SchUserRoleXXT(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }