private void getHistory(string task_id, string proj_id, string parent_task_id, string parent_proj_id, string degree)
        {
            System.Data.DataRow relrow = dl.TaskRelation.Rows.Find(new string[] { task_id, proj_id });

            if (relrow != null)
            {
                foreach (System.Data.DataRow prdrow in relrow.GetChildRows("PCRel"))
                {
                    string pred_task_id = prdrow["pred_task_id"].ToString();
                    string pred_proj_id = prdrow["pred_proj_id"].ToString();
                    this.exportToCsv(parent_task_id + "," + parent_proj_id + "," + pred_task_id + "," + pred_proj_id + "," + degree);
                    if (this.processedTasks.Rows.Find(new string[] { pred_task_id, parent_task_id }) == null)
                    {
                        this.processedTasks.Rows.Add(new string[] { pred_task_id, parent_task_id });
                        getHistory(pred_task_id, pred_proj_id, parent_task_id, parent_proj_id, degree + ".1");
                    }
                }
            }
        }
        private void ReportDetail(PdfPTable pdfTable, System.Data.DataSet theData)
        {
            PdfPCell cell = new PdfPCell();

            System.Data.DataTable pawnData = theData.Tables["PAWN_INFO"];
            string last_group = string.Empty;

            for (int index = 0; index < pawnData.Rows.Count; index++)
            {
                System.Data.DataRow    pawnLoan = pawnData.Rows[index];
                System.Data.DataRow [] customer = pawnLoan.GetChildRows("customerRelation");

                object groupBy = pawnLoan[_groupByField];
                string groupByValue;

                if (groupBy is DateTime)
                {
                    groupByValue = ((DateTime)pawnLoan[_groupByField]).FormatDate();
                }
                else if (groupBy is double)
                {
                    groupByValue = string.Format("{0:c}", pawnLoan[_groupByField]);
                }
                else
                {
                    groupByValue = pawnLoan[_groupByField].ToString();
                }

                if (groupByValue != last_group)
                {
                    //row 1
                    cell                     = new PdfPCell(new Phrase("", _reportFont));
                    cell.Colspan             = 18;
                    cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                    cell.Border              = Rectangle.BOTTOM_BORDER;
                    pdfTable.AddCell(cell);

                    cell                     = new PdfPCell(new Phrase(groupByValue, _reportFont));
                    cell.Colspan             = 18;
                    cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                    cell.Border              = Rectangle.BOTTOM_BORDER;
                    pdfTable.AddCell(cell);

                    last_group = groupByValue;
                }

                //-----------------------------------------------------------------------------------
                //row 2
                cell                     = new PdfPCell(new Phrase(pawnLoan["STORENUMBER"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["CUST_NAME"].ToString(), _reportFont));
                cell.Colspan             = 3;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["ID"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["ADDR1"].ToString(), _reportFont));
                cell.Colspan             = 4;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["CITY"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["STATE"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["ZIPCODE"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["BIRTHDATE"].ToString(), _reportFont));
                cell.Colspan             = 2;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["WEIGHT"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["HEIGHT"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["GENDERCODE"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(customer[0]["RACEDESC"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                //-----------------------------------------------------------------------------------
                //row 3
                cell                     = new PdfPCell(new Phrase("", _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0}", pawnLoan["TICKET_NUMBER"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0}", pawnLoan["PREV_TICKET"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0}", pawnLoan["ORG_TICKET"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0:g}", pawnLoan["DATE_MADE"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0:d}", pawnLoan["DATE_DUE"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                if (isPartialPaymentAllowed)
                {
                    cell                     = new PdfPCell(new Phrase(string.Format("{0:c}", pawnLoan["PRIN_AMOUNT"]), _reportFont));
                    cell.Colspan             = 1;
                    cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
                    cell.Border              = Rectangle.NO_BORDER;
                    pdfTable.AddCell(cell);

                    cell                     = new PdfPCell(new Phrase(string.Format("{0:c}", pawnLoan["PartPymtPrinAmt"]), _reportFont));
                    cell.Colspan             = 1;
                    cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
                    cell.Border              = Rectangle.NO_BORDER;
                    pdfTable.AddCell(cell);
                }
                else
                {
                    cell                     = new PdfPCell(new Phrase(string.Format("{0:c}", pawnLoan["PRIN_AMOUNT"]), _reportFont));
                    cell.Colspan             = 2;
                    cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
                    cell.Border              = Rectangle.NO_BORDER;
                    pdfTable.AddCell(cell);
                }

                cell                     = new PdfPCell(new Phrase(string.Format("{0:c}", pawnLoan["INT_AMT"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0:c}", pawnLoan["SERV_CHG"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0:c}", pawnLoan["LATE_CHG"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0:c}", pawnLoan["OTH_CHG"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(pawnLoan["STATUS_CD"].ToString(), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(string.Format("{0:d}", pawnLoan["STATUS_DATE"]), _reportFont));
                cell.Colspan             = 1;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(pawnLoan["ENT_ID"].ToString(), _reportFont));
                cell.Colspan             = 2;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                cell                     = new PdfPCell(new Phrase(pawnLoan["DISP_ID"].ToString(), _reportFont));
                cell.Colspan             = 2;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                //-----------------------------------------------------------------------------------
                //row 4
                System.Data.DataRow[] mdseList = pawnLoan.GetChildRows("merchandiseRelation");
                for (int j = 0; j < mdseList.Count <System.Data.DataRow>(); j++)
                {
                    cell                     = new PdfPCell(new Phrase("", _reportFont));
                    cell.Colspan             = 1;
                    cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                    cell.Border              = Rectangle.NO_BORDER;
                    pdfTable.AddCell(cell);

                    cell                     = new PdfPCell(new Phrase(mdseList[j]["MD_DESC"].ToString(), _reportFont));
                    cell.Colspan             = 9;
                    cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                    cell.Border              = Rectangle.NO_BORDER;
                    pdfTable.AddCell(cell);

                    cell                     = new PdfPCell(new Phrase(mdseList[j]["LOC_AISLE"].ToString(), _reportFont));
                    cell.Colspan             = 1;
                    cell.HorizontalAlignment = Rectangle.ALIGN_CENTER;
                    cell.Border              = Rectangle.NO_BORDER;
                    pdfTable.AddCell(cell);

                    cell                     = new PdfPCell(new Phrase(mdseList[j]["LOC_SHELF"].ToString(), _reportFont));
                    cell.Colspan             = 1;
                    cell.HorizontalAlignment = Rectangle.ALIGN_CENTER;
                    cell.Border              = Rectangle.NO_BORDER;
                    pdfTable.AddCell(cell);

                    cell                     = new PdfPCell(new Phrase(mdseList[j]["LOCATION"].ToString(), _reportFont));
                    cell.Colspan             = 6;
                    cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                    cell.Border              = Rectangle.NO_BORDER;
                    pdfTable.AddCell(cell);
                }

                //-----------------------------------------------------------------------------------
                //row 5
                cell                     = new PdfPCell(new Phrase("", _reportFont));
                cell.Colspan             = 18;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);

                //-----------------------------------------------------------------------------------
                //row 6
                cell                     = new PdfPCell(new Phrase("", _reportFont));
                cell.Colspan             = 18;
                cell.HorizontalAlignment = Rectangle.ALIGN_LEFT;
                cell.Border              = Rectangle.NO_BORDER;
                pdfTable.AddCell(cell);
            }
        }