Example #1
0
        public static void PrintAttendance(Day _CurrentDay)
        {
            TDayDataSet tDayDataSet = new TDayDataSet();
            TDayDataSetTableAdapters.DaysTableAdapter daysTableAdapter = new TDayDataSetTableAdapters.DaysTableAdapter();
            TDayDataSetTableAdapters.ProfilesTableAdapter profilesTableAdapter = new TDayDataSetTableAdapters.ProfilesTableAdapter();

            try
            {
                if (File.Exists(System.Windows.Forms.Application.UserAppDataPath + @"\Attendance_" + _CurrentDay.Date.Day.ToString() + ".pdf")) { File.Delete(System.Windows.Forms.Application.UserAppDataPath + @"\Attendance_" + _CurrentDay.Date.Day.ToString() + ".pdf"); }
            }
            catch (IOException)
            {
                string Proc = GetFileProcessName("Attendance_" + _CurrentDay.Date.Day.ToString() + ".pdf");
                if (File.Exists(System.Windows.Forms.Application.UserAppDataPath + @"\Attendance_" + _CurrentDay.Date.Day.ToString() + ".pdf")) { File.Delete(System.Windows.Forms.Application.UserAppDataPath + @"\Attendance_" + _CurrentDay.Date.Day.ToString() + ".pdf"); }
            }
            FileStream FS = new FileStream(System.Windows.Forms.Application.UserAppDataPath + @"\Attendance_" + _CurrentDay.Date.Day.ToString()
                + ".pdf", FileMode.CreateNew);
            var Doc = new iTextSharp.text.Document(PageSize.A4.Rotate(), 20, 20, 20, 20);

            PdfWriter.GetInstance(Doc, FS);
            Doc.Open();
            PdfPTable table = new PdfPTable(14);
            table.HorizontalAlignment = Element.ALIGN_LEFT;
            table.WidthPercentage = 100;

            AddHeader(table, "Attendance", 20, new BaseColor(Color.DimGray), new BaseColor(Color.WhiteSmoke));
            AddHeader(table, _CurrentDay.Date.DayOfWeek + "  " + _CurrentDay.Date.ToShortDateString(), 16, new BaseColor(Color.DimGray), new BaseColor(Color.White));
            daysTableAdapter.Fill(tDayDataSet.Days, _CurrentDay.Date);

            int Counter = 0;
            int TotalLC = 0;
            double TotalLCP = 0;
            double TotalTOP = 0;
            double TotalMisoP = 0;
            double TotalVan = 0;
            double TotalP = 0;
            double TotalRTP = 0;
            double TotalBFT = 0;
            double TotalT = 0;
            AddHeader(table, "Billed Clients", 12, new BaseColor(Color.DimGray), new BaseColor(Color.WhiteSmoke));
            AddPriviewCell(table, "Numb", 1);
            AddPriviewCell(table, "Name", 3);
            AddPriviewCell(table, "A", 1);
            AddPriviewCell(table, "LC", 1);
            AddPriviewCell(table, "L$", 1);
            AddPriviewCell(table, "TO$", 1);
            AddPriviewCell(table, "Miso$", 1);
            AddPriviewCell(table, "P$", 1);
            AddPriviewCell(table, "Van", 1);
            AddPriviewCell(table, "RT", 1);
            AddPriviewCell(table, "BFT", 1);
            AddPriviewCell(table, "Total", 1);
            foreach (DataRow Row in tDayDataSet.Days)
            {
                if (ProfileProvider.GetCategory((int)Row["ProfileId"]) == 1)
                {
                    AddPriviewCell(table, Counter.ToString(), 1);
                    AddPriviewCell(table, ProfileProvider.GetName((int)Row["ProfileId"]), 3);
                    AddValueCell(table, (bool)Row["Attendance"], true, 1);
                    AddValueCell(table, (bool)Row["Lunch"], true, 1);
                    if ((bool)Row["Lunch"]) { TotalLC++; }
                    AddPriviewCell(table, Row["LunchPrice"].ToString(), 1);
                    TotalLCP += Convert.ToDouble(Row["LunchPrice"]);
                    AddPriviewCell(table, Row["TakeOutPrice"].ToString(), 1);
                    TotalTOP += Convert.ToDouble(Row["TakeOutPrice"]);
                    AddPriviewCell(table, Row["MiscellaneousPrice"].ToString(), 1);
                    TotalMisoP += Convert.ToDouble(Row["MiscellaneousPrice"]);
                    if (ProfileProvider.GetCategory((int)Row["ProfileId"]) == 1)
                    {
                        AddPriviewCell(table, Row["ProgramPrice"].ToString(), 1);
                        TotalP += Convert.ToDouble(Row["ProgramPrice"]);
                        AddPriviewCell(table, Row["VanPrice"].ToString(), 1);
                        TotalVan += Convert.ToDouble(Row["VanPrice"]);
                        AddPriviewCell(table, Row["RoundTripPrice"].ToString(), 1);
                        TotalRTP += Convert.ToDouble(Row["RoundTripPrice"]);
                        AddPriviewCell(table, Row["BookOfTickets"].ToString(), 1);
                        TotalBFT += Convert.ToDouble(Row["BookOfTickets"]);
                    }
                    else
                    {
                        AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
                        TotalP += Convert.ToDouble(Row["ProgramPrice"]);
                        AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
                        TotalVan += Convert.ToDouble(Row["VanPrice"]);
                        AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
                        TotalRTP += Convert.ToDouble(Row["RoundTripPrice"]);
                        AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
                        TotalBFT += Convert.ToDouble(Row["BookOfTickets"]);
                    }
                    AddPriviewCell(table, Row["Total"].ToString(), 1);
                    Counter++;

                }

            }
            AddPriviewCell(table, "", 1);
            AddPriviewCell(table, "Total:", 3);
            AddPriviewCell(table, Counter.ToString(), 1);
            AddPriviewCell(table, TotalLC.ToString(), 1);
            AddPriviewCell(table, TotalLCP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalTOP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalMisoP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalVan.ToString("0.00"), 1);
            AddPriviewCell(table, TotalRTP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalBFT.ToString("0.00"), 1);
            AddPriviewCell(table, (TotalLCP + TotalMisoP + TotalTOP + TotalVan + TotalP + TotalRTP + TotalBFT).ToString("0.00"), 1);

            AddHeader(table, "Staff/Volunteers", 12, new BaseColor(Color.DimGray), new BaseColor(Color.WhiteSmoke));
            AddPriviewCell(table, "Numb", 1);
            AddPriviewCell(table, "Name", 3);
            AddPriviewCell(table, "A", 1);
            AddPriviewCell(table, "LC", 1);
            AddPriviewCell(table, "L$", 1);
            AddPriviewCell(table, "TO$", 1);
            AddPriviewCell(table, "Miso$", 1);
            AddPriviewCell(table, "P$", 1);
            AddPriviewCell(table, "Van", 1);
            AddPriviewCell(table, "RT", 1);
            AddPriviewCell(table, "BFT", 1);
            AddPriviewCell(table, "Total", 1);

            Counter = 0;
            TotalLC = 0;
            TotalLCP = 0;
            TotalTOP = 0;
            TotalMisoP = 0;
            TotalVan = 0;
            TotalP = 0;
            TotalRTP = 0;
            TotalBFT = 0;
            TotalT = 0;
            foreach (DataRow Row in tDayDataSet.Days)
            {
                if (ProfileProvider.GetCategory((int)Row["ProfileId"]) != 1)
                {
                    AddPriviewCell(table, Counter.ToString(), 1);
                    AddPriviewCell(table, ProfileProvider.GetName((int)Row["ProfileId"]), 3);
                    AddValueCell(table, (bool)Row["Attendance"], true, 1);
                    AddValueCell(table, (bool)Row["Lunch"], true, 1);
                    if ((bool)Row["Lunch"]) { TotalLC++; }
                    AddPriviewCell(table, Row["LunchPrice"].ToString(), 1);
                    TotalLCP += Convert.ToDouble(Row["LunchPrice"]);
                    AddPriviewCell(table, Row["TakeOutPrice"].ToString(), 1);
                    TotalTOP += Convert.ToDouble(Row["TakeOutPrice"]);
                    AddPriviewCell(table, Row["MiscellaneousPrice"].ToString(), 1);
                    TotalMisoP += Convert.ToDouble(Row["MiscellaneousPrice"]);
                    if (ProfileProvider.GetCategory((int)Row["ProfileId"]) == 1)
                    {
                        AddPriviewCell(table, Row["ProgramPrice"].ToString(), 1);
                        TotalP += Convert.ToDouble(Row["ProgramPrice"]);
                        AddPriviewCell(table, Row["VanPrice"].ToString(), 1);
                        TotalVan += Convert.ToDouble(Row["VanPrice"]);
                        AddPriviewCell(table, Row["RoundTripPrice"].ToString(), 1);
                        TotalRTP += Convert.ToDouble(Row["RoundTripPrice"]);
                        AddPriviewCell(table, Row["BookOfTickets"].ToString(), 1);
                        TotalBFT += Convert.ToDouble(Row["BookOfTickets"]);
                    }
                    else
                    {
                        AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
                        TotalP += Convert.ToDouble(Row["ProgramPrice"]);
                        AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
                        TotalVan += Convert.ToDouble(Row["VanPrice"]);
                        AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
                        TotalRTP += Convert.ToDouble(Row["RoundTripPrice"]);
                        AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
                        TotalBFT += Convert.ToDouble(Row["BookOfTickets"]);
                    }

                    AddPriviewCell(table, Row["Total"].ToString(), 1);
                    Counter++;
                }

            }
            AddPriviewCell(table, "", 1);
            AddPriviewCell(table, "Total:", 3);
            AddPriviewCell(table, Counter.ToString(), 1);
            AddPriviewCell(table, TotalLC.ToString(), 1);
            AddPriviewCell(table, TotalLCP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalTOP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalMisoP.ToString("0.00"), 1);
            AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
            AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
            AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
            AddPriviewCell(table, "", 1, new BaseColor(Color.WhiteSmoke));
            AddPriviewCell(table, (TotalLCP + TotalMisoP + TotalTOP + TotalVan + TotalP + TotalRTP + TotalBFT).ToString("0.00"), 1);

            //********************
            TotalLC = 0;
            TotalLCP = 0;
            TotalTOP = 0;
            TotalMisoP = 0;
            TotalVan = 0;
            TotalP = 0;
            TotalRTP = 0;
            TotalBFT = 0;
            TotalT = 0;
            foreach (DataRow Row in tDayDataSet.Days)
            {
                    if ((bool)Row["Lunch"]) { TotalLC++; }
                    TotalLCP += Convert.ToDouble(Row["LunchPrice"]);
                    TotalTOP += Convert.ToDouble(Row["TakeOutPrice"]);
                    TotalMisoP += Convert.ToDouble(Row["MiscellaneousPrice"]);
                    if (ProfileProvider.GetCategory((int)Row["ProfileId"]) == 1)
                    {
                        TotalP += Convert.ToDouble(Row["ProgramPrice"]);
                        TotalVan += Convert.ToDouble(Row["VanPrice"]);
                        TotalRTP += Convert.ToDouble(Row["RoundTripPrice"]);
                        TotalBFT += Convert.ToDouble(Row["BookOfTickets"]);
                    }
                    else
                    {
                        TotalP += Convert.ToDouble(Row["ProgramPrice"]);
                        TotalVan += Convert.ToDouble(Row["VanPrice"]);
                        TotalRTP += Convert.ToDouble(Row["RoundTripPrice"]);
                        TotalBFT += Convert.ToDouble(Row["BookOfTickets"]);
                    }
            }

            //******************
            TotalT += TotalLCP + TotalMisoP + TotalTOP + TotalVan + TotalP + TotalRTP + TotalBFT;
            AddPriviewCell(table, "", 1);
            AddPriviewCell(table, "GrandTotal:", 3);
            AddPriviewCell(table, tDayDataSet.Days.Rows.Count.ToString(), 1);
            AddPriviewCell(table, TotalLC.ToString(), 1);
            AddPriviewCell(table, TotalLCP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalTOP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalMisoP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalVan.ToString("0.00"), 1);
            AddPriviewCell(table, TotalRTP.ToString("0.00"), 1);
            AddPriviewCell(table, TotalBFT.ToString("0.00"), 1);
            AddPriviewCell(table, TotalT.ToString("0.00"), 1);
            Doc.Add(table);
            Doc.Close();
            Process.Start(System.Windows.Forms.Application.UserAppDataPath + @"\Attendance_" + _CurrentDay.Date.Day.ToString() + ".pdf");
        }
Example #2
0
        public static void PrintBills(int ItemId)
        {
            try
            {
                if (File.Exists(System.Windows.Forms.Application.UserAppDataPath + @"\Bill_" + ItemId.ToString() + ".pdf")) { File.Delete(System.Windows.Forms.Application.UserAppDataPath + @"\Bill_" + ItemId.ToString() + ".pdf"); }
            }
            catch (IOException)
            {
                string Proc = GetFileProcessName("Bill_" + ItemId.ToString() + ".pdf");
                if (File.Exists(System.Windows.Forms.Application.UserAppDataPath + @"\Bill_" + ItemId.ToString() + ".pdf")) { File.Delete(System.Windows.Forms.Application.UserAppDataPath + @"\Bill_" + ItemId.ToString() + ".pdf"); }
            }
            FileStream FS = new FileStream(System.Windows.Forms.Application.UserAppDataPath + @"\Bill_" + ItemId.ToString() + ".pdf", FileMode.CreateNew);
            var Doc = new iTextSharp.text.Document(PageSize.A4, 20, 20, 20, 20);
            PdfWriter.GetInstance(Doc, FS);
            Doc.Open();
            BillsItem Item = new BillsItem(ItemId);
            PdfPTable table = new PdfPTable(5);
            table.WidthPercentage = 100;
            AddPriviewCell(table, TDay.Properties.Settings.Default.PlantString,5);
            AddPriviewCell(table, String.Format("For Services of  {0:MMMM} - {0:yyyy}",Item.Date), 5);
            AddPriviewCell(table, Item.Profile.Name + "\n" + Item.Profile.Adress.Addres + "\n" + Item.Profile.Adress.City + "\n" + Item.Profile.Adress.PostalCode, 2,4, Element.ALIGN_LEFT);
            if (Item.PreviousBillPaid==0)
            {
                AddPriviewCell(table, "Balance Forward \nOverdue \nNew Charges", 1, 3, Element.ALIGN_LEFT);
            }
            else
            {
                AddPriviewCell(table, "Balance Forward \nPayments/Credits\nNew Charges", 1,3,Element.ALIGN_LEFT);
            }

            if (Item.PreviousBillPaid == 0)
            {
                AddPriviewCell(table, "", 1, 3, Element.ALIGN_CENTER);
                AddPriviewCell(table, Item.PreviousBillTotal.ToString() + "\n" + Item.PreviousBillTotal.ToString() + "\n" + Item.BillTotal.ToString(), 2, 3, Element.ALIGN_CENTER);
            }
            else
            {
                AddPriviewCell(table, Item.PreviousBillPaidDate.ToShortDateString(), 1, 3, Element.ALIGN_CENTER);
                AddPriviewCell(table, Item.PreviousBillTotal.ToString() + "\n" + Item.PreviousBillPaid.ToString() + "\n" + Item.BillTotal.ToString(), 2, 3, Element.ALIGN_CENTER);
            }
            AddPriviewCell(table, "Balance:", 2,1,Element.ALIGN_LEFT);
            AddPriviewCell(table, (Item.PreviousBillTotal-Item.PreviousBillPaid+Item.BillTotal).ToString(), 1, 2, Element.ALIGN_CENTER);
            Doc.Add(table);
            int TableColums = 0;
            TDayDataSet TempSet = new TDayDataSet();
            TDayDataSetTableAdapters.DaysTableAdapter daysTableAdapter = new TDayDataSetTableAdapters.DaysTableAdapter();
            daysTableAdapter.FillByMonth(TempSet.Days, Bill.GetFirstMonthDay(Item.Date), Bill.GetLastMonthDay(Item.Date));
            double Misc = 0;
            double Trans = 0;
            double Program = 0;
            double TO = 0;
            double Lanch = 0;
            double Van = 0;
            double BFT = 0;
            foreach (DataRow Row in TempSet.Days)
            {
                if ((int)Row["ProfileId"] == Item.ProfileIdBills)
                {
                    Misc += Double.Parse(Row["MiscellaneousPrice"].ToString());
                    Trans += Double.Parse(Row["RoundTripPrice"].ToString());
                    Program += Double.Parse(Row["ProgramPrice"].ToString());
                    TO += Double.Parse(Row["TakeOutPrice"].ToString());
                    Lanch += Double.Parse(Row["LunchPrice"].ToString());
                    Van += Double.Parse(Row["VanPrice"].ToString());
                    BFT += Double.Parse(Row["BookOfTickets"].ToString());
                }
            }
            //Говнокод (((( но к сожалению вообще мозги ничего придумать не могут(((((((((( 3 дня - 2 часа сна...........
            if (Misc > 0) { TableColums++; }
            if (Trans > 0) { TableColums++; }
            if (Program > 0) { TableColums++; }
            if (TO > 0) { TableColums++; }
            if (Lanch > 0) { TableColums++; }
            if (Van > 0) { TableColums++; }
            if (BFT > 0) { TableColums++; }
            PdfPTable tablePart = new PdfPTable(TableColums+3);
            tablePart.WidthPercentage = 100;
            AddHeader(tablePart, " New Charges", 12, new BaseColor(Color.DimGray), new BaseColor(Color.WhiteSmoke));
                AddPriviewCell(tablePart, "Date", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke));
                AddPriviewCell(tablePart, "Comments", 2, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke));
            if (Lanch > 0) { AddPriviewCell(tablePart, "Lunch", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (TO > 0) { AddPriviewCell(tablePart, "TO", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (Misc > 0) { AddPriviewCell(tablePart, "Misc", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (Program > 0) { AddPriviewCell(tablePart, "Program", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (Van > 0) { AddPriviewCell(tablePart, "Van", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (Trans > 0) { AddPriviewCell(tablePart, "Trans", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (BFT > 0) { AddPriviewCell(tablePart, "BFT", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)
                ); }
            DataView DV = TempSet.Days.DefaultView;
            DV.Sort = "Date ASC";
            BindingSource TemS = new BindingSource();
            TemS.DataSource = DV;
            int ItemsCount = 0;
            foreach (DataRowView Row in TemS.List)
            {
                if ((int)Row["ProfileId"] == Item.ProfileIdBills)
                {
                    AddPriviewCell(tablePart, ((DateTime)Row["Date"]).ToShortDateString(), 1, 1, Element.ALIGN_CENTER);
                    AddPriviewCell(tablePart, Row["Comments"].ToString(), 2, 1, Element.ALIGN_CENTER);
                    if (Lanch > 0) { AddPriviewCell(tablePart, Row["LunchPrice"].ToString(), 1, 1, Element.ALIGN_CENTER); }
                    if (TO > 0) { AddPriviewCell(tablePart, Row["TakeOutPrice"].ToString(), 1, 1, Element.ALIGN_CENTER); }
                    if (Misc > 0) { AddPriviewCell(tablePart, Row["MiscellaneousPrice"].ToString(), 1, 1, Element.ALIGN_CENTER); }
                    if (Program > 0) { AddPriviewCell(tablePart, Row["ProgramPrice"].ToString(), 1, 1, Element.ALIGN_CENTER); }
                    if (Van > 0) { AddPriviewCell(tablePart, Row["VanPrice"].ToString(), 1, 1, Element.ALIGN_CENTER); }
                    if (Trans > 0) { AddPriviewCell(tablePart, Row["RoundTripPrice"].ToString(), 1, 1, Element.ALIGN_CENTER); }
                    if (BFT > 0) { AddPriviewCell(tablePart, Row["BookOfTickets"].ToString(), 1, 1, Element.ALIGN_CENTER); }
                    ItemsCount++;
                }
            }
            AddPriviewCell(tablePart, ItemsCount.ToString(), 1, 1, Element.ALIGN_CENTER);
            AddPriviewCell(tablePart, "", TableColums + 2, 1, Element.ALIGN_CENTER);
            AddPriviewCell(tablePart, "Totals:", 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke));
            AddPriviewCell(tablePart, (Lanch + TO + Misc + Program + Van + Trans + BFT).ToString(), 2, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke));
            if (Lanch > 0) { AddPriviewCell(tablePart, Lanch.ToString(), 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (TO > 0) { AddPriviewCell(tablePart, TO.ToString(), 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (Misc > 0) { AddPriviewCell(tablePart, Misc.ToString(), 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (Program > 0) { AddPriviewCell(tablePart, Program.ToString(), 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (Van > 0) { AddPriviewCell(tablePart, Van.ToString(), 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (Trans > 0) { AddPriviewCell(tablePart, Trans.ToString(), 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke)); }
            if (BFT > 0){ AddPriviewCell(tablePart, BFT.ToString(), 1, 1, Element.ALIGN_CENTER, new BaseColor(Color.WhiteSmoke) );}
            AddEmpyRow(tablePart);
            AddEmpyRow(tablePart);
            AddEmpyRow(tablePart);
            Doc.Add(tablePart);
            PdfPTable tableFooster = new PdfPTable(6);
            tableFooster.WidthPercentage = 100;
            if (Item.Paid > 0)
            {
                PdfPCell pricell = new PdfPCell(new Phrase("Paid", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
                pricell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricell.HorizontalAlignment = Element.ALIGN_RIGHT;
                pricell.VerticalAlignment = Element.ALIGN_MIDDLE;
                pricell.Colspan = 1;
                tableFooster.AddCell(pricell);
                pricell = new PdfPCell(new Phrase(Item.Paid.ToString()+"$", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.UNDERLINE, new BaseColor(Color.DimGray))));
                pricell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricell.HorizontalAlignment = Element.ALIGN_CENTER;
                pricell.VerticalAlignment = Element.ALIGN_MIDDLE;
                pricell.Colspan = 1;
                tableFooster.AddCell(pricell);
                pricell = new PdfPCell(new Phrase("Cash", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
                pricell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricell.HorizontalAlignment = Element.ALIGN_RIGHT;
                pricell.VerticalAlignment = Element.ALIGN_MIDDLE;
                pricell.PaddingBottom = 3;
                pricell.Colspan = 1;
                tableFooster.AddCell(pricell);
                if (Item.PaidType == "cash")
                {
                    AddValueCell(tableFooster, true, true, 1, false);
                }
                else
                {
                    AddValueCell(tableFooster, false, true, 1, false);
                }
                pricell = new PdfPCell(new Phrase("Cheque", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
                pricell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricell.HorizontalAlignment = Element.ALIGN_RIGHT;
                pricell.VerticalAlignment = Element.ALIGN_MIDDLE;
                pricell.PaddingBottom = 3;
                pricell.Colspan = 1;
                tableFooster.AddCell(pricell);
                if (Item.PaidType == "cheque")
                {
                    AddValueCell(tableFooster, true, true, 1, false);
                }
                else
                {
                    AddValueCell(tableFooster, false, true, 1, false);
                }
            }
            else
            {
                PdfPCell pricell = new PdfPCell(new Phrase("Paid", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
                pricell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricell.HorizontalAlignment = Element.ALIGN_RIGHT;
                pricell.VerticalAlignment = Element.ALIGN_MIDDLE;
                pricell.Colspan = 1;
                tableFooster.AddCell(pricell);
                pricell = new PdfPCell(new Phrase("___________$", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
                pricell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricell.HorizontalAlignment = Element.ALIGN_CENTER;
                pricell.Colspan = 1;
                tableFooster.AddCell(pricell);
                pricell = new PdfPCell(new Phrase("Cash", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
                pricell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricell.HorizontalAlignment = Element.ALIGN_RIGHT;
                pricell.VerticalAlignment = Element.ALIGN_BOTTOM;
                pricell.PaddingBottom = 3;
                pricell.Colspan = 1;
                tableFooster.AddCell(pricell);
                AddValueCell(tableFooster, false, true, 1, false);
                pricell = new PdfPCell(new Phrase("Cheque", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
                pricell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricell.HorizontalAlignment = Element.ALIGN_RIGHT;
                pricell.VerticalAlignment = Element.ALIGN_MIDDLE;
                pricell.PaddingBottom = 3;
                pricell.Colspan = 1;
                tableFooster.AddCell(pricell);
                AddValueCell(tableFooster, false, true, 1, false);
            }
            AddEmpyRow(tableFooster);
            AddEmpyRow(tableFooster);
            PdfPCell pricellnew = new PdfPCell(new Phrase("Date", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
            pricellnew.Border = iTextSharp.text.Rectangle.NO_BORDER;
            pricellnew.HorizontalAlignment = Element.ALIGN_RIGHT;
            pricellnew.VerticalAlignment = Element.ALIGN_MIDDLE;
            pricellnew.Colspan = 1;
            tableFooster.AddCell(pricellnew);
            if (Item.Paid > 0)
            {
                pricellnew = new PdfPCell(new Phrase(Item.PaidDate.ToShortDateString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.UNDERLINE, new BaseColor(Color.DimGray))));
                pricellnew.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricellnew.HorizontalAlignment = Element.ALIGN_CENTER;
                pricellnew.VerticalAlignment = Element.ALIGN_MIDDLE;
                pricellnew.Colspan = 1;
                tableFooster.AddCell(pricellnew);
            }
            else
            {
                pricellnew = new PdfPCell(new Phrase("___________", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
                pricellnew.Border = iTextSharp.text.Rectangle.NO_BORDER;
                pricellnew.HorizontalAlignment = Element.ALIGN_CENTER;
                pricellnew.VerticalAlignment = Element.ALIGN_MIDDLE;
                pricellnew.Colspan = 1;
                tableFooster.AddCell(pricellnew);
            }
            pricellnew = new PdfPCell(new Phrase("Society Representative", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
            pricellnew.Border = iTextSharp.text.Rectangle.NO_BORDER;
            pricellnew.HorizontalAlignment = Element.ALIGN_CENTER;
            pricellnew.VerticalAlignment = Element.ALIGN_MIDDLE;
            pricellnew.Colspan = 2;
            tableFooster.AddCell(pricellnew);
            pricellnew = new PdfPCell(new Phrase("___________________________", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray))));
            pricellnew.Border = iTextSharp.text.Rectangle.NO_BORDER;
            pricellnew.HorizontalAlignment = Element.ALIGN_CENTER;
            pricellnew.VerticalAlignment = Element.ALIGN_MIDDLE;
            pricellnew.Colspan = 2;
            tableFooster.AddCell(pricellnew);

            Doc.Add(tableFooster);
            Doc.Close();
            Process.Start(System.Windows.Forms.Application.UserAppDataPath + @"\Bill_" + ItemId.ToString() + ".pdf");
        }