private void printRingForUser(UserShows userShow, int UserID, Document doc, ref List<int> defaultUsers, ref int pageCount) { String html = ""; float[] ringColumns = new float[] { 300, 300, 300, 300}; Font pageFont = FontFactory.GetFont("Arial", 22, Font.NORMAL); Font headerFont = new Font(Font.HELVETICA, 16, Font.BOLD, Color.BLACK); Font judgeFont = FontFactory.GetFont("Arial", 9, Font.BOLD); Font notInClassFont = new Font(Font.HELVETICA, 6, Font.NORMAL, Color.BLACK); Font inClassFont = new Font(Font.HELVETICA, 9, Font.NORMAL, Color.BLACK); Font font = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.BLACK); Font font1 = FontFactory.GetFont("Arial", 18, Font.BOLD); Font dogNotInClass = new Font(Font.HELVETICA, 6, Font.NORMAL, Color.BLACK); Font dogInClass = new Font(Font.HELVETICA, 9, Font.NORMAL, Color.BLACK); Font dogDetailsInClass = new Font(Font.HELVETICA, 9, Font.BOLD, Color.BLACK); Fpp.WebModules.Business.User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); List<ShowDetails> showDetailsList = ShowDetails.GetShowDaysList(userShow.ShowID); doc.Add(new Paragraph(show.ShowName, pageFont)); Rings r = new Rings(); DataSet ringList = r.GetAllRingsForShow(userShow.ShowID, "ShowDate"); Dogs d = new Dogs(); DogClasses dc = new DogClasses(); DateTime dt = DateTime.Now; int currentRingID = 0; int ShowDetailsID = -1; int PrevShowDetailsID = -1; PdfPTable rings = new PdfPTable(ringColumns); int ringCnt = 0; PdfPCell cell = null; PdfPTable ringDetails = null; PdfPTable classDetailsTable = null; List<int> dogsRunningToday = new List<int>(); foreach (DataRow ringRow in ringList.Tables[0].Rows) { int RingID = Convert.ToInt32(ringRow["RingID"]); ShowDetailsID = Convert.ToInt32(ringRow["ShowDetailsID"]); if (ringRow.IsNull("ClassID")) { continue; } int ClassID = Convert.ToInt32(ringRow["ClassID"]); DateTime rowDT = Convert.ToDateTime(ringRow["ShowDate"]); if (rowDT != dt) { if (currentRingID != 0) { if (ringCnt % 4 != 0) { var remind = ringCnt % 4; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } } doc.Add(rings); if (currentUser.UserID == UserID) { doc.Add(getHandlerDetails(userShow, currentUser, PrevShowDetailsID, dogsRunningToday)); } else { User defaultHandler = new User(UserID); doc.Add(getHandlerDetails(userShow, defaultHandler, PrevShowDetailsID, dogsRunningToday)); } doc.NewPage(); if (dogsRunningToday.Count > 0) { pageCount++; } } dogsRunningToday.Clear(); doc.Add(new Paragraph(rowDT.ToString("dddd d MMM"), headerFont)); doc.Add(new Paragraph(" ", judgeFont)); dt = rowDT; rings = new PdfPTable(ringColumns); rings.WidthPercentage = 100; ringCnt = 0; } if (currentRingID != RingID) { ringCnt++; ringDetails = new PdfPTable(1); rings.AddCell(new PdfPCell( ringDetails)); List<Judge> judgeList = Judge.getJudgesForRingList(RingID); cell = new PdfPCell(new Phrase(new Chunk("Ring No " + ringRow["RingNo"].ToString(), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); foreach (Judge judge in judgeList) { cell = new PdfPCell(new Phrase(new Chunk(judge.Name, judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); } currentRingID = RingID; classDetailsTable = new PdfPTable(new float[] { 50, 225, 100 }); classDetailsTable.DefaultCell.BorderWidth = 0; ringDetails.AddCell(classDetailsTable); } html += "<tr>"; DataSet dogsList = d.GetDogsInClass(userShow.Userid, ClassID); int DogsInClass = d.dogsInClassCount(ClassID); String clsName = String.Format("{0} {1} {2} {3}", ShowClasses.expandCatagory(ringRow), ShowClasses.expandHeight(ringRow), ringRow["LongName"], ringRow["name"]); String grades = ShowClasses.shortenGrades(ringRow); int ix = clsName.IndexOf("Grd"); if (ix == -1) ix = clsName.IndexOf("Cmb"); if (ix > -1) { clsName = clsName.Substring(0, ix + 3) + " " + grades + " " + clsName.Substring(ix + 4); } else { ix = clsName.IndexOf(" "); clsName = clsName.Substring(0, ix) + " " + grades + " " + clsName.Substring(ix + 1); } if (dogsList.Tables[0].Rows.Count > 0) { Phrase[] tmpCells = new Phrase[3]; tmpCells[0] = new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogInClass)); tmpCells[1] = new Phrase(new Chunk(clsName, dogInClass)); tmpCells[2] = new Phrase(new Chunk(String.Format("({0})", DogsInClass), dogInClass)); int countDogs = 0; int DefaultHandler; Paragraph p = new Paragraph(); foreach (DataRow dogRow in dogsList.Tables[0].Rows) { int DogID = Convert.ToInt32(dogRow["DogID"]); DefaultHandler = Convert.ToInt32(dogRow["DefaultHandler"]); if (DefaultHandler == 0) DefaultHandler = -1; if ((DefaultHandler == -1 && currentUser.UserID == UserID) || (DefaultHandler == UserID) ) { if (countDogs == 0) { cell = new PdfPCell(tmpCells[0]); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); p.Add(tmpCells[1]); p.Add(Chunk.NEWLINE); } if (!dogsRunningToday.Contains(DogID)) { dogsRunningToday.Add(DogID); } String img = "<img src='data:image/gif;base64," + CreateImage(dogRow["DogColour"].ToString()) + "' />"; String dogName = dogRow["DogName"].ToString(); if (dogName.Length == 0) { dogName = dogRow["KCName"].ToString(); } var chunk = new Chunk(" ", dogDetailsInClass); chunk.SetBackground(new Color( System.Drawing.ColorTranslator.FromHtml(dogRow["DogColour"].ToString()) )); p.Add(new Phrase(chunk)); p.Add(new Phrase(new Chunk(String.Format(" [{1}] {0}", dogName, dogRow["RO"]), dogDetailsInClass))); p.Add(Chunk.NEWLINE); int AltHandler = Convert.ToInt32(dogRow["AltHandler"]); String HandlerName = ""; if (AltHandler > 0) { User u = new User(AltHandler); HandlerName = u.Name; html += "<div class='altHandler'>Handler:" + AltHandler + "</div>"; p.Add(Chunk.NEWLINE); p.Add(new Phrase(new Chunk(String.Format("Handler:", AltHandler),dogInClass))); } countDogs++; } else { if (defaultUsers != null && defaultUsers.IndexOf(DefaultHandler) == -1) { defaultUsers.Add(DefaultHandler); } } } if (countDogs == 0) { cell = new PdfPCell(new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(clsName, dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = true; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(String.Format("({0})", DogsInClass), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } else { cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = true; classDetailsTable.AddCell(cell); cell = new PdfPCell(tmpCells[2]); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } } else { cell = new PdfPCell(new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(clsName, dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(String.Format("({0})", DogsInClass), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } PrevShowDetailsID = ShowDetailsID; } if (ringCnt % 4 != 0) { var remind = ringCnt % 4; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } } if (currentUser.UserID == UserID) { doc.Add(getHandlerDetails(userShow, currentUser, PrevShowDetailsID, dogsRunningToday)); } else { User defaultHandler = new User(UserID); doc.Add(getHandlerDetails(userShow, defaultHandler, PrevShowDetailsID, dogsRunningToday)); } doc.NewPage(); }
protected void Page_Load(object sender, EventArgs e) { FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity; FormsAuthenticationTicket ticket = identity.Ticket; // get the roles stored as UserData into the ticket String[] userData = ticket.UserData.Split(':'); String[] roles = userData[0].Split(','); int id = Convert.ToInt32(userData[1]); String html = ""; Fpp.WebModules.Business.User currentUser = new User(id); int ShowID = Convert.ToInt32(Request["showid"]); Shows show = new Shows(ShowID); List<ShowDetails> showDetailsList = ShowDetails.GetShowDaysList(ShowID); html += "<h2>" + show.ShowName + "</h2>"; Rings r = new Rings(); DataSet ringList = r.GetAllRingsForShow(ShowID, "ShowDate"); Dogs d = new Dogs(); DogClasses dc = new DogClasses(); DateTime dt = DateTime.Now; Boolean newday = false; int currentRingID = 0; foreach (DataRow ringRow in ringList.Tables[0].Rows) { int RingID = Convert.ToInt32(ringRow["RingID"]); if (ringRow.IsNull("ClassID") ) { continue; } int ClassID = Convert.ToInt32(ringRow["ClassID"]); DateTime rowDT = Convert.ToDateTime(ringRow["ShowDate"]); if (rowDT != dt) { newday = true; if (currentRingID != 0) { html += "</table></div>"; html += "<div class='pagebreak'></div>"; } html += "<div class='clsDate'>" + rowDT.ToString("dddd d MMM") + "</div>"; dt = rowDT; } if (currentRingID != RingID) { List<Judge> judgeList = Judge.getJudgesForRingList(RingID); if (currentRingID != 0 && !newday) { html += "</table></div>"; } html += "<div class='Ring'>"; html += "<table class='roClassesTbl'>"; html += "<tr class='ringInfo'>"; html += "<td colspan='3'>" + "<div class='roTitle centered'>Ring No " + ringRow["RingNo"].ToString() + "</div>"; foreach (Judge judge in judgeList) { html += "<div class='roTitle centered'>" + judge.Name + "</div>"; } html += "</td></tr>"; currentRingID = RingID; } html += "<tr>"; DataSet dogsList = d.GetDogsInClass(currentUser.UserID, ClassID); int DogsInClass = d.dogsInClassCount(ClassID); String clsName = ShowClasses.expandCatagory(ringRow) + " " + ShowClasses.expandHeight(ringRow) + ringRow["name"].ToString(); String grades = ShowClasses.shortenGrades(ringRow); int ix = clsName.IndexOf("Grd"); if (ix == -1) ix = clsName.IndexOf("Cmb"); if (ix > -1) { clsName = clsName.Substring(0, ix + 3) + " (" + grades + ") " + clsName.Substring(ix + 4); } else { ix = clsName.IndexOf(" "); clsName = clsName.Substring(0, ix) + " (" + grades + ") " + clsName.Substring(ix + 1); } if (dogsList.Tables[0].Rows.Count > 0) { html += "<td valign='top' class='clsRing InClass'>" + ringRow["ClsNo"] + "</td>"; html += "<td valign='top' class='clsDetails InClass'><div>" + clsName + "</div>"; foreach (DataRow dogRow in dogsList.Tables[0].Rows) { String img = "<img src='data:image/gif;base64," + CreateImage(dogRow["DogColour"].ToString()) + "' />"; html += String.Format("<div class='dogInClass'><div style='background:{2};' class='dogIcon'>{3}</div>[{1}] {0}</div>", dogRow["DogName"], dogRow["RO"], dogRow["DogColour"], img); } html += "</td>"; html += "<td valign='top' class='clsEntry'><div>(" + DogsInClass+ ")</div></td>"; } else { html += "<td valign='top' class='clsRing notInClass'>" + ringRow["ClsNo"] + "</td>"; html += "<td valign='top' class='clsDetails notInClass'>" + clsName + "</td>"; html += "<td valign='top' class='clsEntry notInClass'><div>(" + DogsInClass + ")</div></td>"; } html += "</tr>"; newday = false; } html += "</table>"; html += "</div>"; ringPlanContainer.InnerHtml = html; }
private String printRingForUser(UserShows userShow, int UserID, ref List<int> defaultUsers) { String html = ""; Fpp.WebModules.Business.User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); List<ShowDetails> showDetailsList = ShowDetails.GetShowDaysList(userShow.ShowID); html += "<h2>" + show.ShowName + "</h2>"; Rings r = new Rings(); DataSet ringList = r.GetAllRingsForShow(userShow.ShowID, "ShowDate"); Dogs d = new Dogs(); DogClasses dc = new DogClasses(); DateTime dt = DateTime.Now; Boolean newday = false; int currentRingID = 0; int ShowDetailsID = -1; int PrevShowDetailsID = -1; foreach (DataRow ringRow in ringList.Tables[0].Rows) { try { int RingID = Convert.ToInt32(ringRow["RingID"]); int EntryType = Convert.ToInt32(ringRow["EntryType"]); ShowDetailsID = Convert.ToInt32(ringRow["ShowDetailsID"]); if (ringRow.IsNull("ClassID")) { continue; } int ClassID = Convert.ToInt32(ringRow["ClassID"]); DateTime rowDT = Convert.ToDateTime(ringRow["ShowDate"]); if (rowDT != dt) { newday = true; if (currentRingID != 0) { html += "</table></div></div>"; if (currentUser.UserID == UserID) { html += getHandlerDetails(userShow, currentUser, PrevShowDetailsID); } else { User defaultHandler = new User(UserID); html += getHandlerDetails(userShow, defaultHandler, PrevShowDetailsID); } html += "<div class='pagebreak'></div>"; } html += "<div class='day group'>"; html += "<div class='clsDate'>" + rowDT.ToString("dddd d MMM") + "</div>"; dt = rowDT; } if (currentRingID != RingID) { List<Judge> judgeList = Judge.getJudgesForRingList(RingID); if (currentRingID != 0 && !newday) { html += "</table></div>"; } html += "<div class='Ring'>"; html += "<table class='roClassesTbl'>"; html += "<tr class='ringInfo'>"; html += "<td colspan='3'>" + "<div class='roTitle centered'>Ring No " + ringRow["RingNo"].ToString() + "</div>"; foreach (Judge judge in judgeList) { html += "<div class='roTitle centered'>" + judge.Name + "</div>"; } html += "</td></tr>"; currentRingID = RingID; } html += "<tr>"; DataSet dogsList = d.GetDogsInClass(userShow.Userid, ClassID); int DogsInClass = d.dogsInClassCount(ClassID); String clsName = String.Format("{0} {1} {2} {3}", ShowClasses.expandCatagory(ringRow), ShowClasses.expandHeight(ringRow), ringRow["LongName"], ringRow["name"]); String grades = ShowClasses.shortenGrades(ringRow); int ix = clsName.IndexOf("Grd"); if (ix == -1) ix = clsName.IndexOf("Cmb"); if (ix > -1) { clsName = clsName.Substring(0, ix + 3) + " " + grades + " " + clsName.Substring(ix + 4); } else { ix = clsName.IndexOf(" "); clsName = clsName.Substring(0, ix) + " " + grades + " " + clsName.Substring(ix + 1); } if (dogsList.Tables[0].Rows.Count > 0) { String tmphtml = "<td valign='top' class='clsRing InClass'>" + ringRow["ClsNo"] + "</td>" + "<td valign='top' class='clsDetails InClass'><div>" + clsName + "</div>"; int countDogs = 0; int DefaultHandler; foreach (DataRow dogRow in dogsList.Tables[0].Rows) { int DogID = Convert.ToInt32(dogRow["DogID"]); DefaultHandler = Convert.ToInt32(dogRow["DefaultHandler"]); if (DefaultHandler == 0) DefaultHandler = -1; if ((DefaultHandler == -1 && currentUser.UserID == UserID) || (DefaultHandler == UserID) ) { html += tmphtml; tmphtml = ""; String img = "<img src='data:image/gif;base64," + CreateImage(dogRow["DogColour"].ToString()) + "' />"; String dogName = dogRow["DogName"].ToString(); if (dogName.Length == 0) { dogName = dogRow["KCName"].ToString(); } html += String.Format("<div class='dogInClass'><div style='background:{2};' class='dogIcon'>{3}</div>[{1}] {0}</div>", dogName, dogRow["RO"], dogRow["DogColour"], img); int AltHandler = Convert.ToInt32(dogRow["AltHandler"]); String HandlerName = ""; if (AltHandler > 0) { User u = new User(AltHandler); HandlerName = u.Name; html += "<div class='altHandler'>Handler:" + AltHandler + "</div>"; } // Pairs if (EntryType == 4) { MultiDog md = new MultiDog(UserID, DogID, ClassID); html += String.Format("<div class='dogInClass'><div style='width:8px;height:10px;' class='dogIcon'></div>[{1}] {0}</div>", md.Dogname, dogRow["RO"]); } countDogs++; } else { if (defaultUsers != null && defaultUsers.IndexOf(DefaultHandler) == -1) { defaultUsers.Add(DefaultHandler); } } } if (countDogs == 0) { html += "<td valign='top' class='clsRing notInClass'>" + ringRow["ClsNo"] + "</td>"; html += "<td valign='top' class='clsDetails notInClass'>" + clsName + "</td>"; html += "<td valign='top' class='clsEntry notInClass'><div>(" + DogsInClass + ")</div></td>"; } else { html += "</td>"; html += "<td valign='top' class='clsEntry'><div>(" + DogsInClass + ")</div></td>"; } } else { html += "<td valign='top' class='clsRing notInClass'>" + ringRow["ClsNo"] + "</td>"; html += "<td valign='top' class='clsDetails notInClass'>" + clsName + "</td>"; html += "<td valign='top' class='clsEntry notInClass'><div>(" + DogsInClass + ")</div></td>"; } html += "</tr>"; newday = false; PrevShowDetailsID = ShowDetailsID; } catch (Exception e) { AppException.LogEvent("Printing Ring Plan: " + e.Message); } } html += "</table>"; html += "</div>"; html += "</div>"; if (currentUser.UserID == UserID) { html += getHandlerDetails(userShow, currentUser, PrevShowDetailsID); } else { User defaultHandler = new User(UserID); html += getHandlerDetails(userShow, defaultHandler, PrevShowDetailsID); } html += "<div class='pagebreak'></div>"; return html; }