private bool ResetClevelandDesignInvoice()
        {
            int  intCounter;
            int  intNumberOfRecords;
            bool blnFatalError = false;

            try
            {
                TheFindSortedWOVTasksByOfficeIDDataSet = TheWOVInvoicingClass.FindSortedWOVTasksByOfficeID(100000);
                gintReportNumberOfRecords = 0;
                gintReportCounter         = 0;

                intNumberOfRecords = TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID.Rows.Count - 1;

                MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice.Rows.Clear();

                ClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoiceRow NewBillingRow = MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice.NewclevelanddesigninvoiceRow();

                NewBillingRow.BusinessAddress    = "PRICING";
                NewBillingRow.BusinessName       = "";
                NewBillingRow.Date               = DateTime.Now;
                NewBillingRow.DockID             = "";
                NewBillingRow.TotalProjectCharge = 0;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    if (TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].WOVTaskDescription == "WOV1")
                    {
                        NewBillingRow.WOV1 = TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].Price;
                    }
                    else if (TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].WOVTaskDescription == "WOV2")
                    {
                        NewBillingRow.WOV2 = TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].Price;
                    }
                    else if (TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].WOVTaskDescription == "WOV3")
                    {
                        NewBillingRow.WOV3 = TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].Price;
                    }
                    else if (TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].WOVTaskDescription == "PP1")
                    {
                        NewBillingRow.PP1 = TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].Price;
                    }
                    else if (TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].WOVTaskDescription == "PP2")
                    {
                        NewBillingRow.PP2 = TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].Price;
                    }

                    NewBillingRow.PermitCost     = 0;
                    NewBillingRow.PermitQuantity = 0;
                    NewBillingRow.PermitType     = "";
                }

                MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice.Rows.Add(NewBillingRow);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Design Project Invoicing // Reset Cleveland Design Invoice " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());

                blnFatalError = true;
            }

            return(blnFatalError);
        }
        private bool LoadClevelandInvoice(int intOfficeID, int intBillingID)
        {
            bool     blnFatalError = false;
            int      intProjectCounter;
            int      intProjectNumberOfRecords;
            int      intPayCounter;
            int      intPayNumberOfRecords;
            bool     blnIsSelected;
            int      intReportCounter;
            bool     blnItemFound;
            string   strProjectName;
            string   strProjectAddress;
            int      intTotalQuantity;
            decimal  decPrice;
            decimal  decTotalPrice;
            string   strWOVTaskDescription;
            DateTime datClosingDate;

            try
            {
                ResetClevelandDesignInvoice();
                ThefindDesignProjectsForInvoicingByOfficeBillingCodeDataSet = TheWOVInvoicingClass.FindDesignProjectsForInvoicingByOfficeBillingCode(intOfficeID, intBillingID);

                intProjectNumberOfRecords = ThefindDesignProjectsForInvoicingByOfficeBillingCodeDataSet.FindDesignProjectsForInvoicingByOfficeBillingCode.Rows.Count - 1;

                if (intProjectNumberOfRecords > -1)
                {
                    for (intProjectCounter = 0; intProjectCounter <= intProjectNumberOfRecords; intProjectCounter++)
                    {
                        MainWindow.gintProjectID         = ThefindDesignProjectsForInvoicingByOfficeBillingCodeDataSet.FindDesignProjectsForInvoicingByOfficeBillingCode[intProjectCounter].ProjectID;
                        MainWindow.gstrAssignedProjectID = ThefindDesignProjectsForInvoicingByOfficeBillingCodeDataSet.FindDesignProjectsForInvoicingByOfficeBillingCode[intProjectCounter].AssignedProjectID;
                        strProjectAddress = ThefindDesignProjectsForInvoicingByOfficeBillingCodeDataSet.FindDesignProjectsForInvoicingByOfficeBillingCode[intProjectCounter].ProjectAddress;
                        strProjectName    = ThefindDesignProjectsForInvoicingByOfficeBillingCodeDataSet.FindDesignProjectsForInvoicingByOfficeBillingCode[intProjectCounter].ProjectName;

                        blnIsSelected = ProjectSelected(MainWindow.gintProjectID);

                        if (blnIsSelected == true)
                        {
                            gblnDisplayInvoice = true;

                            TheFindProjectTechPayItemsTotalsByProjectIDDataSet = TheTechPayClass.FindProjectTechPayItemsTotalsByProjectID(MainWindow.gintProjectID);

                            intPayNumberOfRecords = TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID.Rows.Count - 1;

                            if (intPayNumberOfRecords > -1)
                            {
                                for (intPayCounter = 0; intPayCounter <= intPayNumberOfRecords; intPayCounter++)
                                {
                                    blnItemFound          = false;
                                    intTotalQuantity      = TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TotalQuantity;
                                    strWOVTaskDescription = TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode;

                                    TheFindWOVTaskByOfficeIDAndDescriptionDataSet = TheWOVInvoicingClass.FindWOVTaskByOfficeIDAndDescription(MainWindow.gintWarehouseID, strWOVTaskDescription);

                                    decPrice = TheFindWOVTaskByOfficeIDAndDescriptionDataSet.FindWOVTaskByOfficeIDAndDescription[0].Price;

                                    decTotalPrice = decPrice * Convert.ToDecimal(intTotalQuantity);

                                    if (gintReportCounter > 0)
                                    {
                                        for (intReportCounter = 1; intReportCounter <= gintReportNumberOfRecords; intReportCounter++)
                                        {
                                            if (MainWindow.gstrAssignedProjectID == MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].DockID)
                                            {
                                                blnItemFound = true;

                                                if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "WOV1")
                                                {
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].WOV1 += Convert.ToDecimal(intTotalQuantity);
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].TotalProjectCharge += decTotalPrice;
                                                }
                                                else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "WOV2")
                                                {
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].WOV2 += Convert.ToDecimal(intTotalQuantity);
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].TotalProjectCharge += decTotalPrice;
                                                }
                                                else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "WOV3")
                                                {
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].WOV3 += Convert.ToDecimal(intTotalQuantity);
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].TotalProjectCharge += decTotalPrice;
                                                }
                                                else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "PP1")
                                                {
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].PP1 += Convert.ToDecimal(intTotalQuantity);
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].TotalProjectCharge += decTotalPrice;
                                                }
                                                else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "PP2")
                                                {
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].PP2 += Convert.ToDecimal(intTotalQuantity);
                                                    MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice[intReportCounter].TotalProjectCharge += decTotalPrice;
                                                }
                                            }
                                        }
                                    }

                                    if (blnItemFound == false)
                                    {
                                        ClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoiceRow NewProjectRow = MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice.NewclevelanddesigninvoiceRow();

                                        NewProjectRow.BusinessAddress = strProjectAddress;
                                        NewProjectRow.BusinessName    = strProjectName;
                                        NewProjectRow.DockID          = MainWindow.gstrAssignedProjectID;

                                        //getting the last update date
                                        datClosingDate     = FindClosingDate(MainWindow.gintProjectID);
                                        NewProjectRow.Date = datClosingDate;
                                        NewProjectRow.TotalProjectCharge = decTotalPrice;

                                        if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "WOV1")
                                        {
                                            NewProjectRow.WOV1 = Convert.ToDecimal(intTotalQuantity);
                                            NewProjectRow.WOV2 = 0;
                                            NewProjectRow.WOV3 = 0;
                                            NewProjectRow.PP1  = 0;
                                            NewProjectRow.PP2  = 0;
                                        }
                                        else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "WOV2")
                                        {
                                            NewProjectRow.WOV1 = 0;
                                            NewProjectRow.WOV2 = Convert.ToDecimal(intTotalQuantity);
                                            NewProjectRow.WOV3 = 0;
                                            NewProjectRow.PP1  = 0;
                                            NewProjectRow.PP2  = 0;
                                        }
                                        else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "WOV3")
                                        {
                                            NewProjectRow.WOV1 = 0;
                                            NewProjectRow.WOV2 = 0;
                                            NewProjectRow.WOV3 = Convert.ToDecimal(intTotalQuantity);
                                            NewProjectRow.PP1  = 0;
                                            NewProjectRow.PP2  = 0;
                                        }
                                        else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "PP1")
                                        {
                                            NewProjectRow.WOV1 = 0;
                                            NewProjectRow.WOV2 = 0;
                                            NewProjectRow.WOV3 = 0;
                                            NewProjectRow.PP1  = Convert.ToDecimal(intTotalQuantity);
                                            NewProjectRow.PP2  = 0;
                                        }
                                        else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "PP2")
                                        {
                                            NewProjectRow.WOV1 = 0;
                                            NewProjectRow.WOV2 = 0;
                                            NewProjectRow.WOV3 = 0;
                                            NewProjectRow.PP1  = 0;
                                            NewProjectRow.PP2  = Convert.ToDecimal(intTotalQuantity);
                                        }



                                        MainWindow.TheClevelandDesignProjectInvoicingDataSet.clevelanddesigninvoice.Rows.Add(NewProjectRow);

                                        gintReportNumberOfRecords = gintReportCounter + 1;
                                        gintReportCounter++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Design Project Invoicing // Load Cleveland Invoice " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());

                blnFatalError = true;
            }

            return(blnFatalError);
        }