//Move spot to high pool protected void MoveFromCurrentPool_Click(object sender, EventArgs e) { if (Manager.ActionPermitted(Actions.Move_To_High_Pool, CurrentUser.Role)) { ImageButton lbtn = (ImageButton)sender; Session[Constants.CURRENT_PLAYER_ID] = lbtn.ID.Split(',')[0]; Session[Constants.ACTION_TYPE] = Constants.ACTION_MOVE_RESERVATION; ShowPopupModal("Are you sure to move?"); } }
private void FillNavTable() { if (!Manager.ActionPermitted(Actions.View_Past_Games, CurrentUser.Role) && !Manager.ActionPermitted(Actions.View_Future_Games, CurrentUser.Role)) { this.GameInfoTable.Caption = CurrentPool.DayOfWeek + " Pool " + CurrentPool.Name; return; } TableRow navRow = new TableRow(); //Previous TableCell prevCell = new TableCell(); LinkButton lbtn = new LinkButton(); lbtn.Text = "< Prev"; lbtn.Font.Bold = true; lbtn.Font.Size = new FontUnit(Constants.LINKBUTTON_FONTSIZE); lbtn.ID = "PrevGame"; lbtn.Click += new EventHandler(Navigate_Click); prevCell.Controls.Add(lbtn); prevCell.HorizontalAlign = HorizontalAlign.Left; Game prevGame = GetPreviousGame(); if (prevGame == null) { lbtn.Enabled = false; } navRow.Cells.Add(prevCell); //GameInfo text TableCell gameinfoCell = new TableCell(); gameinfoCell.Text = CurrentPool.DayOfWeek + " Pool " + CurrentPool.Name; gameinfoCell.HorizontalAlign = HorizontalAlign.Center; navRow.Cells.Add(gameinfoCell); //Next TableCell nextCell = new TableCell(); lbtn = new LinkButton(); lbtn.Text = "Next >"; lbtn.Font.Bold = true; lbtn.Font.Size = new FontUnit(Constants.LINKBUTTON_FONTSIZE); lbtn.ID = "NextGame"; lbtn.Click += new EventHandler(Navigate_Click); Game nextGame = GetNextGame(); if (nextGame == null) { lbtn.Enabled = false; } nextCell.Controls.Add(lbtn); nextCell.HorizontalAlign = HorizontalAlign.Right; navRow.Cells.Add(nextCell); this.NavTable.Rows.Add(navRow); }
//Cancel primary members and dropn pickup, not for waiting list protected void Cancel_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; Session[Constants.ACTION_TYPE] = Constants.ACTION_CANCEL; ShowPopupModal("Are you sure to cancel?"); }
public bool IsSuperAdmin() { if (Request.Cookies[Constants.PRIMARY_USER] != null) { String userId = Request.Cookies[Constants.PRIMARY_USER][Constants.USER_ID]; Player player = Manager.FindPlayerById(userId); if (Manager.ActionPermitted(Actions.Admin_Management, player.Role)) { return(true); } } return(false); }
private Game GetNextGame() { List <Game> games = CurrentPool.Games; IEnumerable <Game> gameQuery = games.OrderBy(game => game.Date); foreach (Game game in gameQuery) { if ((Manager.ActionPermitted(Actions.View_Future_Games, CurrentUser.Role) || game.Date >= Manager.EastDateTimeToday) && game.Date > TargetGameDate) { return(game); } } return(null); }
//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 bool IsSuperAdmin() { if (Request.Cookies[Constants.PRIMARY_USER] != null) { String userId = Request.Cookies[Constants.PRIMARY_USER][Constants.USER_ID]; Player player = Manager.FindPlayerById(userId); if (Manager.ActionPermitted(Actions.Admin_Management, player.Role)) { return(true); } } TextBox passcodeTb = (TextBox)Master.FindControl("PasscodeTb"); if (Manager.SuperAdmin != passcodeTb.Text) { ClientScript.RegisterStartupScript(Page.GetType(), "msgid", "alert('Wrong passcode! Re-enter your passcode and try again')", true); return(false); } Session[Constants.SUPER_ADMIN] = passcodeTb.Text; return(true); }
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); }
private TableRow CreateDropinTableRow(Player player, Attendee attendee, bool isWaiting) { TableRow row = new TableRow(); TableCell nameCell = new TableCell(); LinkButton nameLink = new LinkButton(); nameLink.Text = player.Name; nameLink.Font.Bold = true; nameLink.Font.Size = new FontUnit(Constants.LINKBUTTON_FONTSIZE); nameLink.ID = player.Id + ", DROPIN"; nameCell.Controls.Add(nameLink); foreach (Fee fee in player.Fees) { if (!fee.IsPaid && fee.Amount > 0) { Image image = new Image(); image.ImageUrl = "~/Icons/dollar.png"; nameCell.Controls.Add(image); } } row.Cells.Add(nameCell); row.Cells.Add(nameCell); TableCell actionCell = new TableCell(); actionCell.HorizontalAlign = HorizontalAlign.Right; ImageButton imageBtn = new ImageButton(); imageBtn.ID = player.Id; if (isWaiting) { imageBtn.ImageUrl = "~/Icons/Remove.png"; imageBtn.Click += new ImageClickEventHandler(Cancel_Waiting_Click); } else if (attendee.Status == InOutNoshow.In) { imageBtn.ImageUrl = "~/Icons/Remove.png"; imageBtn.Click += new ImageClickEventHandler(Cancel_Click); } else if (attendee.Status == InOutNoshow.NoShow) { imageBtn.ImageUrl = "~/Icons/noShow.png"; imageBtn.Click += new ImageClickEventHandler(Cancel_Click); } else { imageBtn.ImageUrl = "~/Icons/Add.png"; imageBtn.Click += new ImageClickEventHandler(Reserve_Click); } if (isWaiting || attendee.Status == InOutNoshow.In) { if (CurrentPool.IsLowPool && Manager.ActionPermitted(Actions.Move_To_High_Pool, CurrentUser.Role)) { ImageButton moveBtn = new ImageButton(); moveBtn.ID = player.Id + ",move"; moveBtn.Width = new Unit(Constants.IMAGE_BUTTON_SIZE); moveBtn.Height = new Unit(Constants.IMAGE_BUTTON_SIZE); moveBtn.ImageUrl = "~/Icons/Move.png"; moveBtn.Click += MoveFromCurrentPool_Click; actionCell.Controls.Add(moveBtn); } } imageBtn.Width = new Unit(Constants.IMAGE_BUTTON_SIZE); imageBtn.Height = new Unit(Constants.IMAGE_BUTTON_SIZE); actionCell.Controls.Add(imageBtn); row.Cells.Add(actionCell); if (Handler.IsPermitted(Actions.View_Player_Details, player)) { nameLink.Click += new EventHandler(Username_Click); } if (!Handler.IsPermitted(Actions.Reserve_Player, player)) { imageBtn.Enabled = false; } return(row); }
private void FillDropinTable(Pool pool, DateTime gameDate) { //Calcuate stats for dropins Game game = pool.FindGameByDate(gameDate); if (game.DropinRestricted) { DropinCandidateTable.Caption = "Dropin Restricted for this time!"; return; } List <Player> players = GetDropinPlayers(pool, gameDate); Dropin nextIntern = null; if (!pool.IsLowPool && pool.AutoCoopReserve) { Game lowPoolGame = Manager.FindSameDayPool(pool).FindGameByDate(gameDate); nextIntern = Handler.FindNextCoopCandidateToMoveHighPool(CurrentPool, game, lowPoolGame); } foreach (Player player in players) { Attendee attdenee = game.Dropins.FindByPlayerId(player.Id); if (attdenee.Status != InOutNoshow.Out) { TableRow row = CreateDropinTableRow(player, attdenee, game.WaitingList.Exists(player.Id)); this.DropinTable.Rows.Add(row); this.DropinTable.Visible = true; } else if (!game.WaitingList.Exists(player.Id))// if (dropinSpotAvailable) { Dropin dropin = CurrentPool.Dropins.FindByPlayerId(player.Id); if (dropin != null) { if (!Manager.ActionPermitted(Actions.Power_Reserve, CurrentUser.Role) && dropin.IsCoop && pool.AutoCoopReserve && (nextIntern == null || nextIntern.PlayerId != dropin.PlayerId)) { continue; } TableRow row = CreateDropinTableRow(player, attdenee, game.WaitingList.Exists(player.Id)); this.DropinCandidateTable.Rows.Add(row); if (DropinCandidateTable.Rows.Count % 2 == 1) { row.BackColor = DropinCandidateTable.BorderColor; } if (player.Id == GetOperatorId()) { row.BorderStyle = BorderStyle.Double; row.BackColor = System.Drawing.Color.DarkOrange; } if (nextIntern != null && nextIntern.PlayerId == dropin.PlayerId) { row.BorderStyle = BorderStyle.Double; row.BackColor = System.Drawing.Color.Beige; } } } } // List<Player> waitingList = Manager.FindPlayersByIds(game.WaitingList.getPlayerIds()); foreach (Waiting waiting in game.WaitingList.Items) { Player player = Manager.FindPlayerById(waiting.PlayerId); TableRow row = CreateDropinTableRow(player, game.Dropins.FindByPlayerId(player.Id), game.WaitingList.Exists(player.Id)); this.DropinWaitingTable.Rows.Add(row); this.DropinWaitingTable.Visible = true; } if (pool.AllowAddNewDropinName && Manager.ActionPermitted(Actions.Add_New_Player, CurrentUser.Role)) { TableRow addRow = new TableRow(); TableCell addNameCell = new TableCell(); // TextBox nameTb = new TextBox(); //nameTb.ID = "DropinNameTb"; //this.DropinNameTb.Visible = true; addNameCell.Controls.Add(DropinNameTb); // addNameCell.Controls.Add(RequiredFieldValidator); addRow.Cells.Add(addNameCell); TableCell addCell = new TableCell(); addCell.HorizontalAlign = HorizontalAlign.Right; ImageButton addImageBtn = new ImageButton(); addImageBtn.ImageUrl = "~/Icons/Add.png"; addImageBtn.Width = new Unit(Constants.IMAGE_BUTTON_SIZE); addImageBtn.Height = new Unit(Constants.IMAGE_BUTTON_SIZE); addImageBtn.Click += new ImageClickEventHandler(AddNewDropin_Click); addCell.Controls.Add(addImageBtn); addRow.Cells.Add(addCell); this.DropinCandidateTable.Rows.Add(addRow); } else { this.DropinNameTb.Visible = false; } }
private void FillMemberTable(Pool pool, DateTime date) { IEnumerable <Player> playerQuery = OrderMembersByName(pool, date); bool spotsFilledup = !Handler.IsSpotAvailable(pool, date); bool alterbackcolor = false; foreach (Player player in playerQuery) { //If this player is on the waiting list, don't list it in member section Game comingGame = pool.FindGameByDate(date); if (comingGame.WaitingList.Exists(player.Id)) { continue; } // Member member = pool.Members.FindByPlayerId(player.Id); TableRow row = new TableRow(); if (alterbackcolor) { row.BackColor = MemberTable.BorderColor; } alterbackcolor = !alterbackcolor; if (player.Id == GetOperatorId()) { row.BackColor = System.Drawing.Color.CadetBlue; row.BorderStyle = BorderStyle.Outset; } TableCell nameCell = new TableCell(); LinkButton nameLink = new LinkButton(); nameLink.Text = player.Name; nameLink.Font.Bold = true; nameLink.Font.Size = new FontUnit(Constants.LINKBUTTON_FONTSIZE); nameLink.ID = player.Id + ",MEMEBER"; this.MemberTable.Rows.Add(row); nameCell.Controls.Add(nameLink); /* if (player.Marked) * { * Image image = new Image(); * image.ImageUrl = "~/Icons/Colorball.png"; * //nameCell.Controls.Add(image); * }*/ foreach (Fee fee in player.Fees) { if (!fee.IsPaid && fee.Amount > 0) { Image image = new Image(); image.ImageUrl = "~/Icons/dollar.png"; nameCell.Controls.Add(image); } } row.Cells.Add(nameCell); TableCell statusCell = new TableCell(); statusCell.HorizontalAlign = HorizontalAlign.Right; ImageButton imageBtn = new ImageButton(); imageBtn.ID = player.Id; //If current user is not permit to reserve for this player, disable the image btn if (Handler.IsPermitted(Actions.View_Player_Details, player)) { nameLink.Click += new EventHandler(Username_Click); } if (!Handler.IsPermitted(Actions.Reserve_Player, player)) { imageBtn.Enabled = false; } Game game = pool.FindGameByDate(date); Attendee attdenee = game.Members.FindByPlayerId(player.Id); if (attdenee.Status == InOutNoshow.Out) { imageBtn.ImageUrl = "~/Icons/Out.png"; imageBtn.Click += new ImageClickEventHandler(Reserve_Click); } else if (attdenee.Status == InOutNoshow.In) { if (attdenee.Confirmed) { imageBtn.ImageUrl = "~/Icons/In.png"; imageBtn.Click += new ImageClickEventHandler(Cancel_Click); if (CurrentPool.IsLowPool && Manager.ActionPermitted(Actions.Move_To_High_Pool, CurrentUser.Role)) { ImageButton moveBtn = new ImageButton(); moveBtn.ID = player.Id + ",move"; moveBtn.Width = new Unit(Constants.IMAGE_BUTTON_SIZE); moveBtn.Height = new Unit(Constants.IMAGE_BUTTON_SIZE); moveBtn.ImageUrl = "~/Icons/Move.png"; moveBtn.Click += MoveFromCurrentPool_Click; statusCell.Controls.Add(moveBtn); } } else { imageBtn.ImageUrl = "~/Icons/toConfirm.png"; imageBtn.Click += new ImageClickEventHandler(Confirm_Click); } } else//No show { imageBtn.ImageUrl = "~/Icons/noShow.png"; imageBtn.Click += new ImageClickEventHandler(Cancel_Click); } //imageBtn.Click += new ImageClickEventHandler(MemberChangeAttendance_Click); imageBtn.Width = new Unit(Constants.IMAGE_BUTTON_SIZE); imageBtn.Height = new Unit(Constants.IMAGE_BUTTON_SIZE); // imageBtn.CssClass = "imageBtn"; statusCell.Controls.Add(imageBtn); row.Cells.Add(statusCell); } }
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?"); }