protected void btnRefreshCache_Click(object sender, EventArgs e) { MatchTicket.Cache.RefreshCache(); //Arsenal_Player.Cache.RefreshCache(); //Arsenal_Team.Cache.RefreshCache(); MatchTicket.MatchTicketCountStatistics(); ClientScript.RegisterClientScriptBlock(typeof(string), "succeed", "alert('更新缓存成功');window.location.href=window.location.href", true); }
public ActionResult Tickets(string match, int row, int seat, int price) { try { string matchName = match.Split(':')[1].Trim(); int result = DataAccess.DbAccess.Database.SqlQuery <int>(string.Format("SELECT [dbo].[FreeSeatFunction]({0},{1},'{2}')", row, seat, matchName)).FirstOrDefault(); if (result == 0) { Ticket t = new Ticket() { Seat = seat, Row = row, Price = price, MatchName = matchName, Location = "Berlin" }; User u = DataAccess.DbAccess.Users.ToList().Find(x => x.Username == AuthUser.Username && x.Password == AuthUser.Password); Match m = DataAccess.DbAccess.Matches.ToList().Find(x => x.MatchName == matchName); MatchTicket mt = new MatchTicket() { Match = m, User = u, Ticket = t, TicketID = t.TicketID, MatchID = m.MatchID, UserID = u.UserID, MatchTicketID = DataAccess.DbAccess.MatchTickets.ToList().Count + 1 }; DataAccess.DbAccess.MatchTickets.Add(mt); DataAccess.DbAccess.SaveChanges(); } else { TicketViewModel ticketView = new TicketViewModel(); foreach (var mtch in DataAccess.DbAccess.Matches.ToList()) { ticketView.matches.Add(string.Format("{0}: {1}", mtch.MatchID, mtch.MatchName)); } ticketView.errorMSG = "Row / Seat already taken."; return(View(ticketView)); } return(RedirectToAction("UserProfile", "User")); } catch { TicketViewModel ticketView = new TicketViewModel(); foreach (var mtch in DataAccess.DbAccess.Matches.ToList()) { ticketView.matches.Add(string.Format("{0}: {1}", mtch.MatchID, mtch.MatchName)); } ticketView.errorMSG = "Unknown error occured."; return(View(ticketView)); } }
private void BindData() { var list = MatchTicket.All().FindAll(x => { var returnValue = true; string tmpString; if (ViewState["LeagueGuid"] != null) { tmpString = ViewState["LeagueGuid"].ToString(); if (!string.IsNullOrEmpty(tmpString)) { returnValue = returnValue && x.LeagueGuid.Equals(new Guid(tmpString)); } } if (ViewState["IsHome"] != null) { tmpString = ViewState["IsHome"].ToString(); if (!string.IsNullOrEmpty(tmpString)) { returnValue = returnValue && x.IsHome.Equals(Convert.ToBoolean(tmpString)); } } if (ViewState["ProductCode"] != null) { tmpString = ViewState["ProductCode"].ToString(); if (!string.IsNullOrEmpty(tmpString)) { returnValue = returnValue && x.ProductCode.Equals(tmpString, StringComparison.OrdinalIgnoreCase); } } if (ViewState["AllowMemberClass"] != null) { tmpString = ViewState["AllowMemberClass"].ToString(); if (!string.IsNullOrEmpty(tmpString) && x.AllowMemberClass.HasValue) { returnValue = returnValue && x.AllowMemberClass.Equals(Convert.ToInt32(tmpString)); } } if (ViewState["TeamName"] != null) { tmpString = ViewState["TeamName"].ToString(); if (!string.IsNullOrEmpty(tmpString) && tmpString != "--对阵球队--") { returnValue = returnValue && x.TeamName.ToLower().Contains(tmpString.ToLower()); } } return(returnValue); }); #region set GridView Selected PageIndex if (MatchGuid.HasValue && MatchGuid != Guid.Empty) { var i = list.FindIndex(mt => mt.ID.Equals(MatchGuid)); if (i >= 0) { gvMatchTicket.PageIndex = i / gvMatchTicket.PageSize; gvMatchTicket.SelectedIndex = i % gvMatchTicket.PageSize; } else { gvMatchTicket.PageIndex = 0; gvMatchTicket.SelectedIndex = -1; } } else { gvMatchTicket.SelectedIndex = -1; } #endregion gvMatchTicket.DataSource = list; gvMatchTicket.DataBind(); #region set Control Custom Pager if (gvMatchTicket.BottomPagerRow != null) { gvMatchTicket.BottomPagerRow.Visible = true; ctrlCustomPagerInfo.Visible = true; ctrlCustomPagerInfo.PageIndex = gvMatchTicket.PageIndex; ctrlCustomPagerInfo.PageCount = gvMatchTicket.PageCount; ctrlCustomPagerInfo.RowCount = list.Count; ctrlCustomPagerInfo.InitComponent(); } else { ctrlCustomPagerInfo.Visible = false; } #endregion }