/*<summary> * This Method gets the games data and puts it into the proper gridView * </summary> * * @methods getGame * @return {void} */ protected void getSoccerGame() { using (chandureddyEntities db = new chandureddyEntities()) { var CricketGames = (from allCricketGames in db.Games where allCricketGames.gamename == "cricket" select allCricketGames); CricketGamesGridView.DataSource = CricketGames.AsQueryable().ToList(); CricketGamesGridView.DataBind(); } }
/*<summary> *This Method gets the games data and puts it into the proper gridView * </summary> * * @methods getGame * @return {void} */ protected void getCricketGame() { using (chandureddyEntities db = new chandureddyEntities()) { var CricketGames = (from allCricketGames in db.Games where allCricketGames.gamename == "cricket" select allCricketGames); CricketGamesGridView.DataSource = CricketGames.AsQueryable().ToList(); CricketGamesGridView.DataBind(); } }
protected void RegisterButton_Click(object sender, EventArgs e) { using (chandureddyEntities db = new chandureddyEntities()) { string userName = UserNameTextBox.Text; string password = PasswordTextBox.Text; string confPass = ConfirmPasswordTextBox.Text; //check user name exists in db var userNameCheck = (from UserInformation in db.User_Information where UserInformation.username == userName select UserInformation); if (userNameCheck.Any()) { ClientScript.RegisterStartupScript(GetType(), "validate", "alert('UserName already EXISTS.');", true); } else { if (password == confPass) { if (password.Length > 5) { User_Information newUser = new User_Information(); newUser.username = userName; newUser.password = password; db.User_Information.Add(newUser); db.SaveChanges(); Response.Redirect("Default.aspx"); } else { ClientScript.RegisterStartupScript(GetType(), "validate", "alert('Password must be atleast 6 char long.');", true); PasswordTextBox.Text = ""; PasswordTextBox.Focus(); } } else { ClientScript.RegisterStartupScript(GetType(), "validate", "alert('Passwords dont match.');", true); ConfirmPasswordTextBox.Text = ""; ConfirmPasswordTextBox.Focus(); } } } }
protected void AddGameButton_Click(object sender, EventArgs e) { using (chandureddyEntities db = new chandureddyEntities()) { // use the syudent model to save a new record Game newGame = new Game(); int GameID = -1; if (Request.QueryString.Count > 0) { // get game id from url GameID = Convert.ToInt32(Request.QueryString["GameID"]); // get the current Game from the DB newGame = (from game in db.Games where game.Id == GameID select game).FirstOrDefault(); } // add for data to new record newGame.hometeam = hometeamTextBox.Text; newGame.awayteam = awayteamTextBox.Text; newGame.hometeampoints = Convert.ToInt32(hometeampointsTextBox.Text); newGame.awayteampoints = Convert.ToInt32(awayteampointsTextBox.Text); newGame.attendance = Convert.ToInt32(attendanceTextBox.Text); newGame.venue = venueTextBox.Text; newGame.gamename = gamenameTextBox.SelectedValue; newGame.winningteam = winningTextBox.Text; newGame.dateplayed = Convert.ToDateTime(dateplayedTextBox.Text); // add a new game to Games Table Collection if (GameID == -1) { db.Games.Add(newGame); } // run insert commands to database db.SaveChanges(); Response.Redirect("~/Default.aspx"); } }
private void GetGame() { int GameID = Convert.ToInt32(Request.QueryString["GameID"]); //connect to DB using (chandureddyEntities db = new chandureddyEntities()) { Game updatedGame = (from game in db.Games where game.Id == GameID select game).FirstOrDefault(); if (updatedGame != null) { hometeamTextBox.Text = updatedGame.hometeam; awayteamTextBox.Text = updatedGame.awayteam; hometeampointsTextBox.Text = updatedGame.hometeampoints.ToString(); awayteampointsTextBox.Text = updatedGame.awayteampoints.ToString(); attendanceTextBox.Text = updatedGame.attendance.ToString(); venueTextBox.Text = updatedGame.venue; gamenameTextBox.SelectedValue = updatedGame.gamename; dateplayedTextBox.Text = updatedGame.dateplayed.ToString("yyy-MM-dd"); } } }
protected void getUser() { // connect to EF using (chandureddyEntities db = new chandureddyEntities()) { //string SortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); string username = inputUserName.Text; string password = inputPassword.Text; // query the Students Table using EF and LINQ var User = (from User_Information in db.User_Information where User_Information.username == username && User_Information.password == password select User_Information); if (User.Any()) { Session["userName"] = username; Response.Redirect("GameEditPage.aspx"); } else Response.Redirect("Default.aspx"); } }
protected void getUser() { // connect to EF using (chandureddyEntities db = new chandureddyEntities()) { //string SortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); string username = inputUserName.Text; string password = inputPassword.Text; // query the Students Table using EF and LINQ var User = (from User_Information in db.User_Information where User_Information.username == username && User_Information.password == password select User_Information); if (User.Any()) { Session["userName"] = username; Response.Redirect("CreateGamePage.aspx"); } else { Response.Redirect("Default.aspx"); } } }