protected void Page_Load(object sender, EventArgs e)
        {
            int ShowDetailsID = Convert.ToInt32(Request["showdetailsid"]);
            int ShowDayID = Convert.ToInt32(Request["dayid"]);
            ShowDetails _showDetails = new ShowDetails(ShowDayID);

            DataRowCollection getDayRowData = _showDetails.GetDayData(ShowDayID, true);

            String res = "<table id='classDetails' showDetailsID='" + ShowDetailsID.ToString() + "'>";
            String tmp = "";

            tmp += "<tr>";
            String dateThing = getDateOrdinalSuffix(_showDetails.ShowDate.Day);

            tmp += "<td class='classHeader' colspan='5'>" + _showDetails.ShowDate.ToString("dddd MMM d").ToUpper() + dateThing + " CLASSES</td>";
            tmp += "<td>";

            tmp += "<tr class='tableHeader'>";
            tmp += "<td class='clsno'></td>";
            tmp += "<td class='name'> </td>";
            tmp += "<td class='grades'></td>";
            tmp += "<td class='cat'></td>";
            tmp += "<td class='height'></td>";
            tmp += "</tr>";
            res += tmp;
            foreach (DataRow row in getDayRowData)
            {
                ShowClasses sc = new ShowClasses(row);
                tmp = "<tr id='" + sc.ID + "' class='tableItem' >";

                String grades = "";
                grades = "<table class='gradeTable' style='border:none'><tr>";
                String str = sc.Grades;
                for (int i = 1; i <= 7; i++)
                {
                    grades += "<td grade='" + i.ToString() + "' >";
                    if (str.IndexOf((char)(i + 48)) > -1)
                    {
                        grades += i.ToString();
                    }
                    grades += "</td>";
                }
                grades += "</tr></table>";

                tmp += String.Format("<td class='clsno'>Class {0}</td>", sc.ClassNo);
                tmp += String.Format("<td class='name'><div >{0} {1} {2} </div></td>", ShowClasses.expandHeight(row), sc.LongClassName, sc.ClassName);
                tmp += String.Format("<td class='cat'>{0}</td>", ShowClasses.expandCatagory(row) );
                tmp += String.Format("<td class='grades'>{0}</td>", grades);
                tmp += "</tr>";
                res += tmp;
            }

            res += "</table>";
            previewArea.InnerHtml = res;
        }
        public int Copy(DateTime newDay)
        {
            int newShowDetailsID = _showDetails.AddDay(newDay, _showID, _classlimit);

            ShowClasses showClass = new ShowClasses();
            showClass.BulkCopy(_id, newShowDetailsID);

            return newShowDetailsID;
        }
        private String generateClassesForDay(int ShowDetailsID , DataTable showDayTable)
        {
            ShowDetails _showDetails = new ShowDetails(ShowDetailsID);

            String res = "<table id='classDetails' style='font-family:Verdana; font-size:16pt;'>";
            String tmp = "";

            String dateThing = getDateOrdinalSuffix(_showDetails.ShowDate.Day);
            tmp += "<tr><td class='classHeader' colspan='5'>" + _showDetails.ShowDate.ToString("dddd MMM d").ToUpper() + dateThing + " CLASSES</td></tr>";
            tmp += "</table>";
            res += tmp;
            //tmp += "<tr><th>Class No</th><th>Class Name</th><th>Classes</th><th>Judge</th></tr>";

            foreach (DataRow row in showDayTable.Rows)
            {
                ShowClasses sc = new ShowClasses(row);

                tmp = "<table border='1'  id='classDetails' style='font-family:Verdana; font-size:10pt;'>";
                tmp += "<tr class='tableItem' >";
                String grades = "";

                grades = "<table class='gradeTable' style='border:dotted 1px #000000'><tr>";
                String str = sc.Grades;
                for (int i = 1; i <= 7; i++)
                {
                    grades += "<td grade='" + i.ToString() + "' >";
                    if (str.IndexOf((char)(i + 48)) > -1)
                    {
                        grades += i.ToString();
                    }
                    grades += "</td>";
                }

                grades += "</tr></table>";

                tmp += String.Format("<td style='width:50px' class='clsno'>{0}</td>", sc.ClassNo);
                if (row["EntryType"].ToString() == "1")
                {
                    tmp += String.Format("<td class='name'><div >{1} {0} {2} {3}</div></td>", ShowClasses.expandCatagory(row), ShowClasses.expandHeight(row), sc.LongClassName, sc.ClassName);
                }
                else
                {
                    tmp += String.Format("<td class='name'><div >{0} {1}</div></td>", sc.LongClassName, sc.ClassName);
                }
                tmp += String.Format("<td class='grades'>{0}</td>", grades);
                tmp += String.Format("<td class='judge'>{0}</td>", row["JudgeName"]);
                tmp += "</tr></table>";

                res += tmp;
            }

            return res;
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            int RingID = Convert.ToInt32(context.Request["ringid"]);
            String cmd = context.Request["doc"].ToString();
            Shows show = new Shows(ShowID);

            ShowDetails sd = new ShowDetails();
            DataTable table = sd.GetShowDetails(ShowID).Tables[0];
            String pdfPath = context.Server.MapPath(cmd + ".pdf");
            Boolean publish = false;
            if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true;

            Document doc = new Document(PageSize.A4, -50, -50, 2, 2);
            Stream output;
            if (publish)
            {
                String path = context.Server.MapPath(@"..\schedules\");
                path += DateTime.Today.ToString("yyyy");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName);
                output = new FileStream(path, FileMode.Create);
            }
            else
            {
                output = new MemoryStream();
            }
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            Font font = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK);
            Font resFont = new Font(Font.COURIER, 9, Font.ITALIC, Color.BLACK);
            Font headerFont = new Font(Font.COURIER, 10, Font.BOLD, Color.BLACK);
            Font headerFont2 = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK);
            Font ClassTitleFont = new Font(Font.HELVETICA, 16, Font.NORMAL, Color.BLACK);
            ShowClasses sc = new ShowClasses();
            Rings currentRing = new Rings(RingID);
            List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID);
            foreach (ShowClasses showClass in showClasses)
            {
                PdfPTable ptable = new PdfPTable(3);
                PdfPCell cell;

                String grades = showClass.Grades;
                if (grades.Length == 1)
                {
                    grades = "Grade " + grades;
                }
                else
                {
                    grades = "Grades " + grades[0] + "-" + grades[grades.Length - 1];
                }
                String tmp = String.Format("Ring No:{5}   Class No:{0} {1} {2} {3} ({4})", showClass.ClassNo, showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, currentRing.RingNo);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, ClassTitleFont)));
                cell.Colspan = 3;
                cell.BorderWidth = 0;
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont)));
                cell.Colspan = 3;
                cell.BorderWidth = 0;
                ptable.AddCell(cell);
                ptable.AddCell(cell);
                ptable.AddCell(cell);
                doc.Add(ptable);

                DataSet callingList = sc.getCallingList(ShowID, showClass.ID);
                float[] colWidths = { 35, 50, 200, 200 };
                PdfPTable callingListTbl = new PdfPTable(colWidths);

                cell = new PdfPCell(new Phrase(new Chunk("RO", headerFont)));
                cell.BorderWidth = 0;
                callingListTbl.AddCell(cell);

                cell = new PdfPCell(new Phrase(new Chunk("Ring No", headerFont)));
                cell.BorderWidth = 0;
                callingListTbl.AddCell(cell);

                cell = new PdfPCell(new Phrase(new Chunk("Handler", headerFont)));
                cell.BorderWidth = 0;
                callingListTbl.AddCell(cell);

                cell = new PdfPCell(new Phrase(new Chunk("Dog Name", headerFont)));
                cell.BorderWidth = 0;
                callingListTbl.AddCell(cell);
                int altFlag = 0;
                Color altLine = Color.LIGHT_GRAY;
                foreach (DataRow row in callingList.Tables[0].Rows)
                {
                    Color altColor = Color.WHITE;
                    if (altFlag % 2 == 0 && showClass.EntryType != 5)
                    {
                        altColor = altLine;
                    }

                    cell = new PdfPCell(new Phrase(new Chunk(row["RO"].ToString(), font)));
                    cell.BorderWidth = 0;
                    cell.BorderWidth = 2;
                    cell.BorderColor = Color.RED;
                    cell.BackgroundColor = altColor;
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    callingListTbl.AddCell(cell);

                    if (showClass.EntryType == 5)
                    {
                        cell = new PdfPCell(new Phrase(new Chunk("Team Name:", headerFont2)));
                        cell.BackgroundColor = altColor;
                        cell.BorderWidth = 1;
                        cell.Colspan = 2;
                        cell.FixedHeight = 30F;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk(ShowClasses.expandHeight(row), headerFont2)));
                        cell.BackgroundColor = altColor;
                        cell.BorderWidth = 1;
                        cell.FixedHeight = 30F;
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("", font)));
                        cell.BackgroundColor = altColor;
                        cell.Colspan = 1;
                        cell.BorderWidth = 0;
                        cell.FixedHeight = 30F;
                        callingListTbl.AddCell(cell);
                    }

                    int borderWidth = 0;
                    if (showClass.EntryType == 5) borderWidth = 1;
                    cell = new PdfPCell(new Phrase(new Chunk(row["RingNumber"].ToString(), font)));
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    cell.BackgroundColor = altColor;
                    cell.BorderWidth = borderWidth;
                    callingListTbl.AddCell(cell);

                    int DefaultHandler = Convert.ToInt32(row["DefaultHandler"]);
                    int AltHandler = Convert.ToInt32(row["AltHandler"]);
                    String handlerName = row["Name"].ToString();
                    User user;
                    if (DefaultHandler > 0) {
                        user = new User(DefaultHandler);
                        handlerName = user.Name;
                    }
                    if (AltHandler > 0)
                    {
                        user = new User(AltHandler);
                        handlerName = user.Name;
                    }

                    cell = new PdfPCell(new Phrase(new Chunk(handlerName, font)));
                    cell.BackgroundColor = altColor;
                    cell.BorderWidth = borderWidth;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk(row["KCName"].ToString(), font)));
                    cell.BackgroundColor = altColor;
                    cell.BorderWidth = borderWidth;
                    callingListTbl.AddCell(cell);

                    if (showClass.EntryType == 4 || showClass.EntryType == 5)
                    {
                        int UserID = Convert.ToInt32(row["UserID"]);
                        int DogID = Convert.ToInt32(row["DogID"]);
                        //MultiDog md = new MultiDog(UserID, DogID, showClass.ID);

                        List<MultiDog> otherHandlers = MultiDog.getMultiDog(UserID, DogID, showClass.ID);

                        String reserves = "";
                        int dogCnt = 0;
                        foreach (MultiDog md in otherHandlers)
                        {
                            String res = "";
                            if (dogCnt > 2 && md.Handlername.Length > 0)
                            {
                                if (reserves.Length > 0) reserves += "; ";
                                reserves += String.Format("{0} & {1}", md.Handlername, md.Dogname);
                            }

                            if (dogCnt < 3)
                            {

                                cell = new PdfPCell(new Phrase(new Chunk("", font)));
                                cell.BorderWidth = 0;
                                cell.BackgroundColor = altColor;
                                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                                callingListTbl.AddCell(cell);

                                cell = new PdfPCell(new Phrase(new Chunk(res, font)));
                                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                                cell.BackgroundColor = altColor;
                                cell.BorderWidth = 1;
                                callingListTbl.AddCell(cell);

                                cell = new PdfPCell(new Phrase(new Chunk(md.Handlername, font)));
                                cell.BackgroundColor = altColor;
                                cell.BorderWidth = 1;
                                callingListTbl.AddCell(cell);

                                cell = new PdfPCell(new Phrase(new Chunk(md.Dogname, font)));
                                cell.BackgroundColor = altColor;
                                cell.BorderWidth = 1;
                                callingListTbl.AddCell(cell);
                            }
                            dogCnt++;

                        }

                        cell = new PdfPCell(new Phrase(new Chunk("", font)));
                        cell.BackgroundColor = altColor;
                        cell.BorderWidth = 0;
                        cell.FixedHeight = 30F;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("Reserves: " + reserves, resFont)));
                        cell.BackgroundColor = altColor;
                        cell.Colspan = 3;
                        cell.BorderWidth = 1;
                        cell.FixedHeight = 30F;
                        callingListTbl.AddCell(cell);
                    }
                    altFlag++;

                }
                doc.Add(callingListTbl);
                doc.NewPage();
            }

            doc.Close();

            if (publish)
            {

            }
            else
            {
                context.Response.ClearContent();
                context.Response.ContentType = "application/pdf";
                context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
                context.Response.BinaryWrite((output as MemoryStream).ToArray());
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);

            String sortby = Convert.ToString(context.Request["sortby"]);

            ShowDetails sd = new ShowDetails();
            DataTable table = sd.GetShowDetails(ShowID).Tables[0];

            Document doc = new Document(PageSize.A4, -10, -50, 2, 2);
            Stream output = new MemoryStream();
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            Font smallFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK);
            Font normalFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK);
            Font normalFontBold = new Font(Font.COURIER, 8, Font.BOLD, Color.BLACK);
            Font headerFont = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK);
            Font ClassTitleFont = new Font(Font.HELVETICA, 16, Font.NORMAL, Color.BLACK);
            Font bigFont = new Font(Font.HELVETICA, 25, Font.NORMAL, Color.BLACK);
            Font mediumFont = new Font(Font.HELVETICA, 20, Font.NORMAL, Color.BLACK);

            PdfPTable ptable = new PdfPTable(1);
            PdfPCell cell;

            cell = new PdfPCell();
            cell.FixedHeight = 150;
            cell.BorderWidth = 0;
            ptable.AddCell(cell);

            cell = new PdfPCell(new Phrase(new Chunk("Master List", bigFont)));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BorderWidth = 0;
            cell.FixedHeight = 100;
            ptable.AddCell(cell);

            cell = new PdfPCell(new Phrase(new Chunk(show.ShowName, bigFont)));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BorderWidth = 0;
            ptable.AddCell(cell);

            cell = new PdfPCell(new Phrase(new Chunk(show.ShowDate.ToString("dd MMM yyyy"), bigFont)));
            cell.BorderWidth = 0;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            ptable.AddCell(cell);
            doc.Add(ptable);
            doc.NewPage();

            float[] colWidths = { 100, 40, 175, 200};
            int count = 0;
            String lastName = "";
            DataSet masterList = DogClasses.getMasterList(ShowID, sortby);
            String tmp = "";

            ptable = new PdfPTable(colWidths);
            cell = new PdfPCell(new Phrase(new Chunk("Handler Name", headerFont)));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);

            cell = new PdfPCell(new Phrase("Ring No", headerFont));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);

            cell = new PdfPCell(new Phrase("Dog Name", headerFont));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);

            cell = new PdfPCell(new Phrase("Class Details", headerFont));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);
            doc.Add(ptable);

            bool topBorder = false;
            Color altLine = new Color(224, 224, 224);
            foreach (DataRow row in masterList.Tables[0].Rows)
            {
                Color altColor = Color.WHITE;
                if (count % 2 == 0 )
                {
                    altColor = altLine;
                }

                MasterList masterListItem = new MasterList(row);
                ptable = new PdfPTable(colWidths);
                if (lastName == masterListItem.Name)
                {
                    cell = new PdfPCell(new Phrase(new Chunk("", normalFont)));
                    topBorder = false;
                }
                else
                {
                    topBorder = true;
                    tmp = masterListItem.Name;
                    //if (masterListItem.AltHandler > 0)
                    //{
                    //    User u = new User(masterListItem.AltHandler);
                    //    tmp = u.Name;
                    //}

                    cell = new PdfPCell(new Phrase(new Chunk(tmp, normalFont)));
                    cell.BorderColorTop = Color.BLACK;
                    cell.BorderWidthTop = 1;
                }
                cell.BorderWidth = 0;
                cell.BackgroundColor = altColor;
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase(new Chunk(masterListItem.RingNumber.ToString(), normalFont)));
                cell.BorderWidth = 0;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.BackgroundColor = altColor;
                if (topBorder)
                {
                    cell.BorderColorTop = Color.BLACK;
                    cell.BorderWidthTop = 1;
                }
                ptable.AddCell(cell);

                Paragraph p = new Paragraph();
                Phrase ph = new Phrase();
                ph.Add(new Chunk(masterListItem.KCName, normalFont));
                ph.Add(Chunk.NEWLINE);
                ph.Add(new Chunk(masterListItem.KCNumber, normalFont));
                cell = new PdfPCell(ph);
                cell.BorderWidth = 0;
                cell.BackgroundColor = altColor;
                if (topBorder)
                {
                    cell.BorderColorTop = Color.BLACK;
                    cell.BorderWidthTop = 1;
                }
                ptable.AddCell(cell);

                PdfPTable classDetailsTbl = new PdfPTable(1);
                List<DogClasses> dcList = DogClasses.Retrieve(masterListItem.DogID, ShowID);
                p = new Paragraph();
                bool first = true;
                foreach (DogClasses dc in dcList)
                {
                    ShowClasses sc = new ShowClasses(dc.Classid);
                    if (!first)
                    {
                        p.Add(new Chunk(String.Format(",  {0,3}:", sc.ClassNo), normalFont));
                    }
                    else
                    {
                        p.Add(new Chunk(String.Format("{0,3}:", sc.ClassNo), normalFont));
                    }
                    p.Add(new Chunk(String.Format("{0,3}", dc.RO), normalFontBold));
                    first = false;
                }

                cell = new PdfPCell(p);
                cell.BorderWidth = 0;
                classDetailsTbl.AddCell(cell);
                cell = new PdfPCell(classDetailsTbl);
                cell.BorderWidth = 0;
                cell.BackgroundColor = altColor;
                if (topBorder)
                {
                    cell.BorderColorTop = Color.BLACK;
                    cell.BorderWidthTop = 1;
                }
                ptable.AddCell(cell);

                doc.Add(ptable);

                lastName = masterListItem.Name;

                count++;
                //if (count > 100 ) break;
            }

            doc.Close();

            context.Response.ClearContent();
            context.Response.ContentType = "application/pdf";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
            context.Response.BinaryWrite((output as MemoryStream).ToArray());
        }
        public classesAllowed(ShowClasses sc)
        {
            String tmp = sc.longHeight;
            if (sc.EntryType == 2)
            {
                tmp = "";
            }

            _className = tmp + " " + sc.getGrades  + " " + sc.LongClassName + " " + sc.ClassName;
            _clsNo = sc.ClassNo;
            _entryType = sc.EntryType;
            _chargeType = sc.ChargeType;
            _classType = sc.ClassType;
            _charge = sc.Charge ;
            _classID = sc.ID;
        }
 public void addClassDetails(ShowClasses sc)
 {
     _classesAllowed.Add(new classesAllowed(sc));
 }
        public void ProcessRequest(HttpContext context)
        {
            //PDFBuilder.HtmlToPdfBuilder builder = new HtmlToPdfBuilder(PageSize.A4);
            //builder.AddPage();
            //builder.ImportStylesheet(context.Server.MapPath("pdfstylesheet.css"));

            int ShowID = Convert.ToInt32(context.Request["showid"]);

            Shows show = new Shows(ShowID);

            ShowDetails sd = new ShowDetails();
            DataTable table = sd.GetShowDetails(ShowID).Tables[0];
            String pdfPath = context.Server.MapPath("PreviewSchedule.pdf");
            Boolean publish = false;
            if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true;

            Document doc = new Document(PageSize.A4, 25, 10, 10, 10);
            Stream  output ;
            if (publish)
            {
                String path = context.Server.MapPath(@"..\schedules\");
                path += DateTime.Today.ToString("yyyy");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName);
                output = new FileStream(path, FileMode.Create);
            } else {
                output = new MemoryStream();
            }
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();

            int clsNo = 0;
            ShowClasses sc = new ShowClasses();
            DataSet callingList = sc.getCallingList(ShowID);
            foreach (DataRow row in callingList.Tables[0].Rows)
            {
                if (clsNo > 0 && clsNo != Convert.ToInt32( row["ClsNo"]))  {
                    doc.NewPage();
                }

                var dayClasses = HTMLWorker.ParseToList(new StringReader(dayHtml), sheet);
                foreach (var htmlElement in dayClasses)
                {
                    doc.Add(htmlElement as IElement);
                }
            };

            doc.NewPage();
            contents = File.ReadAllText(context.Server.MapPath("schedule2RulesNRegs.html"));
            parsedHTML = HTMLWorker.ParseToList(new StringReader(contents), sheet);
            foreach (var htmlElement in parsedHTML)
            {
                doc.Add(htmlElement as IElement);
            }

            doc.Close();

            if (publish)
            {

            }
            else
            {
                context.Response.ClearContent();
                context.Response.ContentType = "application/pdf";
                context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
                context.Response.BinaryWrite( (output as MemoryStream).ToArray());
            }
        }
 public void updateClassesInRing(String data)
 {
     String[] d1 = data.Split(':');
     int ringID = Convert.ToInt32(d1[0]);
     String[] d2 = d1[1].Split(',');
     if (d2.Length > 1)
     {
         // if bigger than one, then we have classes to move otherwise
         // this means that there are no classes in this ring
         for (int i = 0; i < d2.Length; i += 2)
         {
             int pos = Convert.ToInt32(d2[i]);
             int id = Convert.ToInt32(d2[i + 1]);
             ShowClasses sc = new ShowClasses(id);
             sc.Position = pos;
             sc.RingID = ringID;
             sc.Update();
         }
     }
 }
        public void ResetNumbersForDay(int ShowID, int ShowDetailsID)
        {
            DataSet ds = _showClasses.getAllClassesForShow(ShowID);
            if (ds.Tables.Count > 0)
            {
                int rowCnt = 1;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    ShowClasses sc = new ShowClasses(row);
                    sc.ClassNo = rowCnt;
                    sc.Update();

                    rowCnt++;

                }
            }
        }
 public void BulkCopy(int showDetailsID, int newShowDetailsID)
 {
     _showClasses.BulkCopy(showDetailsID, newShowDetailsID);
     int clsNo = _showClasses.getMaxClassNo(newShowDetailsID) + 1;
     DataSet ds = _showClasses.GetClassesFromShowDetails(newShowDetailsID);
     foreach (DataRow row in ds.Tables[0].Rows)
     {
         ShowClasses sc = new ShowClasses(row);
         sc.ClassNo = clsNo++;
         sc.Update();
     }
 }
 public void updateClassesInRing(String data)
 {
     String[] d1 = data.Split(':');
     int ringID = Convert.ToInt32(d1[0]);
     String[] d2 = d1[1].Split(',');
     for (int i = 0; i < d2.Length; i += 2)
     {
         int pos = Convert.ToInt32(d2[i]);
         int id = Convert.ToInt32(d2[i + 1]);
         ShowClasses sc = new ShowClasses(id);
         sc.Position = pos;
         sc.RingID = ringID;
         sc.Update();
     }
 }
        public bool Delete()
        {
            Data.ShowDetails showDetails = new Fpp.WebModules.Data.ShowDetails(_moduleSettings);

            ShowClasses sc = new ShowClasses();
            sc.removeRing(_id);

            Judge j = new Judge();
            j.removeRing(_id);

            Helpers h = new Helpers();
            h.removeRing(_id);

            _ring.Delete(_id);

            return true;
        }
        public String GetDay()
        {
            String res = "";

            DataTable table = _showDetails.GetClassSummaryForDay(_id).Tables[0];

            res = "<table id='classDetailsHeader' showDetailsID='"+  _id.ToString() + "'>";

            String tmp = "<tr class='tableHeader'>";
            tmp += "<td class='clsno'>Cls</td>";
            tmp += "<td class='height'>Height</td>";
            tmp += "<td class='cat'>Grd/Cmb</td>";
            tmp += "<td class='name'>Class Name</td>";
            tmp += "<td class='grades'>Grades</td>";
            tmp += "<td class='judge'>Judges</td>";
            tmp += "<td ><input id='btnNewClass' type='button' value='New' /></td>";
            tmp += "</tr></table>";
            tmp += "<div class='ContainerDetailsTable'><table id='classDetails' showDetailsID='" + _id.ToString() + "'>";
            res += tmp;
            foreach (DataRow row in table.Rows)
            {
                ShowClasses sc = new ShowClasses(row);
                tmp = String.Format("<tr clsid='{0}' class='tableItem' position='{1}'  entrytype='{2}' >", sc.ID, sc.Position, sc.EntryType );

                String grades = "";
                grades = "<table class='gradeTable'><tr>";
                String str = sc.Grades;
                for (int i = 1; i <= 7; i++)
                {
                    grades += "<td grade='" + i.ToString() + "' >";
                    if ( str.IndexOf(   (char)(i + 48)  ) > -1 )
                    {
                        grades += i.ToString();
                    }
                    grades += "</td>";
                }

                grades += "</tr></table>";
                tmp += String.Format("<td class='clsno'>{0}</td>", sc.ClassNo);
                tmp += String.Format("<td class='height'>{0}</td>", ShowClasses.expandHeight(row)  );
                tmp += String.Format("<td class='cat'>{0}</td>", ShowClasses.expandCatagory(row) );
                tmp += String.Format("<td class='name' classtype='{1}' classtypename='{0}' name='{2}' ><div class='classTypeName'>{0}</div> <div class='classExtraText'>{2}</div></td>", sc.LongClassName, sc.ClassType, sc.ClassName);
                tmp += String.Format("<td class='grades'>{0}</td>", grades);

                tmp += String.Format("<td class='judge'>{0}</td>", Judge.getJudgeForClass(sc.ID));
                tmp += "<td class='classControls'><span class='del'>Del</span><span class='copy'>Copy</span></td>";

                tmp += "</tr>";

                res += tmp;
            }

            res += "</table><div>";

            return res;
        }
 public void updatePosition(String[] posList)
 {
     for (int i = 0; i < posList.Length; i++)
     {
         int id = Convert.ToInt32(posList[i]);
         ShowClasses sc = new ShowClasses(id);
         sc.Position = i;
         sc.Update();
     }
 }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            int RingID = Convert.ToInt32(context.Request["ringid"]);
            String cmd = context.Request["doc"].ToString();

            Shows show = new Shows(ShowID);
            ShowDetails sd = new ShowDetails();
            DataTable table = sd.GetShowDetails(ShowID).Tables[0];
            String pdfPath = context.Server.MapPath(cmd + ".pdf");
            Boolean publish = false;
            if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true;

            Document doc = new Document(PageSize.A4, -50, -50, 2, 2);
            Stream output;
            if (publish)
            {
                String path = context.Server.MapPath(@"..\schedules\");
                path += DateTime.Today.ToString("yyyy");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName);
                output = new FileStream(path, FileMode.Create);
            }
            else
            {
                output = new MemoryStream();
            }
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            Font smallFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK);
            Font normalFont = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK);
            Font headerFont = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK);
            Font ClassTitleFont = new Font(Font.HELVETICA, 16, Font.NORMAL, Color.BLACK);
            Font bigFont = new Font(Font.HELVETICA, 25, Font.NORMAL, Color.BLACK);
            Font mediumFont = new Font(Font.HELVETICA, 20, Font.NORMAL, Color.BLACK);
            ShowClasses sc = new ShowClasses();
            Rings currentRing = new Rings(RingID);
            List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID);
            PdfPTable callingListTbl = null;
            foreach (ShowClasses showClass in showClasses)
            {
                List<int> resultCnts = ShowClasses.getDogsInClass(showClass.ID, (showClass.Catagory == 0));

                int gradeidx = 0;
                foreach (int dogCounts in resultCnts)
                {
                    PdfPTable ptable = new PdfPTable(3);
                    PdfPCell cell;

                    String grades;
                    String subTitle;
                    if (showClass.Catagory == 0)
                    {
                        if (gradeidx < showClass.Grades.Length)
                        {
                            grades = "Grade " + showClass.Grades[gradeidx];
                        }
                        else
                        {
                            grades = showClass.Grades;
                        }
                        subTitle = String.Format("{0} {1} {2} {3} - Judge: {4}", showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, Judge.getJudgeForClass(showClass.ID));
                    }
                    else
                    {
                        if (showClass.Grades.Length == 1)
                        {
                            grades = showClass.Grades;
                        }
                        else
                        {
                            grades = showClass.Grades[0] + " - " + showClass.Grades[showClass.Grades.Length - 1];
                        }
                        subTitle = String.Format("{0} {1} {3} {2} - Judge: {4}", showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, Judge.getJudgeForClass(showClass.ID));

                    }
                    String tmp = String.Format("Result Sheet - Ring No:{0}", currentRing.RingNo);
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, bigFont)));
                    cell.Colspan = 2;
                    cell.BorderWidth = 0;
                    ptable.AddCell(cell);

                    tmp = String.Format("Class No:{0}", showClass.ClassNo);
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, bigFont)));
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell.BorderWidth = 2;
                    cell.Padding = 5;
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk(subTitle, mediumFont)));
                    cell.Colspan = 3;
                    cell.BorderWidth = 0;
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont)));
                    cell.Colspan = 3;
                    cell.BorderWidth = 0;
                    ptable.AddCell(cell);
                    ptable.AddCell(cell);
                    ptable.AddCell(cell);
                    doc.Add(ptable);

                    float[] colWidths = { 75, 75, 200, 200, 50, 75 };
                    callingListTbl = new PdfPTable(colWidths);

                    cell = new PdfPCell(new Phrase(new Chunk("Place", headerFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.FixedHeight = 35f;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("Ring Number", headerFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("Handler", headerFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("Dog Name", headerFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("Clear/ Faults", headerFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("Time", headerFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    int maxRosettes = calcRosettes(dogCounts);
                    int maxTrophies = calcTrophies(dogCounts);
                    float rowHeight = 25f;
                    if (showClass.EntryType == 4)
                    {
                        rowHeight = 65f;
                    }
                    else if (showClass.EntryType == 5)
                    {
                        rowHeight = 120f;
                    }

                    for (int resultRow = 0; resultRow < maxRosettes; resultRow++)
                    {
                        int bwb = 0;
                        if (resultRow == maxRosettes - 1)
                        {
                            bwb = 1;
                        }
                        Color background = Color.WHITE;
                        if (maxTrophies > 0)
                        {
                            background = Color.LIGHT_GRAY;
                        }
                        maxTrophies--;

                        cell = new PdfPCell(new Phrase(new Chunk(calcPlace(resultRow + 1), normalFont)));
                        cell.BorderWidth = 1;
                        cell.BorderWidthBottom = bwb;
                        cell.FixedHeight = rowHeight;
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;
                        cell.BackgroundColor = background;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("", normalFont)));
                        cell.BorderWidth = 1;
                        cell.BackgroundColor = background;
                        cell.BorderWidthBottom = bwb;

                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(cell);
                    }
                    doc.Add(callingListTbl);
                    doc.NewPage();
                    gradeidx++;
                }
            }

            doc.Close();

            if (publish)
            {

            }
            else
            {
                context.Response.ClearContent();
                context.Response.ContentType = "application/pdf";
                context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
                context.Response.BinaryWrite((output as MemoryStream).ToArray());
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            int RingID = Convert.ToInt32(context.Request["ringid"]);
            String cmd = context.Request["doc"].ToString();
            Shows show = new Shows(ShowID);

            ShowDetails sd = new ShowDetails();
            DataTable table = sd.GetShowDetails(ShowID).Tables[0];
            String pdfPath = context.Server.MapPath(cmd + ".pdf");
            Boolean publish = false;
            if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true;

            Document doc = new Document(PageSize.A6, 35, 0, 20, 2);
            Stream output;
            if (publish)
            {
                String path = context.Server.MapPath(@"..\schedules\");
                path += DateTime.Today.ToString("yyyy");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName);
                output = new FileStream(path, FileMode.Create);
            }
            else
            {
                output = new MemoryStream();
            }
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            Font font = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.BLACK);
            Font smallFont = new Font(Font.HELVETICA, 8, Font.NORMAL, Color.BLACK);
            Font notSoBigFont = new Font(Font.HELVETICA, 11, Font.BOLD, Color.BLACK);
            Font fontWhite = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.WHITE);
            Font headerFont = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK);
            Font spaceFont = new Font(Font.HELVETICA, 40, Font.BOLD, Color.WHITE);
            Font totalsFont = new Font(Font.HELVETICA, 14, Font.BOLD, Color.BLACK);
            Font bigBoyFont = new Font(Font.HELVETICA, 20, Font.BOLD, Color.BLACK);
            Font bigBoyFont2 = new Font(Font.HELVETICA, 25, Font.BOLD, Color.BLACK);
            PdfPCell blankCell = new PdfPCell(new Phrase(new Chunk("", font)));
            ShowClasses sc = new ShowClasses();
            Rings currentRing = new Rings(RingID);
            List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID);
            String tmp;
            foreach (ShowClasses showClass in showClasses)
            {
                PdfPCell cell;
                DataSet callingList = sc.getCallingList(ShowID, showClass.ID);

                String grades = showClass.Grades;
                if (grades.Length == 1)
                {
                    grades = "Grade " + grades;
                }
                else
                {
                    grades = "Grades " + grades[0] + "-" + grades[grades.Length - 1];
                }
                PdfPTable ptable = new PdfPTable(1);
                tmp = String.Format("Class {0}", showClass.ClassNo);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont2)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                ptable.AddCell(cell);

                tmp = String.Format("{0} {1} {2} {3}", showClass.longHeight, showClass.longCatagory, showClass.LongClassName, showClass.ClassName);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                ptable.AddCell(cell);

                tmp = String.Format("{0}", grades);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.FixedHeight = 100f;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                ptable.AddCell(cell);

                tmp = String.Format("Ring {0}", currentRing.RingNo);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.FixedHeight = 30f;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                ptable.AddCell(cell);

                tmp = String.Format("Ring Order = {0}", showClass.Position + 1);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.FixedHeight = 30f;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                ptable.AddCell(cell);

                doc.Add(ptable);
                doc.NewPage();

                foreach (DataRow row in callingList.Tables[0].Rows)
                {
                    int Cat = Convert.ToInt32(row["Catagory"]);
                    if (Cat == 0)
                    {
                        PdfPTable tbl = new PdfPTable(1);
                        int dogGrade = Convert.ToInt32(row["Grade"]);
                        if (dogGrade == 99 ) {
                            tmp = "Veteran";
                        } else {
                            tmp = String.Format("Grade {0}", row["Grade"]);
                        }
                        cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont2)));
                        cell.BackgroundColor = CMYKColor.LIGHT_GRAY;
                        cell.BorderWidth = 2;
                        cell.Padding = 9;
                        cell.PaddingTop = 4;
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        tbl.AddCell(cell);
                        doc.Add(tbl);

                    }

                    float[] colWidths = { 300, 150 };
                    PdfPTable callingListTbl = new PdfPTable(colWidths);
                    tmp = String.Format("Class {0}: {1} {2} {3} {4}", showClass.ClassNo, showClass.longHeight, showClass.LongClassName, grades, showClass.ClassName);
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.PaddingTop = 1;
                    cell.PaddingLeft = 2;
                    cell.FixedHeight = 50f;
                    callingListTbl.AddCell(cell);

                    tmp = String.Format("{0}", row["RO"]);
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorLeft = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell.Padding = 5;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("Course Time", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.Padding = 5;
                    cell.BorderColorRight = Color.BLACK;
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.Padding = 5;
                    cell.BorderColorBottom = Color.BLACK;
                    callingListTbl.AddCell(cell);

                    int DefaultHandler = Convert.ToInt32(row["DefaultHandler"]);
                    int AltHandler = Convert.ToInt32(row["AltHandler"]);
                    String handlerName = row["Name"].ToString();
                    User user;
                    if (DefaultHandler > 0)
                    {
                        user = new User(DefaultHandler);
                        handlerName = user.Name;
                    }
                    if (AltHandler > 0)
                    {
                        user = new User(AltHandler);
                        handlerName = user.Name;
                    }

                    if (showClass.EntryType == 5)
                    {
                        cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", handlerName), smallFont)));
                        cell.BorderWidth = 0;
                        cell.Colspan = 1;
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10}", row["KCName"]), smallFont)));
                        cell.Colspan = 1;
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.BorderWidth = 0;
                    }
                    else
                    {
                        cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", handlerName), notSoBigFont)));
                        cell.BorderWidth = 0;
                        cell.Colspan = 2;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", row["RingNumber"], row["KCName"]), notSoBigFont)));
                        cell.BorderWidth = 0;
                    }
                    if (showClass.EntryType < 4)
                    {
                        cell.FixedHeight = 170f;
                    }
                    cell.Colspan = 2;
                    callingListTbl.AddCell(cell);

                    if (showClass.EntryType == 4 || showClass.EntryType == 5 )
                    {
                        int UserID = Convert.ToInt32(row["UserID"]);
                        int DogID = Convert.ToInt32(row["DogID"]);
                        List<MultiDog> otherHandlers = MultiDog.getMultiDog(UserID, DogID, showClass.ID);

                        int dogCnt = 0;
                        foreach (MultiDog md in otherHandlers)
                        {

                            if (dogCnt < 3)
                            {
                                //html += String.Format("<div class='dogInClass'><div style='width:8px;height:10px;' class='dogIcon'></div>[{1}] {0}</div>", md.Dogname, dogRow["RO"]);
                                if (showClass.EntryType == 4)
                                {
                                    cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", md.Handlername), notSoBigFont)));
                                    cell.BorderWidth = 0;
                                    cell.Colspan = 2;
                                    callingListTbl.AddCell(cell);
                                    cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", "", md.Dogname), notSoBigFont)));
                                    cell.BorderWidth = 0;
                                    cell.FixedHeight = 160f;
                                    cell.Colspan = 2;
                                }
                                else
                                {
                                    cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", md.Handlername), smallFont)));
                                    cell.BorderWidth = 0;
                                    cell.Colspan = 1;
                                    cell.HorizontalAlignment = Element.ALIGN_LEFT;
                                    callingListTbl.AddCell(cell);
                                    cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", "", md.Dogname), smallFont)));
                                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                                    cell.BorderWidth = 0;
                                    cell.Colspan = 1;

                                }
                                callingListTbl.AddCell(cell);
                            }
                            dogCnt++;
                        }

                        if (showClass.EntryType == 5)
                        {
                            cell = new PdfPCell(new Phrase(new Chunk("", smallFont)));
                            cell.BorderWidth = 0;
                            cell.FixedHeight = 140f;
                            cell.Colspan = 2;
                            callingListTbl.AddCell(cell);

                        }
                    }

                    cell = new PdfPCell(new Phrase(new Chunk("Time", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);
                    callingListTbl.AddCell(blankCell);

                    cell = new PdfPCell(new Phrase(new Chunk("Course Faults", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);
                    callingListTbl.AddCell(blankCell);

                    cell = new PdfPCell(new Phrase(new Chunk("Time Faults", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);
                    callingListTbl.AddCell(blankCell);

                    cell = new PdfPCell(new Phrase(new Chunk("Totals Faults", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);
                    callingListTbl.AddCell(blankCell);
                    doc.Add(callingListTbl);
                    doc.NewPage();

                }
            }

            doc.Close();

            if (publish)
            {

            }
            else
            {
                context.Response.ClearContent();
                context.Response.ContentType = "application/pdf";
                context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
                context.Response.BinaryWrite((output as MemoryStream).ToArray());
            }
        }