protected void UpdateGameBtn_Click(object sender, EventArgs e) { if (!IsSuperAdmin() || this.GameDateTb.Text == "" || this.GameListbox.SelectedItem == null)// || this.GameListbox.SelectedItem.Text == this.GameDateTb.Text) { return; } try { DateTime gameDate = DateTime.Parse(GameDateTb.Text); if (this.GameListbox.SelectedItem.Text != this.GameDateTb.Text && CurrentPool.GameExists(gameDate)) { ClientScript.RegisterStartupScript(Page.GetType(), "msgid", "alert('Game on " + gameDate.ToShortDateString() + " is already in system!')", true); return; } Game game = CurrentPool.FindGameByDate(DateTime.Parse(GameListbox.SelectedItem.Text)); if (game != null) { game.Date = gameDate; game.IsCancelled = this.gameCancelledCb.Checked; game.DropinRestricted = this.DropinRestricted.Checked; } } catch (Exception) { ClientScript.RegisterStartupScript(Page.GetType(), "msgid", "alert('Wrong game date format! Fix it and try again')", true); return; } this.GameListbox.DataSource = CurrentPool.Games; this.GameListbox.DataBind(); DataAccess.Save(Manager); SetNextGameDate(); // Response.Redirect(Request.RawUrl); }
protected void MemberChangeAttendance_Click(object sender, ImageClickEventArgs e) { ImageButton btn = (ImageButton)sender; String playerId = btn.ID.Split(',')[0]; DateTime date = DateTime.Parse(btn.ID.Split(',')[1]); Player player = Manager.FindPlayerById(playerId); Game game = CurrentPool.FindGameByDate(date); Attendee attendee = game.Members.FindByPlayerId(playerId); if (attendee.Status == InOutNoshow.Out) { if (Handler.IsSpotAvailable(CurrentPool, game.Date)) { Handler.ReservePromarySpot(CurrentPool, game, player); Manager.AddReservationNotifyWechatMessage(player.Id, CurrentUser.Id, Constants.RESERVED, CurrentPool, CurrentPool, game.Date); } else { ShowMessage("Pool " + CurrentPool.Name + " is full. If you would like to add to waiting list, use the pool reservation page"); return; } return; } else if (attendee.Status == InOutNoshow.In) { Handler.CancelPromarySpot(CurrentPool, game, player); Manager.AddReservationNotifyWechatMessage(player.Id, CurrentUser.Id, Constants.CANCELLED, CurrentPool, CurrentPool, game.Date); Handler.AssignDropinSpotToWaiting(CurrentPool, game); } //Recalculate factor Manager.ReCalculateFactor(CurrentPool, date); DataAccess.Save(Manager); Response.Redirect(Request.RawUrl); }
protected void GameList_SelectedIndexChanged(object sender, EventArgs e) { GameDateTb.Text = this.GameListbox.SelectedItem.Text; Game game = CurrentPool.FindGameByDate(DateTime.Parse(GameListbox.SelectedItem.Text)); gameCancelledCb.Checked = game.IsCancelled; DropinRestricted.Checked = game.DropinRestricted; }
private void No_Show_Confirm_Click(object sender, EventArgs e) { String playerId = Session[Constants.CURRENT_PLAYER_ID].ToString(); Game game = CurrentPool.FindGameByDate(TargetGameDate); Player player = Manager.FindPlayerById(playerId); Handler.MarkNoShow(CurrentPool, game, player); String message = String.Format("[System Info] Hi, {0}. Admin marked you as no-show on the reservation of {1}. If you have any question, contact the admin", player.Name, game.Date.ToString("MM/dd/yyyy")); Manager.WechatNotifier.AddNotifyWechatMessage(player, message); LogHistory log = Handler.CreateLog(Manager.EastDateTimeNow, game.Date, Handler.GetUserIP(), CurrentPool.Name, Manager.FindPlayerById(playerId).Name, "Marked no-show", CurrentUser.Name); Manager.Logs.Add(log); Manager.ReCalculateFactor(CurrentPool, TargetGameDate); DataAccess.Save(Manager); Response.Redirect(Constants.RESERVE_PAGE); }
protected void Reserve_Confirm_Click(object sender, EventArgs e) { String playerId = Session[Constants.CURRENT_PLAYER_ID].ToString(); Player player = Manager.FindPlayerById(playerId); Game game = CurrentPool.FindGameByDate(TargetGameDate); if (Handler.ReserveSpot(CurrentPool, game, player)) { Manager.ReCalculateFactor(CurrentPool, TargetGameDate); Manager.AddReservationNotifyWechatMessage(player.Id, CurrentUser.Id, Constants.RESERVED, CurrentPool, CurrentPool, TargetGameDate); LogHistory log = Handler.CreateLog(Manager.EastDateTimeNow, game.Date, Handler.GetUserIP(), CurrentPool.Name, Manager.FindPlayerById(playerId).Name, "Reserved", CurrentUser.Name); Manager.Logs.Add(log); Handler.AutoMoveCoopPlayers(CurrentPool.DayOfWeek, game.Date); DataAccess.Save(Manager); } Response.Redirect(Constants.RESERVE_PAGE); }
protected void Move_Confirm_Click(object sender, EventArgs e) { Game game = CurrentPool.FindGameByDate(TargetGameDate); String playerId = Session[Constants.CURRENT_PLAYER_ID].ToString(); Player player = Manager.FindPlayerById(playerId); if (game.Members.Items.Exists(member => member.PlayerId == playerId && member.Status == InOutNoshow.In) || game.Dropins.Items.Exists(dropin => dropin.PlayerId == playerId && dropin.Status == InOutNoshow.In) || game.WaitingList.Exists(playerId)) { Pool sameDayPool = Manager.Pools.Find(p => p.DayOfWeek == CurrentPool.DayOfWeek && p.Name != CurrentPool.Name); game = sameDayPool.FindGameByDate(TargetGameDate); MoveSpot(sameDayPool, game, player); return; } MoveSpot(CurrentPool, game, player); }
//Cancel waiting protected void Cancel_Waiting_Click(object sender, EventArgs e) { if (Handler.IsReservationLocked(TargetGameDate) && !Manager.ActionPermitted(Actions.Change_After_Locked, CurrentUser.Role)) { ShowMessage(appLockedMessage); return; } ImageButton lbtn = (ImageButton)sender; String playerId = lbtn.ID; Game game = CurrentPool.FindGameByDate(TargetGameDate); game.WaitingList.Remove(playerId); LogHistory log = Handler.CreateLog(Manager.EastDateTimeNow, game.Date, Handler.GetUserIP(), CurrentPool.Name, Manager.FindPlayerById(playerId).Name, "Cancel waitinglist", CurrentUser.Name); Manager.Logs.Add(log); DataAccess.Save(Manager); this.PopupModal.Hide(); Response.Redirect(Constants.RESERVE_PAGE); }
protected void DeleteGameBtn_Click(object sender, EventArgs e) { if (!IsSuperAdmin() || this.GameListbox.SelectedIndex == -1) { return; } Game game = CurrentPool.FindGameByDate(DateTime.Parse(GameListbox.SelectedItem.Text)); if (game != null) { CurrentPool.Games.Remove(game); // this.GameDateTb.Text = ""; // this.GameList.SelectedIndex = -1; this.GameListbox.DataSource = CurrentPool.Games; this.GameListbox.DataBind(); DataAccess.Save(Manager); SetNextGameDate(); //Response.Redirect(Request.RawUrl); } }
protected void Confirm_Click(object sender, EventArgs e) { if (Handler.IsReservationLocked(TargetGameDate) && !Manager.ActionPermitted(Actions.Change_After_Locked, CurrentUser.Role)) { ShowMessage(appLockedMessage); return; } ImageButton lbtn = (ImageButton)sender; String playerId = lbtn.ID; Game game = CurrentPool.FindGameByDate(TargetGameDate); Attendee member = game.Members.FindByPlayerId(playerId); member.Confirmed = true; LogHistory log = Handler.CreateLog(Manager.EastDateTimeNow, game.Date, Handler.GetUserIP(), CurrentPool.Name, Manager.FindPlayerById(playerId).Name, "Confirmed", CurrentUser.Name); Manager.Logs.Add(log); String message = String.Format("You confirmed your reservation for the volleyball game on {0}. If you change your mind, please cancel it. Thanks", game.Date.ToString("MM/dd/yyyy")); Manager.WechatNotifier.AddNotifyWechatMessage(Manager.FindPlayerById(playerId), message); DataAccess.Save(Manager); ShowMessage("Your reservation is confirmed !"); //Response.Redirect(Constants.RESERVE_PAGE); }
protected void AddWaitingList_Confirm_Click(object sender, ImageClickEventArgs e) { String playerId = Session[Constants.CURRENT_PLAYER_ID].ToString(); Game game = CurrentPool.FindGameByDate(TargetGameDate); if (game.WaitingList.Exists(playerId)) { return; } Pool otherPool = Manager.Pools.Find(p => p.Name != CurrentPool.Name && p.DayOfWeek == CurrentPool.DayOfWeek); if (otherPool != null && otherPool.Members.Exists(playerId) && !otherPool.FindGameByDate(TargetGameDate).Members.Items.Exists(member => member.PlayerId == playerId && member.Status == InOutNoshow.In)) { //Changed to allow holding a member spot in another pool when putting into waiting list // ShowMessage("Sorry, But you have aleady reserved a spot in pool " + pool.Name + " on the same day. Cancel that spot before adding onto the waiting list"); //return; } if (otherPool != null && otherPool.Dropins.Exists(playerId) && otherPool.FindGameByDate(TargetGameDate).Dropins.Items.Exists(dropin => dropin.PlayerId == playerId && dropin.Status == InOutNoshow.In)) { ShowMessage("Sorry, But you have aleady reserved a dropin spot in pool " + otherPool.Name + " on the same day. Cancel that spot beforeadding onto the waiting list"); return; } else if (otherPool.FindGameByDate(TargetGameDate).WaitingList.Exists(playerId)) { ShowMessage("Sorry, But you are on waiting list in pool " + otherPool.Name + " on the same day. Cancel that before adding onto the waiting list"); return; } Handler.AddToWaitingList(CurrentPool, game, Manager.FindPlayerById(playerId)); Manager.AddReservationNotifyWechatMessage(playerId, CurrentUser.Id, Constants.WAITING, CurrentPool, CurrentPool, TargetGameDate); LogHistory log = Handler.CreateLog(Manager.EastDateTimeNow, game.Date, Handler.GetUserIP(), CurrentPool.Name, Manager.FindPlayerById(playerId).Name, "Added to waiting list", CurrentUser.Name); Manager.Logs.Add(log); Handler.AutoMoveCoopPlayers(CurrentPool.DayOfWeek, game.Date); DataAccess.Save(Manager); Response.Redirect(Constants.RESERVE_PAGE); }
protected void Page_Load(object sender, EventArgs e) { //ReloadManager(); this.PopupModal.Hide(); if (Manager.CookieAuthRequired && Request.Cookies[Constants.PRIMARY_USER] == null) { Response.Redirect(Constants.REQUEST_REGISTER_LINK_PAGE); return; } Player currentUser = Manager.FindPlayerById(Request.Cookies[Constants.PRIMARY_USER][Constants.USER_ID]); if (currentUser == null || !currentUser.IsActive) { ShowMessage("Sorry, but your device is no longer linked to any account, Please contact admin for advice"); return; } Session[Constants.CURRENT_USER] = currentUser; String operatorId = Request.Cookies[Constants.PRIMARY_USER][Constants.USER_ID]; String poolId = this.Request.Params[Constants.POOL_ID]; String poolName = this.Request.Params[Constants.POOL]; if (poolId != null) { poolName = Manager.FindPoolById(poolId).Name; Session[Constants.POOL] = poolName; this.ToReadmeBtn.Visible = false; Session[Constants.GAME_DATE] = null; } else if (poolName != null) { Session[Constants.POOL] = poolName; Session[Constants.GAME_DATE] = null; } if (CurrentPool == null) { Response.Redirect(Constants.POOL_LINK_LIST_PAGE); return; } // DateTime gameDate = Manager.EastDateTimeToday; String gameDateString = this.Request.Params[Constants.GAME_DATE]; if (gameDateString != null) { gameDate = DateTime.Parse(gameDateString); } else if (Session[Constants.GAME_DATE] != null) { gameDate = DateTime.Parse(Session[Constants.GAME_DATE].ToString()); } Session[Constants.GAME_DATE] = null; List <Game> games = CurrentPool.Games; Game targetGame = games.OrderBy(game => game.Date).ToList <Game>().Find(game => game.Date >= gameDate); if (targetGame != null) { Session[Constants.GAME_DATE] = targetGame.Date; } //Check to see if user is quilified to view current pool if ((!Manager.ActionPermitted(Actions.View_All_Pools, currentUser.Role) && !CurrentPool.Members.Exists(currentUser.Id) &&// !CurrentPool.Dropins.Exists(currentUser.Id) && !targetGame.Dropins.Exists(currentUser.Id)) || (CurrentPool.AutoCoopReserve && targetGame.Dropins.Items.Exists(c => c.PlayerId == currentUser.Id && c.IsCoop && c.Status == InOutNoshow.Out))) { Response.Redirect(Constants.POOL_LINK_LIST_PAGE); return; } if (!Manager.ActionPermitted(Actions.Admin_Management, currentUser.Role) && Manager.InMaintenance) { GameInfoTable.Caption = "Under Maintenance!"; this.RateBtn.Visible = false; this.ToReadmeBtn.Visible = false; this.MemberTable.Visible = false; this.DropinCandidateTable.Visible = false; return; } //Initialize processor InitializeActionHandler(); //Fill message board if (!String.IsNullOrEmpty(CurrentPool.MessageBoard)) { ShowBoardMessage(CurrentPool.MessageBoard); } else if (TargetGameDate.DayOfWeek == DayOfWeek.Thursday) { ShowBoardMessage(Constants.THURSDAY_NOTIFY_MESSAGE); } else { this.MessageTextTable.Visible = false; } if (Session[Constants.GAME_DATE] == null) { if (String.IsNullOrEmpty(CurrentPool.MessageBoard)) { GameInfoTable.Caption = "No volleyball in pool " + CurrentPool.Name + " !"; } //Fill member table FillMemberTable(CurrentPool); //Fill dropin table this.DropinCandidateTable.Caption = "Dropins"; FillDropinTable(CurrentPool); return; } //Check if there is dropin spots available for the players on waiting list Game comingGame = CurrentPool.FindGameByDate(TargetGameDate); while (!Handler.IsReservationLocked(TargetGameDate) && Handler.IsSpotAvailable(CurrentPool, TargetGameDate) && comingGame.WaitingList.Count > 0) { Handler.AssignDropinSpotToWaiting(CurrentPool, comingGame); } //Cancel unconfirmed reservation Handler.AutoCancelUnconfirmedReservations(); //Auto move intern Handler.AutoMoveCoop(); //Fill game information FillGameInfoTable(CurrentPool, TargetGameDate); //Fill member table FillMemberTable(CurrentPool, TargetGameDate); //Fill dropin table FillDropinTable(CurrentPool, TargetGameDate); SetConfirmButtonHandlder(); this.AddDropinImageBtn.Click += new ImageClickEventHandler(AddDropinImageBtn_Click); this.CreateNewPlayerBtn.Click += new ImageClickEventHandler(CreateNewPlayerBtn_Click); //this.PopupModal.Hide(); }
protected void Reserve_Click(object sender, EventArgs e) { if (Handler.IsReservationLocked(TargetGameDate) && !Manager.ActionPermitted(Actions.Change_After_Locked, CurrentUser.Role)) { ShowMessage(appLockedMessage); return; } ImageButton lbtn = (ImageButton)sender; Session[Constants.CURRENT_PLAYER_ID] = lbtn.ID; String playerId = lbtn.ID; Player player = Manager.FindPlayerById(playerId); Game game = CurrentPool.FindGameByDate(TargetGameDate); //Handle dropin if (game.Dropins.Exists(playerId)) { Pickup dropin = game.Dropins.FindByPlayerId(playerId); if (dropin.IsCoop) { if (CurrentPool.AutoCoopReserve && !Manager.ActionPermitted(Actions.Reserve_Coop, CurrentUser.Role)) { ShowMessage("Sorry, but the reservation for " + player.Name + " is not permitted in this pool, contact admin for advise"); return; } if (Manager.EastDateTimeNow < TargetGameDate.AddHours(CurrentPool.ReservHourForCoop)) { ShowMessage("Sorry, but the reservation for " + player.Name + " starts at " + CurrentPool.ReservHourForCoop + " O'clock on game day. Check back later"); return; } } else { DateTime dropinSpotOpeningDate = Handler.DropinSpotOpeningDateTime(CurrentPool, TargetGameDate, player); if (Manager.EastDateTimeNow < dropinSpotOpeningDate) { ShowMessage("Sorry, But drop-in reservation for " + player.Name + " cannot be made until " + Manager.DropinSpotOpeningHour + " on " + dropinSpotOpeningDate.ToLongDateString() + ". Please check back later."); return; } } if (!player.IsRegisterdMember && Handler.IsDropinOwesExceedMax(player)) { ShowMessage("According to our records, the total amount you unpaid dropin fee reaches the maximum ($" + Manager.MaxDropinFeeOwe + "). Please make the payment prior to new reservations. If you would like e-transfer, send to " + Manager.AdminEmail + ". Thanks"); return; } } if (Handler.IsSpotAvailable(CurrentPool, TargetGameDate) || CurrentPool.Members.Exists(player.Id) && Handler.AllowMemberAddReservation(CurrentPool, TargetGameDate, player)) { //Check to see if the player has dropin spot in another pool on same day if (IsReservedInAnotherPool(playerId)) { return; } } else { //Todo : Power reserve for Monday player with high factor //Power reserve if (Manager.ActionPermitted(Actions.Power_Reserve, CurrentUser.Role)) { Session[Constants.ACTION_TYPE] = Constants.ACTION_POWER_RESERVE; ShowPopupModal("Sorry, But all spots are already filled up. Would you like to reserve an EXTRA spot?"); } else { Session[Constants.ACTION_TYPE] = Constants.ACTION_ADD_WAITING_LIST; ShowPopupModal("Sorry, But all spots are already filled up. Would you like to put onto the waiting list?"); } return; } Session[Constants.ACTION_TYPE] = Constants.ACTION_RESERVE; ShowPopupModal("Are you sure to reserve?"); }