Ejemplo n.º 1
0
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            //setting local variables
            bool    blnThereIsAProblem = false;
            bool    blnFatalError      = false;
            string  strErrorMessage    = "";
            string  strValueForValidation;
            decimal decTaskPrice = 0;
            string  strTaskDescription;
            int     intRecordsReturned;

            try
            {
                if (cboSelectOffice.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Office Has Not Been Selected\n";
                }
                strTaskDescription = txtTaskDescription.Text;
                if (strTaskDescription == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Task Description was not Entered\n";
                }
                strValueForValidation = txtTaskPrice.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Task Price is not Numberic\n";
                }
                else
                {
                    decTaskPrice = Convert.ToDecimal(strValueForValidation);
                }

                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                TheFindWOVTaskByOfficeIDandDescriptionDataSet = TheWOVInvoicingClass.FindWOVTaskByOfficeIDAndDescription(MainWindow.gintWarehouseID, strTaskDescription);

                intRecordsReturned = TheFindWOVTaskByOfficeIDandDescriptionDataSet.FindWOVTaskByOfficeIDAndDescription.Rows.Count;

                if (intRecordsReturned > 0)
                {
                    TheMessagesClass.ErrorMessage("The Task already exists for this office");
                    return;
                }

                blnFatalError = TheWOVInvoicingClass.InsertWOVTask(strTaskDescription, MainWindow.gintWarehouseID, decTaskPrice);

                if (blnFatalError == true)
                {
                    throw new Exception();
                }

                TheMessagesClass.InformationMessage("The Task Has Been Entered");

                ResetControls();
            }
            catch (Exception Ex)
            {
                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Add WOV Tasks // Process Button " + Ex.Message);

                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Add WOV Tasks // Process Button " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        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);
        }