コード例 #1
0
        public ActionResult Edit(TournamentDivision tournamentdivision, IEnumerable<CompetitorDivision> competitors)
        {
            if (ModelState.IsValid)
            {
                foreach(CompetitorDivision competitorDivision in competitors)
                {
                    db.CompetitorDivisions.Attach(competitorDivision);
                    db.ObjectStateManager.ChangeObjectState(competitorDivision, EntityState.Modified);
                }

                db.TournamentDivisions.Attach(tournamentdivision);
                db.ObjectStateManager.ChangeObjectState(tournamentdivision, EntityState.Modified);
                db.SaveChanges();

                return RedirectToAction("Details", "Tournament", new { id = tournamentdivision.TournamentId});
            }
            InitViewBag(tournamentdivision);
            return View(tournamentdivision);
        }
コード例 #2
0
        private void InitViewBag(TournamentDivision tournamentdivision)
        {
            ViewBag.Competitors = db.CompetitorDivisions.Where(m => m.DivisionId == tournamentdivision.DivisionId && m.Competitor.TournamentId == tournamentdivision.TournamentId).OrderBy(m => m.Competitor.Student.FirstName).ThenBy(m => m.Competitor.Student.LastName);
            ViewBag.DivisionId = new SelectList(db.Divisions, "DivisionId", "DivisionName", tournamentdivision.DivisionId);
            ViewBag.TournamentId = new SelectList(db.Tournaments, "TournamentId", "TournamentName", tournamentdivision.TournamentId);

            GetTournamentStats(tournamentdivision.Tournament);
        }
コード例 #3
0
 /// <summary>
 /// Create a new TournamentDivision object.
 /// </summary>
 /// <param name="tournamentId">Initial value of the TournamentId property.</param>
 /// <param name="divisionId">Initial value of the DivisionId property.</param>
 /// <param name="isCompleted">Initial value of the IsCompleted property.</param>
 /// <param name="medalsReceived">Initial value of the MedalsReceived property.</param>
 public static TournamentDivision CreateTournamentDivision(global::System.Int32 tournamentId, global::System.Int32 divisionId, global::System.Boolean isCompleted, global::System.Boolean medalsReceived)
 {
     TournamentDivision tournamentDivision = new TournamentDivision();
     tournamentDivision.TournamentId = tournamentId;
     tournamentDivision.DivisionId = divisionId;
     tournamentDivision.IsCompleted = isCompleted;
     tournamentDivision.MedalsReceived = medalsReceived;
     return tournamentDivision;
 }
コード例 #4
0
        private void createEventSheet(int tournamentId, TournamentDivision tournamentDivision)
        {
            List<CompetitorDivision> competitorDivisions = db.CompetitorDivisions.Where(m => m.Competitor.TournamentId == tournamentId && m.DivisionId == tournamentDivision.DivisionId).ToList();

            PdfPTable headerTable = new PdfPTable(4);
            headerTable.HorizontalAlignment = Element.ALIGN_LEFT;
            headerTable.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
            headerTable.DefaultCell.Border = Rectangle.NO_BORDER;
            headerTable.WidthPercentage = 100f;
            headerTable.SetWidths(new float[] { 10, 60, 15, 15 });

            headerTable.AddCell(Image.GetInstance(Server.MapPath("/Content/images/reportLogo.gif")));
            headerTable.AddCell(new Phrase(tournamentDivision.Division.DivisionName, fontH1));
            headerTable.AddCell("Ring No.:");

            PdfContentByte pdfContentByte = PDFWriter.DirectContent;
            Barcode128 code128 = new Barcode128 { Code = string.Format("*{0}*", tournamentDivision.DivisionId), Extended = false, CodeType = Barcode.CODE128/*, Font = null*/ };
            headerTable.AddCell(code128.CreateImageWithBarcode(pdfContentByte, null, null));

            document.Add(headerTable);

            if (tournamentDivision.Division.DivisionTypeId == WKSADBConstants.DivisionType_SparringId)
            {
                //document.SetMargins(27f, 27f, 27f, 27f);
                PdfPTable table = new PdfPTable(5);
                table.HorizontalAlignment = Element.ALIGN_LEFT;
                table.DefaultCell.Border = Rectangle.NO_BORDER;
                table.WidthPercentage = 100f;
                table.SpacingBefore = 5f;
                table.SpacingAfter = 5f;

                int byeCount = getByeCount(competitorDivisions.Count);

                PdfPCell cell = iTextSharpHelper.CreateCell(string.Format("Competitor List (division requires {0} bye{1})", byeCount, byeCount == 1 ? string.Empty : "s"), new Font(baseFont, 9, Font.BOLD), 0, Element.ALIGN_LEFT, null);
                cell.Colspan = 5;
                table.AddCell(cell);

                foreach (CompetitorDivision competitorDivision in competitorDivisions)
                {
                    table.AddCell(iTextSharpHelper.CreateCell(string.Format("{0} {1} ({2})", competitorDivision.Competitor.Student.FirstName, competitorDivision.Competitor.Student.LastName, competitorDivision.Competitor.Student.School.SchoolName), new Font(baseFont, 6), 0, Element.ALIGN_LEFT, null));
                }

                int remaining = competitorDivisions.Count % 5;
                for (int i = 0; i < 5 - remaining; i++)
                {
                    table.AddCell("");
                }

                document.Add(table);

                Image sparringTreeImage = Image.GetInstance(Server.MapPath("/Content/images/sparringtreev03.jpg"));
                // Have to scale as it's in 150dpi
                sparringTreeImage.ScalePercent(48f);
                document.Add(sparringTreeImage);

                //document.Add(CreateByeChartTable());
            }
            else
            {
                //document.SetMargins(36f, 36f, 36f, 36f);
                PdfPTable table = new PdfPTable(13);
                table.HorizontalAlignment = Element.ALIGN_LEFT;
                table.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
                table.DefaultCell.PaddingTop = 10f;
                table.WidthPercentage = 100f;
                table.SetWidths(new float[] { 30, 2, 8, 2, 8, 2, 8, 2, 8, 2, 8, 2, 8 });
                table.SpacingBefore = 20f;

                PdfPCell gapCell = new PdfPCell();
                gapCell.Rowspan = competitorDivisions.Count() + 1;
                gapCell.Border = 0;

                table.AddCell(iTextSharpHelper.CreateCell(string.Empty, new Font(baseFont, 9), 0, Element.ALIGN_CENTER, null));
                table.AddCell(gapCell);
                table.AddCell(iTextSharpHelper.CreateCell("Judge 1", new Font(baseFont, 9), 0, Element.ALIGN_CENTER, null));
                table.AddCell(gapCell);
                table.AddCell(iTextSharpHelper.CreateCell("Judge 2", new Font(baseFont, 9), 0, Element.ALIGN_CENTER, null));
                table.AddCell(gapCell);
                table.AddCell(iTextSharpHelper.CreateCell("Judge 3", new Font(baseFont, 9), 0, Element.ALIGN_CENTER, null));
                table.AddCell(gapCell);
                table.AddCell(iTextSharpHelper.CreateCell("Judge 4", new Font(baseFont, 9), 0, Element.ALIGN_CENTER, null));
                table.AddCell(gapCell);
                table.AddCell(iTextSharpHelper.CreateCell("Judge 5", new Font(baseFont, 9), 0, Element.ALIGN_CENTER, null));
                table.AddCell(gapCell);
                table.AddCell(iTextSharpHelper.CreateCell("Total", new Font(baseFont, 9, Font.BOLD), 0, Element.ALIGN_CENTER, null));

                // Randomise Competitors
                competitorDivisions.Shuffle();
                foreach (CompetitorDivision competitorDivision in competitorDivisions)
                {
                    table.AddCell(string.Format("{0} {1}", competitorDivision.Competitor.Student.FirstName, competitorDivision.Competitor.Student.LastName));
                    table.AddCell(string.Empty);
                    table.AddCell(string.Empty);
                    table.AddCell(string.Empty);
                    table.AddCell(string.Empty);
                    table.AddCell(string.Empty);
                    table.AddCell(string.Empty);
                }

                document.Add(table);
            }
        }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the TournamentDivisions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTournamentDivisions(TournamentDivision tournamentDivision)
 {
     base.AddObject("TournamentDivisions", tournamentDivision);
 }