Пример #1
0
        public FindJSIMainByDateMatchDataSet FindJSIMainByDateMatch(DateTime datTransactionDate)
        {
            try
            {
                aFindJSIMainByDateMatchDataSet      = new FindJSIMainByDateMatchDataSet();
                aFindJSIMainByDateMatchTableAdapter = new FindJSIMainByDateMatchDataSetTableAdapters.FindJSIMainByDateMatchTableAdapter();
                aFindJSIMainByDateMatchTableAdapter.Fill(aFindJSIMainByDateMatchDataSet.FindJSIMainByDateMatch, datTransactionDate);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "JSI Main Class // Find JSI Main By Date Match " + Ex.Message);
            }

            return(aFindJSIMainByDateMatchDataSet);
        }
Пример #2
0
        private void btnMainProcess_Click(object sender, RoutedEventArgs e)
        {
            //this will insert into the table
            string   strValueForValidation = "";
            string   strErrorMessage       = "";
            bool     blnFatalError         = false;
            bool     blnThereIsAProblem    = false;
            string   strAssignedProjectID;
            string   strVehicleNumber;
            DateTime datTransactionDate = DateTime.Now;
            int      intRecordsReturned;
            DateTime datInspectionDate = DateTime.Now;
            int      intCounter;
            int      intNumberOfRecords;
            int      intEmployeeID;

            try
            {
                strAssignedProjectID = txtAssignedProjectID.Text;
                if (strAssignedProjectID == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Project Was Not Entered\n";
                }
                else
                {
                    TheFindProjectMatrixByCustomerProjectIDDataSet = TheProjectMatrixClass.FindProjectMatrixByCustomerProjectID(strAssignedProjectID);

                    intRecordsReturned = TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID.Rows.Count;

                    if (intRecordsReturned < 1)
                    {
                        TheFindProjectMatrixByAssignedProjectIDDataSet = TheProjectMatrixClass.FindProjectMatrixByAssignedProjectID(strAssignedProjectID);

                        intRecordsReturned = TheFindProjectMatrixByAssignedProjectIDDataSet.FindProjectMatrixByAssignedProjectID.Rows.Count;

                        if (intRecordsReturned > 0)
                        {
                            MainWindow.gintProjectID = TheFindProjectMatrixByAssignedProjectIDDataSet.FindProjectMatrixByAssignedProjectID[0].ProjectID;
                        }
                        else if (intRecordsReturned < 1)
                        {
                            blnFatalError    = true;
                            strErrorMessage += "The Project Was Not Found\n";
                        }
                    }
                    else
                    {
                        MainWindow.gintProjectID = TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID[0].ProjectID;
                    }
                }
                if (cboSelectEmployee.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Employee Was Not Selected\n";
                }
                if (cboSelectDepartment.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Department Was Not Selected\n";
                }
                strVehicleNumber = txtVehicleNumber.Text;
                if (strVehicleNumber == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "Vehicle Number Was Not Entered\n";
                }
                else
                {
                    TheFindActiveVehicleMainByVehicleNumberDataSet = TheVehicleMainClass.FindActiveVehicleMainByVehicleNumber(strVehicleNumber);

                    intRecordsReturned = TheFindActiveVehicleMainByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber.Rows.Count;

                    if (intRecordsReturned < 1)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Vehicle Number Was Not Found\n";
                    }
                    else
                    {
                        MainWindow.gintVehicleID = TheFindActiveVehicleMainByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber[0].VehicleID;
                    }
                }
                strValueForValidation = txtInspectionDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnFatalError == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Inspection Date is not a Date\n";
                }
                else
                {
                    datInspectionDate = Convert.ToDateTime(strValueForValidation);

                    blnThereIsAProblem = TheDataValidationClass.verifyDateRange(datInspectionDate, DateTime.Now);

                    if (blnThereIsAProblem == true)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Inspection is after Today\n";
                    }
                }
                if (cboSelectManager.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Manager Was Not Selected\n";
                }
                if (cboSelectInspector.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Inspector Was Not Selected\n";
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                MainWindow.gdatInspectionDate = datInspectionDate;

                intNumberOfRecords = TheJSIEmployeeAssignedDataSet.jsiemployeeassigned.Rows.Count - 1;

                if (intNumberOfRecords < 0)
                {
                    TheMessagesClass.ErrorMessage("No Employees Were Added");
                    return;
                }

                MainWindow.gintEmployeeID = TheJSIEmployeeAssignedDataSet.jsiemployeeassigned[0].EmployeeID;

                blnFatalError = TheJSIMainClass.InsertIntoJSIMain(datTransactionDate, MainWindow.gintProjectID, MainWindow.gintEmployeeID, MainWindow.gintDepartmentID, MainWindow.gintVehicleID, datInspectionDate, MainWindow.gintManagerID, MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, MainWindow.gintInspectingEmployeeID);

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

                TheFindJSIMainByDateMatchDataSet = TheJSIMainClass.FindJSIMainByDateMatch(datTransactionDate);

                MainWindow.gintJSITransationID = TheFindJSIMainByDateMatchDataSet.FindJSIMainByDateMatch[0].JSITransactionID;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    blnFatalError = TheJSIMainClass.InsertJSIEmployee(MainWindow.gintJSITransationID, TheJSIEmployeeAssignedDataSet.jsiemployeeassigned[intCounter].EmployeeID, datTransactionDate);

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

                blnFatalError = TheEmployeeDataEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Create JSI Entry // JSI Created");

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

                JSIPPEWindow JSIPPEWindow = new JSIPPEWindow();
                JSIPPEWindow.ShowDialog();

                ResetControls();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Create JSI Entry // Main Process Button " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }