예제 #1
0
        private void AddMember(String playerId)
        {
            CurrentPool.Members.Add(new Member(playerId));
            //Add to reserved list for the future games
            foreach (Game game in CurrentPool.Games)
            {
                if (game.Date >= DateTime.Today)
                {
                    game.Members.Add(new Attendee(playerId, InOutNoshow.In));
                }
            }
            //Change the player to club registered member and create membership fee it is  club member mode
            Player player = Manager.FindPlayerById(playerId);

            if (Manager.ClubMemberMode)
            {
                if (!player.IsRegisterdMember)
                {
                    player.IsRegisterdMember = true;
                    Fee fee = new Fee(Fee.FEETYPE_CLUB_MEMBERSHIP, Manager.RegisterMembeshipFee);
                    fee.FeeType = FeeTypeEnum.Membership.ToString();
                    fee.Date    = DateTime.Today;
                    player.Fees.Add(fee);
                }
            }
            else
            {
                Fee fee = new Fee(CurrentPool.MembershipFee);
                fee.FeeType = FeeTypeEnum.Membership.ToString();
                fee.FeeDesc = String.Format(Fee.FEETYPE_MEMBERSHIP, CurrentPool.Name);
                fee.Date    = DateTime.Today;
                player.Fees.Add(fee);
            }
            this.MemberListbox.DataSource = GetPlayers(CurrentPool.Members);
            this.MemberListbox.DataBind();
            this.MemberLb.Text = "Members(" + CurrentPool.Members.Count + ")";

            if (CurrentPool.DayOfWeek == DayOfWeek.Friday)
            {
                return;
            }
            //Register Friday games on same week or next week
            foreach (Pool pool in Manager.FindFridayPools())
            {
                Dropin dropin = pool.Dropins.FindByPlayerId(player.Id);
                if (dropin != null && !dropin.IsCoop)
                {
                    //Add reservation for all the games in this pool
                    foreach (Game game in pool.Games)
                    {
                        if (game.Date >= Manager.EastDateTimeToday)
                        {
                            Pickup pickup = game.Dropins.FindByPlayerId(playerId);
                            if (pickup == null)
                            {
                                pickup = new Pickup(playerId);
                                game.Dropins.Add(new Pickup(playerId));
                            }
                            pickup.Status = InOutNoshow.In;
                        }
                    }
                }
                DataAccess.Save(Manager);
            }
        }
예제 #2
0
        private void GenerationFeeReport()
        {
            List <Fee> allPaidFees = new List <Fee>();

            foreach (Player player in Manager.Players)
            {
                foreach (Fee fee in player.Fees)
                {
                    if (fee.IsPaid)
                    {
                        Fee paidFee = new Fee();
                        paidFee.PayDate = fee.PayDate;
                        paidFee.FeeType = fee.FeeType;
                        paidFee.Amount  = fee.Amount;
                        paidFee.FeeDesc = player.Name + "-" + fee.FeeDesc;
                        allPaidFees.Add(paidFee);
                    }
                }
            }
            this.FeeReportTable.Rows.Clear();
            this.FeeReportTable.Rows.Add(this.FeeReportHeaderRow);
            decimal           balance   = 0;
            IEnumerable <Fee> feesQuery = allPaidFees.OrderBy(fee => fee.PayDate);

            foreach (Fee paidFee in feesQuery)
            {
                TableRow  row      = new TableRow();
                TableCell dateCell = new TableCell();
                dateCell.Text = paidFee.PayDate.ToString("MMM. dd yyyy");
                row.Cells.Add(dateCell);
                TableCell typeCell = new TableCell();
                typeCell.Text = paidFee.FeeType.ToString();
                row.Cells.Add(typeCell);
                TableCell descCell = new TableCell();
                descCell.Text = paidFee.FeeDesc;
                row.Cells.Add(descCell);
                TableCell creditCell = new TableCell();
                if (paidFee.Amount > 0)
                {
                    creditCell.Text = paidFee.Amount.ToString();
                }
                row.Cells.Add(creditCell);
                TableCell debitCell = new TableCell();
                if (paidFee.Amount < 0)
                {
                    debitCell.Text = paidFee.Amount.ToString();
                }
                row.Cells.Add(debitCell);
                TableCell balanceCell = new TableCell();
                balance         += paidFee.Amount;
                balanceCell.Text = balance.ToString();
                row.Cells.Add(balanceCell);
                this.FeeReportTable.Rows.AddAt(1, row);
            }

/*            TableRow balanceRow = new TableRow();
 *          TableCell labelCell = new TableCell();
 *          labelCell.Text = "Balance";
 *          balanceRow.Cells.Add(labelCell);
 *          balanceRow.Cells.Add(new TableCell());
 *          balanceRow.Cells.Add(new TableCell());
 *          balanceRow.Cells.Add(new TableCell());
 *          TableCell balanceCell = new TableCell();
 *          balanceCell.Text = balance.ToString();
 *          balanceRow.Cells.Add(balanceCell);
 */
            //this.FeeReportTable.Rows.AddAt(0, balanceRow);
            this.FeeReportTable.Caption = "Fee & Payment Reports - Balance : $" + balance.ToString();
        }
예제 #3
0
        private CostReference CreateDropinFee(Pool pool, DateTime gameDate, String playerId)
        {
            Player player = Manager.FindPlayerById(playerId);

            //No cost if clust member mode and the player is the registered member
            if (Manager.ClubMemberMode && player.IsRegisterdMember)
            {
                return(new CostReference(CostType.CLUB_MEMBER, null));
            }
            //No fee created and remove one transfer for the dropin player who is the member with cancelled spot in another pool on same day.
            foreach (Pool thePool in Manager.Pools)
            {
                if (thePool.Name != thePool.Name && thePool.DayOfWeek == thePool.DayOfWeek && thePool.Members.Exists(playerId))
                {
                    player.RemoveTransferByGameDate(gameDate);
                    return(new CostReference(CostType.TRANSFER, null));
                }
            }
            //Check to see if the player has free of charge of dropin
            if (player.FreeDropin > 0)
            {
                player.FreeDropin--;

                /*Fee fee = new Fee(0);
                *  fee.Date = gameDate;
                *  fee.FeeType = "Free -" + String.Format(Fee.FEETYPE_DROPIN, pool.Name);
                *  fee.IsPaid = false;
                *  player.Fees.Add(fee);*/
                return(new CostReference(CostType.FREE, null));
            }
            //Check to see if the player has paid total amount that reaches the membership fee
            if (ReachMaxDropinFeePaid(player))
            {
                return(new CostReference(CostType.REACH_MAX, null));
            }
            if (player.TransferUsed < Manager.MaxTransfers)
            {
                Transfer transfer = player.GetAvailableTransfer(gameDate);
                if (transfer != null)
                {
                    transfer.IsUsed        = true;
                    transfer.ApplyGameDate = gameDate;
                    return(new CostReference(CostType.TRANSFER, transfer.TransferId));
                }
            }
            //Deduct from prepaid balance if it is enough
            if (player.PrePaidBalance >= Manager.DropinFee)
            {
                player.PrePaidBalance -= Manager.DropinFee;
                return(new CostReference(CostType.PRE_PAID, null));
            }
            //last case is to create dropin fee
            Fee fee = new Fee(Manager.DropinFee);

            fee.Date    = gameDate;
            fee.FeeType = FeeTypeEnum.Dropin.ToString();
            fee.FeeDesc = String.Format(Fee.FEETYPE_DROPIN, pool.Name);
            player.Fees.Add(fee);
            //Send wechat reminder if dropin fee reaches the max allow
            if (!player.IsRegisterdMember && IsDropinOwesExceedMax(player))
            {
                String message = "[System Info] Hi, " + player.Name + ". According to our records, the total amount you unpaid dropin fee reaches the maximum ($" + Manager.MaxDropinFeeOwe + "). Please make the payment ASAP, in order to continue making reservation in the future.";
                Manager.WechatNotifier.AddNotifyWechatMessage(player, message);
            }
            return(new CostReference(CostType.FEE, fee.FeeId));
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Application[Constants.DATA] = DataAccess.LoadReservation();
            if (!IsPostBack)
            {
                //
                if (null != Session[Constants.SUPER_ADMIN])
                {
                    ((TextBox)Master.FindControl("PasscodeTb")).Text = Session[Constants.SUPER_ADMIN].ToString();
                }
                //Bind player list
                int selectPlayerIndex = this.PlayerListbox.SelectedIndex;
                this.PlayerListbox.DataSource     = Manager.Players.OrderBy(player => player.Name);
                this.PlayerListbox.DataTextField  = "Name";
                this.PlayerListbox.DataValueField = "Id";
                this.PlayerListbox.DataBind();
                this.PlayerListbox.SelectedIndex = selectPlayerIndex;
                //Add fee type into FeetypeDropinDownList
                this.FeeTypeDDL.Items.Clear();
                foreach (FeeTypeEnum value in Enum.GetValues(typeof(FeeTypeEnum)))
                {
                    this.FeeTypeDDL.Items.Add(value.ToString());
                }
            }
            //
            this.ResetFeeBtn.OnClientClick = "if ( !confirm('Are you sure you want to delete this fee?')) return false;";
            if (Convert.ToString(ViewState["Generated"]) == "true")
            {
                ShowFees();
            }
            GenerationFeeReport();
            List <Fee> allCredits  = new List <Fee>();
            decimal    totalAmount = 0;

            foreach (Player player in Manager.Players)
            {
                foreach (Fee fee in player.Fees)
                {
                    if (fee.FeeDesc.StartsWith("Credit"))
                    {
                        Fee paidFee = new Fee();
                        paidFee.PayDate = fee.PayDate;
                        paidFee.FeeType = fee.FeeType;
                        paidFee.Amount  = fee.Amount;
                        paidFee.FeeDesc = player.Name + "-" + fee.FeeDesc;
                        totalAmount     = totalAmount + fee.Amount;
                        allCredits.Add(paidFee);
                    }
                }
            }

            foreach (Fee fee in allCredits)
            {
                TableRow  row  = new TableRow();
                TableCell cell = new TableCell();
                cell.Text = fee.FeeDesc;
                row.Cells.Add(cell);
                cell      = new TableCell();
                cell.Text = fee.Amount.ToString();
                row.Cells.Add(cell);
                this.TransferTable.Rows.Add(row);
            }
            TableRow  totalRow  = new TableRow();
            TableCell totalcell = new TableCell();

            totalcell.Text = "Total";
            totalRow.Cells.Add(totalcell);
            totalcell      = new TableCell();
            totalcell.Text = totalAmount.ToString();
            totalRow.Cells.Add(totalcell);
            this.TransferTable.Rows.Add(totalRow);
        }