Ejemplo n.º 1
0
            public ImportedTicket(IList <RaffleTicket> originals)
            {
                this.originals = originals;
                Person         = originals.First().Person;
                Account        = Names.DefaultAccount;
                Type           = "Melave Malka Raffle";

                Tickets = ((IListSource) new RowListBinder(Program.Table <RaffleTicket>(), originals.Cast <Row>().ToList())).GetList();

                if (originals.Count > 1)
                {
                    SubType = "tickets #" + originals.Join(", #", t => t.TicketId.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    SubType = "ticket #" + originals.First().TicketId.ToString(CultureInfo.InvariantCulture);
                }
                Amount = RaffleTicket.CalcPrice(originals.Count);

                Comments = (originals.Select(t => (t.Comments ?? "").Trim())
                            .Distinct(StringComparer.OrdinalIgnoreCase)
                            .Join(Environment.NewLine)
                            + "\r\n(imported from Rafflizer)").Trim();

                AmountPaid    = RaffleTicket.CalcPrice(originals.Count(t => t.Paid));
                PaymentMethod = AmountPaid > 0 ? "Cash" : "Unpaid";
            }
Ejemplo n.º 2
0
        private void gridView_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
        {
            switch (e.SummaryProcess)
            {
            case CustomSummaryProcess.Start:
                e.TotalValue = 0;
                break;

            case CustomSummaryProcess.Calculate:
                e.TotalValue = (int)e.TotalValue + 1;
                break;

            case CustomSummaryProcess.Finalize:
                e.TotalValue      = RaffleTicket.CalcPrice((int)e.TotalValue);
                e.TotalValueReady = true;
                break;
            }
        }
Ejemplo n.º 3
0
        void UpdateStats()
        {
            ticketCount.Caption = tickets.Rows.Count + " Tickets";
            totalValue.Caption  = "Total value: " +
                                  tickets.Rows.GroupBy(t => t.Person, (person, set) => set.Count())
                                  .Sum(c => RaffleTicket.CalcPrice(c))
                                  .ToString("c0", CultureInfo.CurrentCulture)

                                  + "; paid: "
                                  + tickets.Rows.Where(t => t.Paid)
                                  .GroupBy(t => t.Person, (person, set) => set.Count())
                                  .Sum(c => RaffleTicket.CalcPrice(c))
                                  .ToString("c0", CultureInfo.CurrentCulture);

            IList <int> idHoles;

            if (tickets.Rows.Count == 0)
            {
                idHoles = new int[0];
            }
            else
            {
                idHoles = Enumerable.Range(1, tickets.Rows.Max(t => t.TicketId))
                          .Except(tickets.Rows.Select(t => t.TicketId))
                          .ToList();
            }

            if (idHoles.Count == 0)
            {
                holeMessage.Caption = "No Holes";
                holeMessage.Appearance.ForeColor = Color.Green;
            }
            else if (idHoles.Count == 1)
            {
                holeMessage.Appearance.ForeColor = Color.Red;
                holeMessage.Caption = "Ticket #" + idHoles.First().ToString(CultureInfo.CurrentCulture) + " is missing";
            }
            else
            {
                holeMessage.Appearance.ForeColor = Color.Red;
                var message = new StringBuilder();

                for (int i = 0; i < idHoles.Count;)
                {
                    var start = idHoles[i];
                    int size  = 1;
                    while (++i < idHoles.Count && idHoles[i] == start + size)
                    {
                        size++;
                    }

                    message.Append(message.Length == 0 ? "Holes: " : ", ");

                    message.Append(start);
                    if (size == 2)
                    {
                        message.Append(", ").Append(start + 1);
                    }
                    else if (size > 2)
                    {
                        message.Append(" - ").Append(start + size - 1);
                    }
                }

                holeMessage.Caption = message.ToString();
            }
        }