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

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

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

                MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice.Rows.Clear();

                WisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoiceRow NewBillingRow = MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice.NewwisconsindesigninvoiceRow();

                NewBillingRow.BusinessAddress = "PRICING";
                NewBillingRow.BusinessName    = "";
                NewBillingRow.Date            = DateTime.Now;
                NewBillingRow.DockID          = "";
                NewBillingRow.ProjectTotal    = 0;
                NewBillingRow.PermitType      = "";
                NewBillingRow.PermitCost      = 0;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    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;
                    }
                    else if (TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].WOVTaskDescription == "MC05")
                    {
                        NewBillingRow.MC05 = TheFindSortedWOVTasksByOfficeIDDataSet.FindSortedWOVTasksByOfficeID[intCounter].Price;
                    }
                }

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

                TheMessagesClass.ErrorMessage(Ex.ToString());

                blnFatalError = true;
            }

            return(blnFatalError);
        }
        private bool LoadWisconsinInvoice(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
            {
                ResetMilwaukeeDesignInvoice();
                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.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice[intReportCounter].DockID)
                                            {
                                                blnItemFound = true;

                                                if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "PP1")
                                                {
                                                    MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice[intReportCounter].PP1          += Convert.ToDecimal(intTotalQuantity);
                                                    MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice[intReportCounter].ProjectTotal += decTotalPrice;
                                                }
                                                else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "PP2")
                                                {
                                                    MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice[intReportCounter].PP2          += Convert.ToDecimal(intTotalQuantity);
                                                    MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice[intReportCounter].ProjectTotal += decTotalPrice;
                                                }
                                                else if (TheFindProjectTechPayItemsTotalsByProjectIDDataSet.FindProjectTechPayItemsTotalsByProjectID[intPayCounter].TechPayCode == "MC05")
                                                {
                                                    MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice[intReportCounter].MC05         += Convert.ToDecimal(intTotalQuantity);
                                                    MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice[intReportCounter].ProjectTotal += decTotalPrice;
                                                }
                                            }
                                        }
                                    }

                                    if (blnItemFound == false)
                                    {
                                        WisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoiceRow NewProjectRow = MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice.NewwisconsindesigninvoiceRow();

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

                                        //getting the last update date
                                        datClosingDate             = FindClosingDate(MainWindow.gintProjectID);
                                        NewProjectRow.Date         = datClosingDate;
                                        NewProjectRow.ProjectTotal = decTotalPrice;
                                        NewProjectRow.PermitType   = "";
                                        NewProjectRow.PermitCost   = 0;

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

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

                                        MainWindow.TheWisconsinDesignProjectInvoicingDataSet.wisconsindesigninvoice.Rows.Add(NewProjectRow);

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

                TheMessagesClass.ErrorMessage(Ex.ToString());

                blnFatalError = true;
            }

            return(blnFatalError);
        }