/// <summary> /// 增加一条数据 /// </summary> public int Add(ROYcms.Sys.Model.ROYcms_New_User model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + PubConstant.date_prefix + "New_User("); strSql.Append("New_id,User_id,Time)"); strSql.Append(" values ("); strSql.Append("@New_id,@User_id,@Time)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@New_id", SqlDbType.Int, 4), new SqlParameter("@User_id", SqlDbType.Int, 4), new SqlParameter("@Time", SqlDbType.DateTime) }; parameters[0].Value = model.New_id; parameters[1].Value = model.User_id; parameters[2].Value = model.Time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ROYcms.Sys.Model.ROYcms_New_User GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,New_id,User_id,Time from " + PubConstant.date_prefix + "New_User "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; ROYcms.Sys.Model.ROYcms_New_User model = new ROYcms.Sys.Model.ROYcms_New_User(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["New_id"].ToString() != "") { model.New_id = int.Parse(ds.Tables[0].Rows[0]["New_id"].ToString()); } if (ds.Tables[0].Rows[0]["User_id"].ToString() != "") { model.User_id = int.Parse(ds.Tables[0].Rows[0]["User_id"].ToString()); } if (ds.Tables[0].Rows[0]["Time"].ToString() != "") { model.Time = DateTime.Parse(ds.Tables[0].Rows[0]["Time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(ROYcms.Sys.Model.ROYcms_New_User model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + PubConstant.date_prefix + "New_User set "); strSql.Append("New_id=@New_id,"); strSql.Append("User_id=@User_id,"); strSql.Append("Time=@Time"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@New_id", SqlDbType.Int, 4), new SqlParameter("@User_id", SqlDbType.Int, 4), new SqlParameter("@Time", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.New_id; parameters[2].Value = model.User_id; parameters[3].Value = model.Time; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }