Пример #1
0
 public static string GetName(int ProfileId)
 {
     TDayDataSet tDayDataSet = new TDayDataSet();
     TDayDataSetTableAdapters.ProfilesTableAdapter ProfilesTableAdapter = new TDayDataSetTableAdapters.ProfilesTableAdapter();
     ProfilesTableAdapter.FillAll(tDayDataSet.Profiles);
     DataRow Row = tDayDataSet.Profiles.FindByProfileId(ProfileId);
     return Row["Name"].ToString();
 }
Пример #2
0
 public static bool GetDelStatus(int ProfileId)
 {
     TDayDataSet tDayDataSet = new TDayDataSet();
     TDayDataSetTableAdapters.ProfilesTableAdapter ProfilesTableAdapter = new TDayDataSetTableAdapters.ProfilesTableAdapter();
     ProfilesTableAdapter.FillAll(tDayDataSet.Profiles);
     DataRow Row = tDayDataSet.Profiles.FindByProfileId(ProfileId);
     return (bool)Row["DelStatus"];
 }
Пример #3
0
 public static int GetCategory(int ProfileId)
 {
     TDayDataSet tDayDataSet = new TDayDataSet();
     TDayDataSetTableAdapters.ProfilesTableAdapter ProfilesTableAdapter = new TDayDataSetTableAdapters.ProfilesTableAdapter();
     ProfilesTableAdapter.FillAll(tDayDataSet.Profiles);
     DataRow Row = tDayDataSet.Profiles.FindByProfileId(ProfileId);
     return (int)Row["Category"];
 }
Пример #4
0
 public bool IsCreate()
 {
     bool _IsInBills = false;
     TDayDataSet tempSet = new TDayDataSet();
     billsTableAdapter.FillByMonth(tempSet.Bills, FirstDayOfMonth, LastDayOfMonth);
     if (tempSet.Bills.Rows.Count > 0)
     {
         _IsInBills = true;
     }
     tempSet.Dispose();
     return _IsInBills;
 }
Пример #5
0
 public static bool Login(string Username, string Password)
 {
     bool _isAuthentificated = false;
     TDayDataSet TDaySet = new TDayDataSet();
     TDayDataSetTableAdapters.UsersTableAdapter usersTableAdapter = new TDayDataSetTableAdapters.UsersTableAdapter();
     usersTableAdapter.Fill(TDaySet.Users);
     foreach (DataRow Row in TDaySet.Users)
     {
         if (Row["Login"].ToString() == Username && Row["Password"].ToString() == Password)
         {
             _isAuthentificated = true;
             break;
         }
     }
     return _isAuthentificated;
 }
Пример #6
0
 private decimal GetPreviousBillTotal(int _ProfileId, DateTime FirstDayOfMonth, DateTime LastDayOfMonth)
 {
     decimal _PreBillTotal = decimal.Zero;
     TDayDataSet tempSet = new TDayDataSet();
     billsTableAdapter.FillByMonth(tempSet.Bills, FirstDayOfMonth.AddMonths(-1), LastDayOfMonth.AddMonths(-1));
     foreach (DataRow Row in tempSet.Bills)
     {
         if ((int)Row["ProfileId"] == _ProfileId)
         {
             _PreBillTotal = (decimal)Row["BillTotal"];
             break;
         }
     }
     tempSet.Dispose();
     return _PreBillTotal;
 }
Пример #7
0
 private DateTime GetPreviousBillPaidDate(int _ProfileId, DateTime FirstDayOfMonth, DateTime LastDayOfMonth)
 {
     DateTime _PreBillTotal = DateTime.Now.Date;
     TDayDataSet tempSet = new TDayDataSet();
     billsTableAdapter.FillByMonth(tempSet.Bills, FirstDayOfMonth.AddMonths(-1), LastDayOfMonth.AddMonths(-1));
     foreach (DataRow Row in tempSet.Bills)
     {
         if ((int)Row["ProfileId"] == _ProfileId)
         {
             _PreBillTotal = (DateTime)Row["PaidDate"];
             break;
         }
     }
     tempSet.Dispose();
     return _PreBillTotal;
 }
Пример #8
0
 private decimal GetBillTotal(int _ProfileId, DateTime FirstDayOfMonth, DateTime LastDayOfMonth)
 {
     decimal _PreBillTotal = decimal.Zero;
     TDayDataSet tempSet = new TDayDataSet();
     daysTableAdapter.FillByMonth(tempSet.Days, FirstDayOfMonth, LastDayOfMonth);
     foreach (DataRow Row in tempSet.Days)
     {
         if ((int)Row["ProfileId"] == _ProfileId)
         {
             _PreBillTotal += (decimal)Row["Total"];
         }
     }
     tempSet.Dispose();
     return _PreBillTotal;
 }
Пример #9
0
        public static void PrintTransportation(string Day)
        {
            TDayDataSet tDayDataSet = new TDayDataSet();
            TDayDataSetTableAdapters.TransportationTableAdapter transportationTableAdapter = new TDayDataSetTableAdapters.TransportationTableAdapter();
            TDayDataSetTableAdapters.ProfilesTableAdapter profilesTableAdapter = new TDayDataSetTableAdapters.ProfilesTableAdapter();
            try
            {
                if (File.Exists(System.Windows.Forms.Application.UserAppDataPath + @"\Transportation.pdf")) { File.Delete(System.Windows.Forms.Application.UserAppDataPath + @"\Transportation.pdf"); }
            }
            catch (IOException)
            {
                string Proc = GetFileProcessName("Transportation.pdf");
                if (File.Exists(System.Windows.Forms.Application.UserAppDataPath + @"\Transportation.pdf")) { File.Delete(System.Windows.Forms.Application.UserAppDataPath + @"\Transportation.pdf"); }
            }
            FileStream FS = new FileStream(System.Windows.Forms.Application.UserAppDataPath + @"\Transportation.pdf", FileMode.CreateNew);
            var Doc = new iTextSharp.text.Document(PageSize.A4.Rotate(), 20, 20, 20, 20);

            PdfWriter.GetInstance(Doc, FS);
            Doc.Open();
            PdfPTable table;
            if (Day == "Master")
            {
                table = new PdfPTable(20);
                table.HorizontalAlignment = Element.ALIGN_LEFT;
                table.WidthPercentage = 100;

                AddHeader(table, "Transportation", 20, new BaseColor(Color.DimGray), new BaseColor(Color.WhiteSmoke));
                AddHeader(table, Day, 16, new BaseColor(Color.DimGray), new BaseColor(Color.White));
                transportationTableAdapter.Fill(tDayDataSet.Transportation);
                AddPriviewCell(table, "Numb", 1);
                AddPriviewCell(table, "Name", 4);
                AddPriviewCell(table, "Category", 2);
                AddPriviewCell(table, "Address", 4);
                AddPriviewCell(table, "Phone", 2);
                AddPriviewCell(table, "HD#", 2);
                AddPriviewCell(table, "Mon", 1);
                AddPriviewCell(table, "Tue", 1);
                AddPriviewCell(table, "Wed", 1);
                AddPriviewCell(table, "Thu", 1);
                AddPriviewCell(table, "Fri", 1);
                //AddPriviewCell(table, "Comment", 1);
            }
            else
            {
                table = new PdfPTable(15);
                table.HorizontalAlignment = Element.ALIGN_LEFT;
                table.WidthPercentage = 100;

                AddHeader(table, "Transportation", 20, new BaseColor(Color.DimGray), new BaseColor(Color.WhiteSmoke));
                AddHeader(table, Day, 16, new BaseColor(Color.DimGray), new BaseColor(Color.White));
                transportationTableAdapter.Fill(tDayDataSet.Transportation);
                AddPriviewCell(table, "Numb", 1);
                AddPriviewCell(table, "Name", 4);
                AddPriviewCell(table, "Category", 2);
                AddPriviewCell(table, "Address", 4);
                AddPriviewCell(table, "Phone", 2);
                AddPriviewCell(table, "HD#", 2);
            }
            int Counter = 1;
            foreach (DataRow Row in tDayDataSet.Transportation)
            {
                switch (Day)
                {
                    case "Master":
                        AddPriviewCell(table, Counter.ToString(), 1);
                        AddPriviewCell(table, ProfileProvider.GetName((int)Row["ProfileId"]), 4);
                        AddPriviewCell(table, Row["Category"].ToString(), 2);
                        AddPriviewCell(table, Row["Adress"].ToString(), 4);
                        AddPriviewCell(table, Row["Phone"].ToString(), 2);
                        AddPriviewCell(table, Row["HandyDARTNumber"].ToString(), 2);
                        AddValueCell(table, (bool)Row["Monday"], true, 1);
                        AddValueCell(table, (bool)Row["Tuesday"], true, 1);
                        AddValueCell(table, (bool)Row["Wednesday"], true, 1);
                        AddValueCell(table, (bool)Row["Thursday"], true, 1);
                        AddValueCell(table, (bool)Row["Friday"], true, 1);
                        //AddPriviewCell(table, Row["Comments"].ToString(), 1);
                        Counter++;
                        break;
                    case "Monday":
                        if ((bool)Row["Monday"])
                        {
                            AddPriviewCell(table, Counter.ToString(), 1);
                            AddPriviewCell(table, ProfileProvider.GetName((int)Row["ProfileId"]), 4);
                            AddPriviewCell(table, Row["Category"].ToString(), 2);
                            AddPriviewCell(table, Row["Adress"].ToString(), 4);
                            AddPriviewCell(table, Row["Phone"].ToString(), 2);
                            AddPriviewCell(table, Row["HandyDARTNumber"].ToString(), 2);
                            Counter++;
                        }
                        break;
                    case "Tuesday":
                        if ((bool)Row["Tuesday"])
                        {
                            AddPriviewCell(table, Counter.ToString(), 1);
                            AddPriviewCell(table, ProfileProvider.GetName((int)Row["ProfileId"]), 4);
                            AddPriviewCell(table, Row["Category"].ToString(), 2);
                            AddPriviewCell(table, Row["Adress"].ToString(), 4);
                            AddPriviewCell(table, Row["Phone"].ToString(), 2);
                            AddPriviewCell(table, Row["HandyDARTNumber"].ToString(), 2);
                            Counter++;
                        }
                        break;
                    case "Wednesday":
                        if ((bool)Row["Wednesday"])
                        {
                            AddPriviewCell(table, Counter.ToString(), 1);
                            AddPriviewCell(table, ProfileProvider.GetName((int)Row["ProfileId"]), 4);
                            AddPriviewCell(table, Row["Category"].ToString(), 2);
                            AddPriviewCell(table, Row["Adress"].ToString(), 4);
                            AddPriviewCell(table, Row["Phone"].ToString(), 2);
                            AddPriviewCell(table, Row["HandyDARTNumber"].ToString(), 2);
                            Counter++;
                        }
                        break;
                    case "Thursday":
                        if ((bool)Row["Thursday"])
                        {
                            AddPriviewCell(table, Counter.ToString(), 1);
                            AddPriviewCell(table, ProfileProvider.GetName((int)Row["ProfileId"]), 4);
                            AddPriviewCell(table, Row["Category"].ToString(), 2);
                            AddPriviewCell(table, Row["Adress"].ToString(), 4);
                            AddPriviewCell(table, Row["Phone"].ToString(), 2);
                            AddPriviewCell(table, Row["HandyDARTNumber"].ToString(), 2);
                            Counter++;
                        }
                        break;
                    case "Friday":
                        if ((bool)Row["Friday"])
                        {
                            AddPriviewCell(table, Counter.ToString(), 1);
                            AddPriviewCell(table, ProfileProvider.GetName((int)Row["ProfileId"]), 4);
                            AddPriviewCell(table, Row["Category"].ToString(), 2);
                            AddPriviewCell(table, Row["Adress"].ToString(), 4);
                            AddPriviewCell(table, Row["Phone"].ToString(), 2);
                            AddPriviewCell(table, Row["HandyDARTNumber"].ToString(), 2);
                            Counter++;
                        }
                        break;
                }

            }
            Doc.Add(table);
            Doc.Close();
            Process.Start(System.Windows.Forms.Application.UserAppDataPath + @"\Transportation.pdf");
        }
Пример #10
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");
        }
Пример #11
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");
        }
Пример #12
0
        private void toolStripButton12_Click(object sender, EventArgs e)
        {
            if (dataGridView7.SelectedCells.Count > 0)
            {
                TDayDataSet tempSet = new TDayDataSet();
                Bill _Bill = new Bill();
                billsTableAdapter.FillByMonth(tempSet.Bills, _Bill.FirstDayOfMonth, _Bill.LastDayOfMonth);
                int Index = -1;
                foreach (DataRow Row in tempSet.Bills)
                {
                    if ((int)Row["ProfileId"] == (int)dataGridView7.Rows[dataGridView7.SelectedCells[0].RowIndex].Cells["dataGridViewTextBoxColumn1"].Value)
                    {
                        Index = (int)Row["BillId"];
                            break;
                    }
                }
                if (Index != -1)
                {
                    panel8.Visible = false;
                    foreach (DataGridViewRow Row in dataGridView5.Rows)
                    {
                        if ((int)Row.Cells["billIdDataGridViewTextBoxColumn"].Value == Index)
                        {
                            DataGridViewCellEventArgs eve = new DataGridViewCellEventArgs(0, Row.Index);
                            dataGridView5_CellClick(sender, eve);
                            dataGridView5.Rows[Row.Index].Selected = true;
                            break;
                        }
                    }
                }
                else
                {
                    BillsItem item = new BillsItem((int)dataGridView7.Rows[dataGridView7.SelectedCells[0].RowIndex].Cells["dataGridViewTextBoxColumn1"].Value, _Bill.FirstDayOfMonth, _Bill.LastDayOfMonth);
                    item.Insert();
                    billsTableAdapter.Fill(tDayDataSet.Bills);
                    panel8.Visible = false;
                    dataGridView7.Rows[dataGridView7.Rows.Count - 1].Selected = true;
                }

            }
        }