/// <summary> /// 增加一条数据 /// </summary> public int Add(BCW.BQC.Model.BQCList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_BQCList("); strSql.Append("CID,Match,Team_Home,Team_Away,Start_time,Score,Result,State,PayCent,PayCount,EndTime,other,Sale_StartTime,nowprize,nextprize,sysprize,sysprizestatue,sysdayprize)"); strSql.Append(" values ("); strSql.Append("@CID,@Match,@Team_Home,@Team_Away,@Start_time,@Score,@Result,@State,@PayCent,@PayCount,@EndTime,@other,@Sale_StartTime,@nowprize,@nextprize,@sysprize,@sysprizestatue,@sysdayprize)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CID", SqlDbType.Int, 4), new SqlParameter("@Match", SqlDbType.NVarChar, 300), new SqlParameter("@Team_Home", SqlDbType.NVarChar, 300), new SqlParameter("@Team_Away", SqlDbType.NVarChar, 300), new SqlParameter("@Start_time", SqlDbType.NVarChar, 300), new SqlParameter("@Score", SqlDbType.NVarChar, 300), new SqlParameter("@Result", SqlDbType.NVarChar, 100), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@PayCent", SqlDbType.BigInt, 8), new SqlParameter("@PayCount", SqlDbType.Int, 4), new SqlParameter("@EndTime", SqlDbType.DateTime), new SqlParameter("@other", SqlDbType.NChar, 10), new SqlParameter("@Sale_StartTime", SqlDbType.DateTime), new SqlParameter("@nowprize", SqlDbType.BigInt, 8), new SqlParameter("@nextprize", SqlDbType.BigInt, 8), new SqlParameter("@sysprize", SqlDbType.BigInt, 8), new SqlParameter("@sysprizestatue", SqlDbType.Int, 4), new SqlParameter("@sysdayprize", SqlDbType.BigInt, 8) }; parameters[0].Value = model.CID; parameters[1].Value = model.Match; parameters[2].Value = model.Team_Home; parameters[3].Value = model.Team_Away; parameters[4].Value = model.Start_time; parameters[5].Value = model.Score; parameters[6].Value = model.Result; parameters[7].Value = model.State; parameters[8].Value = model.PayCent; parameters[9].Value = model.PayCount; parameters[10].Value = model.EndTime; parameters[11].Value = model.other; parameters[12].Value = model.Sale_StartTime; parameters[13].Value = model.nowprize; parameters[14].Value = model.nextprize; parameters[15].Value = model.sysprize; parameters[16].Value = model.sysprizestatue; parameters[17].Value = model.sysdayprize; object obj = SqlHelper.GetSingle(strSql.ToString(), parameters); return(Convert.ToInt32(obj)); }
/// <summary> /// 取得每页记录 /// </summary> /// <param name="p_pageIndex">当前页</param> /// <param name="p_pageSize">分页大小</param> /// <param name="p_recordCount">返回总记录数</param> /// <param name="strWhere">查询条件</param> /// <returns>IList BQCList</returns> public IList <BCW.BQC.Model.BQCList> GetBQCLists(int p_pageIndex, int p_pageSize, string strWhere, out int p_recordCount) { IList <BCW.BQC.Model.BQCList> listBQCLists = new List <BCW.BQC.Model.BQCList>(); string sTable = "tb_BQCList"; string sPkey = "id"; string sField = "CID,Match,Team_Home,Team_Away,Start_time,Score,Result,State,PayCent,PayCount,EndTime,other,Sale_StartTime,id,nowprize,nextprize,sysprize,sysprizestatue,sysdayprize"; string sCondition = strWhere; string sOrder = "CID Desc"; int iSCounts = 0; using (SqlDataReader reader = SqlHelper.RunProcedureMe(sTable, sPkey, sField, p_pageIndex, p_pageSize, sCondition, sOrder, iSCounts, out p_recordCount)) { //计算总页数 if (p_recordCount > 0) { int pageCount = BasePage.CalcPageCount(p_recordCount, p_pageSize, ref p_pageIndex); } else { return(listBQCLists); } while (reader.Read()) { BCW.BQC.Model.BQCList objBQCList = new BCW.BQC.Model.BQCList(); objBQCList.CID = reader.GetInt32(0); objBQCList.Match = reader.GetString(1); objBQCList.Team_Home = reader.GetString(2); objBQCList.Team_Away = reader.GetString(3); objBQCList.Start_time = reader.GetString(4); objBQCList.Score = reader.GetString(5); objBQCList.Result = reader.GetString(6); objBQCList.State = reader.GetInt32(7); objBQCList.PayCent = reader.GetInt64(8); objBQCList.PayCount = reader.GetInt32(9); objBQCList.EndTime = reader.GetDateTime(10); objBQCList.other = reader.GetString(11); objBQCList.Sale_StartTime = reader.GetDateTime(12); objBQCList.id = reader.GetInt32(13); objBQCList.nowprize = reader.GetInt64(14); objBQCList.nextprize = reader.GetInt64(15); objBQCList.sysprize = reader.GetInt64(16); objBQCList.sysprizestatue = reader.GetInt32(17); objBQCList.sysdayprize = reader.GetInt64(18); listBQCLists.Add(objBQCList); } } return(listBQCLists); }
/// <summary> /// 得到一个对象实体 /// </summary> public BCW.BQC.Model.BQCList GetBQCList(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 CID,Match,Team_Home,Team_Away,Start_time,Score,Result,State,PayCent,PayCount,EndTime,other,Sale_StartTime,id,nowprize,nextprize,sysprize,sysprizestatue,sysdayprize from tb_BQCList "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; BCW.BQC.Model.BQCList model = new BCW.BQC.Model.BQCList(); using (SqlDataReader reader = SqlHelper.ExecuteReader(strSql.ToString(), parameters)) { if (reader.HasRows) { reader.Read(); model.CID = reader.GetInt32(0); model.Match = reader.GetString(1); model.Team_Home = reader.GetString(2); model.Team_Away = reader.GetString(3); model.Start_time = reader.GetString(4); model.Score = reader.GetString(5); model.Result = reader.GetString(6); model.State = reader.GetInt32(7); model.PayCent = reader.GetInt64(8); model.PayCount = reader.GetInt32(9); model.EndTime = reader.GetDateTime(10); model.other = reader.GetString(11); model.Sale_StartTime = reader.GetDateTime(12); model.id = reader.GetInt32(13); model.nowprize = reader.GetInt64(14); model.nextprize = reader.GetInt64(15); model.sysprize = reader.GetInt64(16); model.sysprizestatue = reader.GetInt32(17); model.sysdayprize = reader.GetInt64(18); return(model); } else { return(null); } } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(BCW.BQC.Model.BQCList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_BQCList set "); strSql.Append("CID=@CID,"); strSql.Append("Match=@Match,"); strSql.Append("Team_Home=@Team_Home,"); strSql.Append("Team_Away=@Team_Away,"); strSql.Append("Start_time=@Start_time,"); strSql.Append("Score=@Score,"); strSql.Append("Result=@Result,"); strSql.Append("State=@State,"); strSql.Append("PayCent=@PayCent,"); strSql.Append("PayCount=@PayCount,"); strSql.Append("EndTime=@EndTime,"); strSql.Append("other=@other,"); strSql.Append("Sale_StartTime=@Sale_StartTime,"); strSql.Append("nowprize=@nowprize,"); strSql.Append("nextprize=@nextprize,"); strSql.Append("sysprize=@sysprize,"); strSql.Append("sysprizestatue=@sysprizestatue,"); strSql.Append("sysdayprize=@sysdayprize"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@CID", SqlDbType.Int, 4), new SqlParameter("@Match", SqlDbType.NVarChar, 300), new SqlParameter("@Team_Home", SqlDbType.NVarChar, 300), new SqlParameter("@Team_Away", SqlDbType.NVarChar, 300), new SqlParameter("@Start_time", SqlDbType.NVarChar, 300), new SqlParameter("@Score", SqlDbType.NVarChar, 300), new SqlParameter("@Result", SqlDbType.NVarChar, 100), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@PayCent", SqlDbType.BigInt, 8), new SqlParameter("@PayCount", SqlDbType.Int, 4), new SqlParameter("@EndTime", SqlDbType.DateTime), new SqlParameter("@other", SqlDbType.NChar, 10), new SqlParameter("@Sale_StartTime", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@nowprize", SqlDbType.BigInt, 8), new SqlParameter("@nextprize", SqlDbType.BigInt, 8), new SqlParameter("@sysprize", SqlDbType.BigInt, 8), new SqlParameter("@sysprizestatue", SqlDbType.Int, 4), new SqlParameter("@sysdayprize", SqlDbType.BigInt, 8) }; parameters[0].Value = model.CID; parameters[1].Value = model.Match; parameters[2].Value = model.Team_Home; parameters[3].Value = model.Team_Away; parameters[4].Value = model.Start_time; parameters[5].Value = model.Score; parameters[6].Value = model.Result; parameters[7].Value = model.State; parameters[8].Value = model.PayCent; parameters[9].Value = model.PayCount; parameters[10].Value = model.EndTime; parameters[11].Value = model.other; parameters[12].Value = model.Sale_StartTime; parameters[13].Value = model.id; parameters[14].Value = model.nowprize; parameters[15].Value = model.nextprize; parameters[16].Value = model.sysprize; parameters[17].Value = model.sysprizestatue; parameters[18].Value = model.sysdayprize; SqlHelper.ExecuteSql(strSql.ToString(), parameters); }