public static LotteryResult GetLotteryResult(string cpCode, int status, string btime, string etime, string orderasc = "asc")
        {
            string sqlwhere = " where  b.cpCode='" + cpCode + "'";

            if (status > -1)
            {
                sqlwhere += " and b.Status=" + status;
            }

            if (!string.IsNullOrEmpty(btime))
            {
                sqlwhere += " and b.opentime>='" + btime + "'";
            }
            if (!string.IsNullOrEmpty(etime))
            {
                sqlwhere += " and b.opentime<='" + etime + " 23:59:59:999'";
            }

            DataTable     dt    = LotteryResultDAL.GetDataTable("select top 1 *  from  LotteryResult (nolock) b " + sqlwhere + " Order by AutoID " + orderasc);
            LotteryResult model = new LotteryResult();

            foreach (DataRow dr in dt.Rows)
            {
                model.FillData(dr);
            }
            return(model);
        }
        public static List <LotteryResult> GetPagList(string cpCode, int status, bool orderby, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string btime = "", string etime = "")
        {
            string sqlwhere = " b.cpCode='" + cpCode + "'";

            if (status > -1)
            {
                sqlwhere += " and b.Status=" + status;
            }
            if (!string.IsNullOrEmpty(btime))
            {
                sqlwhere += " and b.CreateTime>='" + btime + "'";
            }
            if (!string.IsNullOrEmpty(etime))
            {
                sqlwhere += " and b.CreateTime<='" + etime + " 23:59:59:999'";
            }
            DataTable dt = CommonBusiness.GetPagerData(" LotteryResult (nolock) b ",
                                                       "b.*", sqlwhere, "b.AutoID ", pageSize, pageIndex,
                                                       out totalCount, out pageCount, orderby);
            List <LotteryResult> list = new List <LotteryResult>();

            foreach (DataRow dr in dt.Rows)
            {
                LotteryResult model = new LotteryResult();
                model.FillData(dr);
                list.Add(model);
            }
            return(list);
        }
        public static LotteryResult GetOpenLottery(string cpcode, string sqlwhere, int top = 1)
        {
            DataTable     dt    = LotteryResultDAL.BaseProvider.GetOpenLottery(cpcode, sqlwhere, top);
            LotteryResult model = new LotteryResult();

            foreach (DataRow dr in dt.Rows)
            {
                model.FillData(dr);
            }
            return(model);
        }
        public static LotteryResult GetNowLottery(string cpcode)
        {
            DataTable     dt    = LotteryResultDAL.BaseProvider.GetNowLottery(cpcode);
            LotteryResult model = new LotteryResult();

            foreach (DataRow dr in dt.Rows)
            {
                model.FillData(dr);
            }
            return(model);
        }
        public static LotteryResult GetLotteryResult(string cpCode, string status, string orderasc = "asc")
        {
            string sqlwhere = " where  b.cpCode='" + cpCode + "'";

            if (!string.IsNullOrEmpty(status))
            {
                sqlwhere += " and b.Status in (" + status + ") ";
            }

            DataTable     dt    = LotteryResultDAL.GetDataTable("select top 1 *  from  LotteryResult (nolock) b " + sqlwhere + " Order by AutoID " + orderasc);
            LotteryResult model = new LotteryResult();

            foreach (DataRow dr in dt.Rows)
            {
                model.FillData(dr);
            }
            return(model);
        }
        public static List <LotteryResult> GetLotteryOpen(int pageIndex, ref int totalCount, ref int pageCount, string cpcode = "", int pageSize = 15, string btime = "", string etime = "", string status = "0,1", string keywords = "")
        {
            string whereSql = " 1=1 ";

            if (!string.IsNullOrEmpty(status) && status != "-1")
            {
                whereSql += " and a.Status in (" + status + ")";
            }
            if (!string.IsNullOrEmpty(btime))
            {
                whereSql += " and a.OpenTime>='" + btime + "'";
            }
            if (!string.IsNullOrEmpty(etime))
            {
                whereSql += " and a.OpenTime<='" + etime + " 23:59:59:999'";
            }
            if (!string.IsNullOrEmpty(cpcode))
            {
                whereSql += " and a.CPCode='" + cpcode + "'";
            }
            if (!string.IsNullOrEmpty(keywords))
            {
                whereSql += " and a.IssueNum like'%" + keywords + "%' ";
            }
            string    cstr = @" a.AutoID,a.CPCode,a.IssueNum,c.ResultNum AutoNum,a.ResultNum ResultNum,a.Status,a.UpdateTime,a.CreateTime,a.PizeNum,a.UserNum,a.SumNum,a.OpenTime,a.Num,b.CPName ";
            DataTable dt   = CommonBusiness.GetPagerData(" LotteryResult a join lottery b on a.CPCode=b.CPCode left join LotteryWaitPay c on a.CPCode=c.CPCode and a.IssueNum=c.IssueNum ", cstr, whereSql, "a.AutoID", pageSize, pageIndex, out totalCount, out pageCount);

            List <LotteryResult> list = new List <LotteryResult>();

            foreach (DataRow dr in dt.Rows)
            {
                LotteryResult model = new LotteryResult();
                model.FillData(dr);
                list.Add(model);
            }
            return(list);
        }