protected void GetBoundArchive() { using (Bounding_SystemEntities db = new Bounding_SystemEntities()) { Int32 BoundID = Convert.ToInt32(Session["BoundID"]); var Bounds = from b in db.Bounds select b; grdBoundArchive.DataSource = Bounds.ToList(); grdBoundArchive.DataBind(); } }
protected void GetReplayArchive() { using (Bounding_SystemEntities db = new Bounding_SystemEntities()) { Int32 ReplayID = Convert.ToInt32(Session["ReplayID"]); var Replays = from b in db.Replays select b; grdReplayArchive.DataSource = Replays.ToList(); grdReplayArchive.DataBind(); } }
protected void BoundSubmit_Click(object sender, EventArgs e) { //use EF to connect to SQL Server using (Bounding_SystemEntities db = new Bounding_SystemEntities()) { // Use the Student model to save the new record Bound bound = new Bound(); Int32 BoundID = 0; //check the querystring for an id so we can determine add / update if (Request.QueryString["BoundID"] != null) { //get the id from the url BoundID = Convert.ToInt32(Request.QueryString["BoundID"]); //get the current student from EF bound = (from objB in db.Bounds where objB.bound_id == BoundID select objB).FirstOrDefault(); } // Fill in properties of department bound.bound_name = txtBoundName.Text; if (DropDownBoundDifficulty.SelectedValue != "-1") { bound.bound_difficulty = Convert.ToInt32(DropDownBoundDifficulty.SelectedValue); } else { bound.bound_difficulty = null; } bound.bound_obstacles = Convert.ToInt32(BoundObstacles.Text); //call add only if we have no student ID if (BoundID == 0) { db.Bounds.Add(bound); } //run the update or insert db.SaveChanges(); //redirect to the updated students page Response.Redirect("bound-archive.aspx"); } }
protected void grdBoundArchive_RowDeleting(object sender, GridViewDeleteEventArgs e) { //Identify the DepartmentID to be deleted Int32 BoundID = Convert.ToInt32(grdBoundArchive.DataKeys[e.RowIndex].Values["bound_id"]); // Connect using (Bounding_SystemEntities db = new Bounding_SystemEntities()) { Bound bnd = (from b in db.Bounds where b.bound_id == BoundID select b).FirstOrDefault(); // Delete db.Bounds.Remove(bnd); db.SaveChanges(); // Redirect to the departments list page GetBoundArchive(); } }
protected void GetBound() { Int32 BoundID = Convert.ToInt32(Request.QueryString["BoundID"]); using (Bounding_SystemEntities db = new Bounding_SystemEntities()) { Bound bnd = (from b in db.Bounds where b.bound_id == BoundID select b).FirstOrDefault(); //map the student properties to the form controls if we found a match if (bnd != null) { txtBoundName.Text = bnd.bound_name; DropDownBoundDifficulty.ClearSelection(); //making sure the previous selection has been cleared DropDownBoundDifficulty.Items.FindByValue(bnd.bound_difficulty.ToString()).Selected = true; BoundObstacles.Text = bnd.bound_obstacles.ToString(); } } }
protected void btnSubmit_Click(object sender, EventArgs @event) { using (Bounding_SystemEntities db = new Bounding_SystemEntities()) { Profile profile = new Profile(); profile.online_name = txtBoundName.Text; profile.first_name = txtFirstName.Text; profile.last_name = txtLastName.Text; profile.server = txtServer.Text; profile.age = Convert.ToInt32(txtAge.Text); profile.password = PasswordHasher.CreateHash(txtPassword.Text); profile.gender = "Unknown"; db.Profiles.Add(profile); db.SaveChanges(); Response.Redirect("/"); } }