protected void btnSave_Click(object sender, EventArgs e) { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Games g = new Games(); if (Request.QueryString.Count > 0) { Int32 GameID = Convert.ToInt32(Request.QueryString["GameID"]); g = (from Game in conn.Games1 where Game.GameID == GameID select Game).FirstOrDefault(); } g.Name = txtName.Text; g.Genre = txtGenre.Text; g.AltName = txtAlt.Text; g.Length = txtLength.Text; if (Request.QueryString.Count == 0) { conn.Games1.Add(g); } conn.SaveChanges(); Response.Redirect("games.aspx"); } }
protected void btnSave_Click(object sender, EventArgs e) { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Books b = new Books(); if(Request.QueryString.Count > 0) { Int32 BookID = Convert.ToInt32(Request.QueryString["BookID"]); b = (from books in conn.Books1 where books.BookID == BookID select books).FirstOrDefault(); } b.Name = txtName.Text; b.Genre = txtGenre.Text; b.AltName = txtAlt.Text; b.Length = txtLength.Text; if (Request.QueryString.Count == 0) { conn.Books1.Add(b); } conn.SaveChanges(); Response.Redirect("books.aspx"); } }
protected void btnSave_Click(object sender, EventArgs e) { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Shows s = new Shows(); if (Request.QueryString.Count > 0) { Int32 ShowID = Convert.ToInt32(Request.QueryString["ShowID"]); s = (from Show in conn.Shows1 where Show.ShowID == ShowID select Show).FirstOrDefault(); } s.Name = txtName.Text; s.Genre = txtGenre.Text; s.AltName = txtAlt.Text; s.Length = txtLength.Text; if (Request.QueryString.Count == 0) { conn.Shows1.Add(s); } conn.SaveChanges(); Response.Redirect("shows.aspx"); } }
protected void getShows() { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { var show = from s in conn.Shows1 select s; String Sort = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); grdShows.DataSource = show.AsQueryable().OrderBy(Sort).ToList(); grdShows.DataBind(); } }
protected void GetGames() { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { var game = from g in conn.Games1 select g; String Sort = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); grdGames.DataSource = game.AsQueryable().OrderBy(Sort).ToList(); grdGames.DataBind(); } }
protected void GetBooks() { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { var book = from b in conn.Books1 select b; String Sort = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); grdBooks.DataSource = book.AsQueryable().OrderBy(Sort).ToList(); grdBooks.DataBind(); } }
protected void getBook() { using(DefaultConnectionEF conn = new DefaultConnectionEF()) { Int32 BookID = Convert.ToInt32(Request.QueryString["BookID"]); var b = (from books in conn.Books1 where books.BookID == BookID select books).FirstOrDefault(); txtName.Text = b.Name; txtGenre.Text = b.Genre; txtAlt.Text = b.AltName; txtLength.Text = b.Length; } }
protected void getShow() { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Int32 ShowID = Convert.ToInt32(Request.QueryString["ShowID"]); var s = (from Show in conn.Shows1 where Show.ShowID == ShowID select Show).FirstOrDefault(); txtName.Text = s.Name; txtGenre.Text = s.Genre; txtAlt.Text = s.AltName; txtLength.Text = s.Length; } }
protected void grdShows_RowDeleting(object sender, GridViewDeleteEventArgs e) { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Int32 ShowID = Convert.ToInt32(grdShows.DataKeys[e.RowIndex].Values["ShowID"]); var s = (from Show in conn.Shows1 where Show.ShowID == ShowID select Show).FirstOrDefault(); conn.Shows1.Remove(s); conn.SaveChanges(); getShows(); } }
protected void grdRecords_RowDeleting(object sender, GridViewDeleteEventArgs e) { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Int32 RecordID = Convert.ToInt32(grdRecords.DataKeys[e.RowIndex].Values["RecordID"]); var r = (from record in conn.Records1 where record.RecordID == RecordID select record).FirstOrDefault(); conn.Records1.Remove(r); conn.SaveChanges(); getRecords(); } }
protected void grdGames_RowDeleting(object sender, GridViewDeleteEventArgs e) { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Int32 GameID = Convert.ToInt32(grdGames.DataKeys[e.RowIndex].Values["GameID"]); var g = (from Game in conn.Games1 where Game.GameID == GameID select Game).FirstOrDefault(); conn.Games1.Remove(g); conn.SaveChanges(); GetGames(); } }
protected void grdBooks_RowDeleting(object sender, GridViewDeleteEventArgs e) { using(DefaultConnectionEF conn = new DefaultConnectionEF()) { Int32 BookID = Convert.ToInt32(grdBooks.DataKeys[e.RowIndex].Values["BookID"]); var b = (from books in conn.Books1 where books.BookID == BookID select books).FirstOrDefault(); conn.Books1.Remove(b); conn.SaveChanges(); GetBooks(); } }
protected void getGame() { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Int32 GameID = Convert.ToInt32(Request.QueryString["GameID"]); var g = (from Game in conn.Games1 where Game.GameID == GameID select Game).FirstOrDefault(); txtName.Text = g.Name; txtGenre.Text = g.Genre; txtAlt.Text = g.AltName; txtLength.Text = g.Length; } }
protected void getItems() { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { //var item = (from g in conn.Games1 select new { g.Name, g.Genre, g.AltName, g.Length }).Union(from b in conn.Books1 select new { b.Name, b.Genre, b.AltName, b.Length }).Union(from s in conn.Shows1 select new { s.Name, s.Genre, s.AltName, s.Length }); var game = (from g in conn.Games1 select g); var book = (from b in conn.Books1 select b); var show = (from s in conn.Shows1 select s); String Sort = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); grdgames.DataSource = game.AsQueryable().OrderBy(Sort).ToList(); grdBooks.DataSource = book.AsQueryable().OrderBy(Sort).ToList(); grdShows.DataSource = show.AsQueryable().OrderBy(Sort).ToList(); grdgames.DataBind(); grdBooks.DataBind(); grdShows.DataBind(); } }
protected void grdBooks_RowCommand(object sender, GridViewCommandEventArgs e) { int currentRowIndex = Int32.Parse(e.CommandArgument.ToString()); string ID = grdBooks.DataKeys[currentRowIndex].Value.ToString(); using (DefaultConnectionEF conn = new DefaultConnectionEF()) { Int32 BookID = Convert.ToInt32(ID); var userName = HttpContext.Current.User.Identity.Name; Records objR = new Records(); AspNetUsers objU = (from u in conn.AspNetUsers1 where u.UserName == userName select u).FirstOrDefault(); Books objB = (from b in conn.Books1 where b.BookID == BookID select b).FirstOrDefault(); objR.UserID = objU.Id; objR.BookID = objB.BookID; objR.Status = false; objR.Progress = "None"; conn.Records1.Add(objR); conn.SaveChanges(); } }
protected void getRecords() { using (DefaultConnectionEF conn = new DefaultConnectionEF()) { var userName = HttpContext.Current.User.Identity.Name; AspNetUsers objU = (from u in conn.AspNetUsers1 where u.UserName == userName select u).FirstOrDefault(); var record = (from r in conn.Records1 join s in conn.Shows1 on r.ShowID equals s.ShowID where r.UserID == objU.Id select new { r.RecordID, s.Name, s.Genre, s.AltName, s.Length, r.Progress}).Union(from r in conn.Records1 join b in conn.Books1 on r.BookID equals b.BookID where r.UserID == objU.Id select new { r.RecordID, b.Name, b.Genre, b.AltName, b.Length, r.Progress}).Union(from r in conn.Records1 join g in conn.Games1 on r.GameID equals g.GameID where r.UserID == objU.Id select new { r.RecordID, g.Name, g.Genre, g.AltName, g.Length, r.Progress}); String Sort = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); grdRecords.DataSource = record.AsQueryable().OrderBy(Sort).ToList(); grdRecords.DataBind(); } }