示例#1
0
 /// <summary>
 /// On validation, new user is registered.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnRegister_Click(object sender, EventArgs e)
 {
     // Starting a connection with the CasinoDB for User and Record tables.
     playerDAO = new PlayerDAO(connString);
     recordDAO = new RecordDAO(connString);
     // Condition checks for duplicate account registrations.
     if (playerDAO.UserNameExists(txtUsername.Text))
     {
         txtUsername.Text = "Username already exists.";
         if (playerDAO.UserEmailExists(txtEmail.Text))
         {
             txtEmail.Text = "Email already exists.";
         }
     }
     else
     {
         // Creates salted hash password for new registered player.
         GeneratePasswordSaltedHash(txtPass.Text);
         // Sets the new registered players starting balance.
         int balance = Player.STARTING_BALANCE;
         // Creates new instances of Player and Record for DAO classes.
         Player player = new Player(txtUsername.Text, txtFirstName.Text, txtLastName.Text, txtEmail.Text, base64Password, base64Salt, balance);
         Record record = new Record(player.UserName, 0, 0, 0, 0);
         // Adds a new registered Player to User table and create their new record.
         playerDAO.AddPlayer(player);
         recordDAO.AddNewRecord(record);
         // Redirects to MainMenu page when registration is complete.
         Response.Redirect("/MainMenu.aspx");
     }
 }
示例#2
0
        public void QueryRecordList(HttpContext context)
        {
            RecordDAO     dao       = new RecordDAO();
            String        condition = context.Request["condition"];
            List <Record> lst       = dao.Query(condition);

            context.Response.Write(JsonConvert.SerializeObject(new { Result = 1, Msg = "获取全部数据成功!", data = lst }));
        }
        public void TestFindRecordByRequestIDDAO()
        {
            RecordDAO       recordDao = new RecordDAO();
            OleDbConnection con       = recordDao.Begin();
            int?            id        = recordDao.FindRecordByRequestIDDAO(con, "Consol - C1900007772");

            recordDao.Commit();
            recordDao.Close();
        }
        public void TestFindRecordsToAllocateDAO()
        {
            RecordDAO       recordDao = new RecordDAO();
            OleDbConnection con       = recordDao.Begin();
            List <Record>   records   = recordDao.FindRecordsToAllocateDAO(con);

            recordDao.Commit();
            recordDao.Close();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         recordDAO = new RecordDAO(connString);
         records   = recordDAO.ReadAllRecordsSortedByRatio();
         GVLeaderboard.DataSource = records;
         GVLeaderboard.DataBind();
     }
 }
示例#6
0
        //租借管理
        public JsonResult GetRecordList()
        {
            RecordDAO     dao = new RecordDAO();
            List <Record> lst = dao.GetRecordList();

            return(Json(new
            {
                data = lst,
            }, JsonRequestBehavior.AllowGet));
        }
示例#7
0
        public JsonResult DelRecord(int ID)
        {
            Record record = new Record();

            record.RecordId = ID;
            int result = new RecordDAO().Delete(record);

            return(Json(new
            {
                data = result,
            }, JsonRequestBehavior.AllowGet));
        }
示例#8
0
        public JsonResult GetRecordByPage(int pageIndex, int size)
        {
            RecordDAO dao = new RecordDAO();

            pageIndex -= 1;
            List <Record> lst = dao.GetRecordByPage(pageIndex, size);

            return(Json(new
            {
                data = lst,
            }, JsonRequestBehavior.AllowGet));
        }
        public void TestAddRecordItemDAO()
        {
            Record record = new Record();

            record.UserName = "******";
            RecordDAO       recordDao = new RecordDAO();
            OleDbConnection con       = recordDao.Begin();

            recordDao.AddRecordItemDAO(con, record);

            recordDao.Commit();
            recordDao.Close();
        }
示例#10
0
        /// <summary>
        /// On game draw, all information is saved into their respective databases.
        /// </summary>
        /// <param name="playerDB"></param>
        /// <param name="recordDB"></param>
        /// <param name="gameDB"></param>
        public void SaveDraw(PlayerDAO playerDB, RecordDAO recordDB, GameDAO gameDB)
        {
            // Updates player table information.
            playerDB.UpdateBalance(Player);
            // Updates record table information.
            Record record = recordDB.ReadRecordByUserName(Player.UserName);

            record.GamesPlayed++;
            record.Draws++;
            recordDB.UpdateRecord(record);
            // Updates game table information.
            gameDB.AddNewGame(new Game(Player.UserName, Result.DRAW, GameBalance / 2));
        }
示例#11
0
        public JsonResult BorrowBook(string BookId, string bookName, string bookAuthor, string bookPrice, string bookPic, string userId)
        {
            RecordDAO recordDAO = new RecordDAO();
            BookDAO   bookDAO   = new BookDAO();
            Book      book      = new Book();
            Record    record    = new Record();

            book.BookId     = int.Parse(BookId);
            book.BookName   = bookName;
            book.BookAuthor = bookAuthor;
            book.BookPrice  = bookPrice;
            book.BookPic    = bookPic;
            book.Status     = 0;
            bookDAO.Update(book);
            int count = recordDAO.Insert(int.Parse(BookId), userId);

            return(Json(1, JsonRequestBehavior.AllowGet));
        }
示例#12
0
        public ActionResult RecordManage()
        {
            RecordDAO dao = new RecordDAO();

            return(View());
        }
 public void CreateConnectionForDAO()
 {
     playerDB = new PlayerDAO(connString);
     recordDB = new RecordDAO(connString);
     gameDB   = new GameDAO(connString);
 }