Ejemplo n.º 1
0
        public ActionResult BettingFind(int id)
        {
            try
            {
                ViewBag.Title  = "投注记录";
                ViewBag.Title2 = "投注记录";
                ViewBag.Page   = "投注";

                var betting = new DBC.Betting(id);
                var user    = new DBC.User(betting.UserID);
                var current = GetCurrentUser();

                if (user.ID == current.ID || user.Parent == current.ID)
                {
                    var bettingList = new List <DBC.Betting>()
                    {
                        betting
                    };
                    ViewBag.list = GetBettingOverviewList(bettingList);
                }
                else
                {
                    throw new Exception("无权查看");
                }
            }
            catch
            {
                ViewBag.errorText = "未查询到任何记录";
            }

            return(View("betting"));
        }
Ejemplo n.º 2
0
        public ActionResult Betting(int?userid, int p = 0)
        {
            try
            {
                ViewBag.Title  = "投注记录";
                ViewBag.Title2 = "投注记录";
                ViewBag.Page   = "投注";

                var currentUser  = Session["user"] as DBC.User;
                var pages        = 1;
                var sqlCount     = "";
                var sqlList      = "";
                var sqlCountArgs = new List <object>();
                var sqlListArgs  = new List <object>();

                var current = GetCurrentUser();
                sqlCount = string.Format("select count(*) from {0} where {0}.userid=?", DBTables.Betting, DBTables.User);
                sqlCountArgs.Add(current.ID);

                sqlList = string.Format("select id from {0} where {0}.userid=?  order by time desc limit ?,?", DBTables.Betting, DBTables.User);
                sqlListArgs.Add(current.ID);

                //添加分页参数
                sqlListArgs.Add(p * _itemsPerPage);
                sqlListArgs.Add(_itemsPerPage);

                var totalCount = Convert.ToInt32(DB.SExecuteScalar(sqlCount, sqlCountArgs.ToArray()));
                pages = (int)Math.Ceiling(totalCount * 1.0 / _itemsPerPage);
                var res = DB.SExecuteReader(sqlList, sqlListArgs.ToArray());

                var bettingList = new List <DBC.Betting>();
                foreach (var item in res)
                {
                    //数据记录不完整时跳过
                    try
                    {
                        var id      = Convert.ToInt32(item[0]);
                        var betting = new DBC.Betting(id);
                        bettingList.Add(betting);
                    }
                    catch { }
                }

                var pagination = new Pagination();
                pagination.Pages   = pages;
                pagination.Current = p;
                pagination.BaseUrl = "/home/betting";
                ViewBag.pagination = pagination;

                ViewBag.list = GetBettingOverviewList(bettingList);
            }
            catch
            {
                ViewBag.errorText = "未查询到任何记录";
            }

            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Betting(int? userid, int p = 0)
        {
            try
            {
                ViewBag.Title = "投注记录";
                ViewBag.Title2 = "投注记录";
                ViewBag.Page = "投注";

                var currentUser = Session["user"] as DBC.User;
                var pages = 1;
                var sqlCount = "";
                var sqlList = "";
                var sqlCountArgs = new List<object>();
                var sqlListArgs = new List<object>();

                var current = GetCurrentUser();
                sqlCount = string.Format("select count(*) from {0} where {0}.userid=?", DBTables.Betting, DBTables.User);
                sqlCountArgs.Add(current.ID);

                sqlList = string.Format("select id from {0} where {0}.userid=?  order by time desc limit ?,?", DBTables.Betting, DBTables.User);
                sqlListArgs.Add(current.ID);

                //添加分页参数
                sqlListArgs.Add(p * _itemsPerPage);
                sqlListArgs.Add(_itemsPerPage);

                var totalCount = Convert.ToInt32(DB.SExecuteScalar(sqlCount, sqlCountArgs.ToArray()));
                pages = (int)Math.Ceiling(totalCount * 1.0 / _itemsPerPage);
                var res = DB.SExecuteReader(sqlList, sqlListArgs.ToArray());

                var bettingList = new List<DBC.Betting>();
                foreach (var item in res)
                {
                    //数据记录不完整时跳过
                    try
                    {
                        var id = Convert.ToInt32(item[0]);
                        var betting = new DBC.Betting(id);
                        bettingList.Add(betting);
                    }
                    catch { }
                }

                var pagination = new Pagination();
                pagination.Pages = pages;
                pagination.Current = p;
                pagination.BaseUrl = "/home/betting";
                ViewBag.pagination = pagination;

                ViewBag.list = GetBettingOverviewList(bettingList);
            }
            catch
            {
                ViewBag.errorText = "未查询到任何记录";
            }

            return View();
        }
Ejemplo n.º 4
0
        void GetBettingsList()
        {
            var user = GetCurrentUser();

            if (user == null || user.Role != Enums.Roles.Normal)
            {
                return;
            }

            var list = new List <DBC.Betting>();
            var sql  = string.Format("select id from {0} where userid=? order by id desc limit 20", DBTables.Betting);
            var res  = DB.SExecuteReader(sql, user.ID);

            foreach (var item in res)
            {
                var id      = Convert.ToInt32(item[0]);
                var betting = new DBC.Betting(id);
                list.Add(betting);
            }
            ViewBag.user         = user;
            ViewBag.bettingsList = list;
        }
Ejemplo n.º 5
0
        public ActionResult Betting(int? userid, DateTime? beginDate, DateTime? endDate, int p = 0)
        {
            try
            {
                ViewBag.Title = "投注记录";
                ViewBag.Title2 = "投注记录";
                ViewBag.Page = "投注";

                if (beginDate == null)
                    beginDate = DateTime.Today.AddDays(-7);
                if (endDate == null)
                    endDate = DateTime.Today;

                var currentUser = Session["user"] as DBC.User;
                var pages = 1;
                var sqlCount = "";
                var sqlList = "";
                var sqlSum = "";
                var sqlCountArgs = new List<object>();
                var sqlListArgs = new List<object>();
                var sqlSumArgs = new List<object>();

                //查看指定用户的投注记录
                if (userid != null)
                {
                    var user = new DBC.User(userid.Value);
                    if (user.Parent != GetCurrentUser().ID)
                        throw new Exception("无权查看");

                    sqlCount = string.Format("select count(*) from {0} where {0}.userid=? and time>? and time<?", DBTables.Betting);
                    sqlCountArgs.Add(user.ID);
                    sqlCountArgs.Add(beginDate.Value);
                    sqlCountArgs.Add(endDate.Value.AddDays(1));

                    sqlList = string.Format("select id from {0} where {0}.userid=? and time>? and time<? order by time desc limit ?,?", DBTables.Betting, DBTables.User);
                    sqlListArgs.Add(user.ID);
                    sqlListArgs.Add(beginDate.Value);
                    sqlListArgs.Add(endDate.Value.AddDays(1));

                    sqlSum = string.Format("select sum(total),sum(winning) from {0} where userid=? and time>? and time<?", DBTables.Betting);
                    sqlSumArgs.Add(user.ID);
                    sqlSumArgs.Add(beginDate.Value);
                    sqlSumArgs.Add(endDate.Value.AddDays(1));
                }
                //查看全部投注记录
                else
                {
                    var current = GetCurrentUser();
                    sqlCount = string.Format("select count(*) from {0},{1} where {0}.userid={1}.id and ({1}.id=? or {1}.parent=?) and time>? and time<?", DBTables.Betting, DBTables.User);
                    sqlCountArgs.Add(current.ID);
                    sqlCountArgs.Add(current.ID);
                    sqlCountArgs.Add(beginDate.Value);
                    sqlCountArgs.Add(endDate.Value.AddDays(1));

                    sqlList = string.Format("select {0}.id from {0},{1} where {0}.userid={1}.id and ({1}.id=? or {1}.parent=?) and time>? and time<? order by time desc limit ?,?", DBTables.Betting, DBTables.User);
                    sqlListArgs.Add(current.ID);
                    sqlListArgs.Add(current.ID);
                    sqlListArgs.Add(beginDate.Value);
                    sqlListArgs.Add(endDate.Value.AddDays(1));

                    sqlSum = string.Format("select sum(total),sum(winning) from {0},{1} where {0}.userid={1}.id and ({1}.id=? or {1}.parent=?) and time>? and time<?", DBTables.Betting, DBTables.User);
                    sqlSumArgs.Add(current.ID);
                    sqlSumArgs.Add(current.ID);
                    sqlSumArgs.Add(beginDate.Value);
                    sqlSumArgs.Add(endDate.Value.AddDays(1));
                }

                //添加分页参数
                sqlListArgs.Add(p * _itemsPerPage);
                sqlListArgs.Add(_itemsPerPage);
                //获取总记录数
                var totalCount = Convert.ToInt32(DB.SExecuteScalar(sqlCount, sqlCountArgs.ToArray()));
                //计算分页数
                pages = (int)Math.Ceiling(totalCount * 1.0 / _itemsPerPage);
                //获取下注记录
                var res = DB.SExecuteReader(sqlList, sqlListArgs.ToArray());
                var bettingList = new List<DBC.Betting>();
                foreach (var item in res)
                {
                    //数据记录不完整时跳过
                    try
                    {
                        var id = Convert.ToInt32(item[0]);
                        var betting = new DBC.Betting(id);
                        bettingList.Add(betting);
                    }
                    catch { }
                }

                //获取总投注和总中奖
                var res2 = DB.SExecuteReader(sqlSum, sqlSumArgs.ToArray());
                var totalBetting = Utility.ToInt32(res2[0][0]);
                var totalWinning = Utility.ToInt32(res2[0][1]);

                var pagination = new Pagination();
                pagination.Pages = pages;
                pagination.Current = p;
                pagination.BaseUrl = string.Format("/home/betting?userid={0}&beginDate={1}&endDate={2}", userid, beginDate.Value.ToString("yyyy-MM-dd"), endDate.Value.ToString("yyyy-MM-dd"));

                ViewBag.list = GetBettingOverviewList(bettingList);
                ViewBag.pagination = pagination;
                ViewBag.totalBetting = totalBetting;
                ViewBag.totalWinning = totalWinning;
                ViewBag.beginDate = beginDate.Value;
                ViewBag.endDate = endDate.Value;
                ViewBag.userid = userid;
            }
            catch
            {
                ViewBag.errorText = "未查询到任何记录";
            }

            return View();
        }
Ejemplo n.º 6
0
        public ActionResult BettingFind(int id)
        {
            try
            {
                ViewBag.Title = "投注记录";
                ViewBag.Title2 = "投注记录";
                ViewBag.Page = "投注";

                var betting = new DBC.Betting(id);
                var user = new DBC.User(betting.UserID);
                var current = GetCurrentUser();

                if (user.ID == current.ID || user.Parent == current.ID)
                {
                    var bettingList = new List<DBC.Betting>() { betting };
                    ViewBag.list = GetBettingOverviewList(bettingList);
                }
                else
                {
                    throw new Exception("无权查看");
                }
            }
            catch
            {
                ViewBag.errorText = "未查询到任何记录";
            }

            return View("betting");
        }
Ejemplo n.º 7
0
        public ActionResult Betting(int?userid, DateTime?beginDate, DateTime?endDate, int p = 0)
        {
            try
            {
                ViewBag.Title  = "投注记录";
                ViewBag.Title2 = "投注记录";
                ViewBag.Page   = "投注";

                if (beginDate == null)
                {
                    beginDate = DateTime.Today.AddDays(-7);
                }
                if (endDate == null)
                {
                    endDate = DateTime.Today;
                }

                var currentUser  = Session["user"] as DBC.User;
                var pages        = 1;
                var sqlCount     = "";
                var sqlList      = "";
                var sqlSum       = "";
                var sqlCountArgs = new List <object>();
                var sqlListArgs  = new List <object>();
                var sqlSumArgs   = new List <object>();

                //查看指定用户的投注记录
                if (userid != null)
                {
                    var user = new DBC.User(userid.Value);
                    if (user.Parent != GetCurrentUser().ID)
                    {
                        throw new Exception("无权查看");
                    }

                    sqlCount = string.Format("select count(*) from {0} where {0}.userid=? and time>? and time<?", DBTables.Betting);
                    sqlCountArgs.Add(user.ID);
                    sqlCountArgs.Add(beginDate.Value);
                    sqlCountArgs.Add(endDate.Value.AddDays(1));

                    sqlList = string.Format("select id from {0} where {0}.userid=? and time>? and time<? order by time desc limit ?,?", DBTables.Betting, DBTables.User);
                    sqlListArgs.Add(user.ID);
                    sqlListArgs.Add(beginDate.Value);
                    sqlListArgs.Add(endDate.Value.AddDays(1));

                    sqlSum = string.Format("select sum(total),sum(winning) from {0} where userid=? and time>? and time<?", DBTables.Betting);
                    sqlSumArgs.Add(user.ID);
                    sqlSumArgs.Add(beginDate.Value);
                    sqlSumArgs.Add(endDate.Value.AddDays(1));
                }
                //查看全部投注记录
                else
                {
                    var current = GetCurrentUser();
                    sqlCount = string.Format("select count(*) from {0},{1} where {0}.userid={1}.id and ({1}.id=? or {1}.parent=?) and time>? and time<?", DBTables.Betting, DBTables.User);
                    sqlCountArgs.Add(current.ID);
                    sqlCountArgs.Add(current.ID);
                    sqlCountArgs.Add(beginDate.Value);
                    sqlCountArgs.Add(endDate.Value.AddDays(1));

                    sqlList = string.Format("select {0}.id from {0},{1} where {0}.userid={1}.id and ({1}.id=? or {1}.parent=?) and time>? and time<? order by time desc limit ?,?", DBTables.Betting, DBTables.User);
                    sqlListArgs.Add(current.ID);
                    sqlListArgs.Add(current.ID);
                    sqlListArgs.Add(beginDate.Value);
                    sqlListArgs.Add(endDate.Value.AddDays(1));

                    sqlSum = string.Format("select sum(total),sum(winning) from {0},{1} where {0}.userid={1}.id and ({1}.id=? or {1}.parent=?) and time>? and time<?", DBTables.Betting, DBTables.User);
                    sqlSumArgs.Add(current.ID);
                    sqlSumArgs.Add(current.ID);
                    sqlSumArgs.Add(beginDate.Value);
                    sqlSumArgs.Add(endDate.Value.AddDays(1));
                }

                //添加分页参数
                sqlListArgs.Add(p * _itemsPerPage);
                sqlListArgs.Add(_itemsPerPage);
                //获取总记录数
                var totalCount = Convert.ToInt32(DB.SExecuteScalar(sqlCount, sqlCountArgs.ToArray()));
                //计算分页数
                pages = (int)Math.Ceiling(totalCount * 1.0 / _itemsPerPage);
                //获取下注记录
                var res         = DB.SExecuteReader(sqlList, sqlListArgs.ToArray());
                var bettingList = new List <DBC.Betting>();
                foreach (var item in res)
                {
                    //数据记录不完整时跳过
                    try
                    {
                        var id      = Convert.ToInt32(item[0]);
                        var betting = new DBC.Betting(id);
                        bettingList.Add(betting);
                    }
                    catch { }
                }

                //获取总投注和总中奖
                var res2         = DB.SExecuteReader(sqlSum, sqlSumArgs.ToArray());
                var totalBetting = Utility.ToInt32(res2[0][0]);
                var totalWinning = Utility.ToInt32(res2[0][1]);

                var pagination = new Pagination();
                pagination.Pages   = pages;
                pagination.Current = p;
                pagination.BaseUrl = string.Format("/home/betting?userid={0}&beginDate={1}&endDate={2}", userid, beginDate.Value.ToString("yyyy-MM-dd"), endDate.Value.ToString("yyyy-MM-dd"));

                ViewBag.list         = GetBettingOverviewList(bettingList);
                ViewBag.pagination   = pagination;
                ViewBag.totalBetting = totalBetting;
                ViewBag.totalWinning = totalWinning;
                ViewBag.beginDate    = beginDate.Value;
                ViewBag.endDate      = endDate.Value;
                ViewBag.userid       = userid;
            }
            catch
            {
                ViewBag.errorText = "未查询到任何记录";
            }

            return(View());
        }
Ejemplo n.º 8
0
        void GetBettingsList()
        {
            var user = GetCurrentUser();
            if (user == null || user.Role != Enums.Roles.Normal)
                return;

            var list = new List<DBC.Betting>();
            var sql = string.Format("select id from {0} where userid=? order by id desc limit 20", DBTables.Betting);
            var res = DB.SExecuteReader(sql, user.ID);
            foreach (var item in res)
            {
                var id = Convert.ToInt32(item[0]);
                var betting = new DBC.Betting(id);
                list.Add(betting);
            }
            ViewBag.user = user;
            ViewBag.bettingsList = list;
        }