/// <summary> /// 增加一条数据 /// </summary> public void Add(SeoWebSite.Model.Schedule model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Schedule("); strSql.Append("id,data,updated,date,home,away,halfhome,halfaway,h_teamid,g_teamid,scheduleTypeID)"); strSql.Append(" values ("); strSql.Append("@id,@data,@updated,@date,@home,@away,@halfhome,@halfaway,@h_teamid,@g_teamid,@scheduleTypeID)"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 8), new SqlParameter("@data", SqlDbType.NVarChar, 1000), new SqlParameter("@updated", SqlDbType.Bit, 1), new SqlParameter("@date", SqlDbType.Date, 3), new SqlParameter("@home", SqlDbType.Int, 4), new SqlParameter("@away", SqlDbType.Int, 4), new SqlParameter("@halfhome", SqlDbType.Int, 4), new SqlParameter("@halfaway", SqlDbType.Int, 4), new SqlParameter("@h_teamid", SqlDbType.Int, 4), new SqlParameter("@g_teamid", SqlDbType.Int, 4), new SqlParameter("@scheduleTypeID", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.data; parameters[2].Value = model.updated; parameters[3].Value = model.date; parameters[4].Value = model.home; parameters[5].Value = model.away; parameters[6].Value = model.halfhome; parameters[7].Value = model.halfaway; parameters[8].Value = model.h_teamid; parameters[9].Value = model.g_teamid; parameters[10].Value = model.scheduleTypeID; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个有数据未分析对象实体 /// </summary> public SeoWebSite.Model.Schedule GetTopOne_NoExp() { StringBuilder strSql = new StringBuilder(); strSql.Append("select top(1) s.* from Schedule s where s.ScheduleID in (select o.scheduleid from odds1x2history o where o.scheduleid=s.ScheduleID) and not exists (select b.id from BetExp b where b.id=s.ScheduleID)"); SeoWebSite.Model.Schedule model = new SeoWebSite.Model.Schedule(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); 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]["sclassid"].ToString() != "") { model.sclassid = int.Parse(ds.Tables[0].Rows[0]["sclassid"].ToString()); } model.data = ds.Tables[0].Rows[0]["Data"].ToString(); if (ds.Tables[0].Rows[0]["Date"].ToString() != "") { model.date = DateTime.Parse(ds.Tables[0].Rows[0]["Date"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SeoWebSite.Model.Schedule GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,data,updated,date,home,away,halfhome,halfaway from Schedule "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; SeoWebSite.Model.Schedule model = new SeoWebSite.Model.Schedule(); 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()); } model.data = ds.Tables[0].Rows[0]["data"].ToString(); if (ds.Tables[0].Rows[0]["updated"].ToString() != "") { if ((ds.Tables[0].Rows[0]["updated"].ToString() == "1") || (ds.Tables[0].Rows[0]["updated"].ToString().ToLower() == "true")) { model.updated = true; } else { model.updated = false; } } if (ds.Tables[0].Rows[0]["date"].ToString() != "") { model.date = DateTime.Parse(ds.Tables[0].Rows[0]["date"].ToString()); } if (ds.Tables[0].Rows[0]["home"].ToString() != "") { model.home = int.Parse(ds.Tables[0].Rows[0]["home"].ToString()); } if (ds.Tables[0].Rows[0]["away"].ToString() != "") { model.away = int.Parse(ds.Tables[0].Rows[0]["away"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SeoWebSite.Model.Schedule model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Schedule set "); strSql.Append("data=@data,"); strSql.Append("updated=@updated,"); strSql.Append("date=@date,"); strSql.Append("home=@home,"); strSql.Append("away=@away"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@data", SqlDbType.NVarChar, 1000), new SqlParameter("@updated", SqlDbType.Bit, 1), new SqlParameter("@date", SqlDbType.Date, 3), new SqlParameter("@home", SqlDbType.Int, 4), new SqlParameter("@away", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.data; parameters[2].Value = model.updated; parameters[3].Value = model.date; parameters[4].Value = model.home; parameters[5].Value = model.away; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public SeoWebSite.Model.Schedule GetModel(int id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 id,data,updated,date,home,away,halfhome,halfaway from Schedule "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; SeoWebSite.Model.Schedule model=new SeoWebSite.Model.Schedule(); 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()); } model.data=ds.Tables[0].Rows[0]["data"].ToString(); if(ds.Tables[0].Rows[0]["updated"].ToString()!="") { if((ds.Tables[0].Rows[0]["updated"].ToString()=="1")||(ds.Tables[0].Rows[0]["updated"].ToString().ToLower()=="true")) { model.updated=true; } else { model.updated=false; } } if(ds.Tables[0].Rows[0]["date"].ToString()!="") { model.date=DateTime.Parse(ds.Tables[0].Rows[0]["date"].ToString()); } if(ds.Tables[0].Rows[0]["home"].ToString()!="") { model.home=int.Parse(ds.Tables[0].Rows[0]["home"].ToString()); } if(ds.Tables[0].Rows[0]["away"].ToString()!="") { model.away=int.Parse(ds.Tables[0].Rows[0]["away"].ToString()); } return model; } else { return null; } }
/// <summary> /// �õ�һ��������δ��������ʵ�� /// </summary> public SeoWebSite.Model.Schedule GetTopOne_NoExp() { StringBuilder strSql = new StringBuilder(); strSql.Append("select top(1) s.* from Schedule s where s.ScheduleID in (select o.scheduleid from odds1x2history o where o.scheduleid=s.ScheduleID) and not exists (select b.id from BetExp b where b.id=s.ScheduleID)"); SeoWebSite.Model.Schedule model = new SeoWebSite.Model.Schedule(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); 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]["sclassid"].ToString() != "") { model.sclassid = int.Parse(ds.Tables[0].Rows[0]["sclassid"].ToString()); } model.data = ds.Tables[0].Rows[0]["Data"].ToString(); if (ds.Tables[0].Rows[0]["Date"].ToString() != "") { model.date = DateTime.Parse(ds.Tables[0].Rows[0]["Date"].ToString()); } return model; } else { return null; } }