private void btnAddEmployee_Click(object sender, RoutedEventArgs e)
        {
            bool blnFatalError = false;

            try
            {
                blnFatalError = TheDataValidationClass.VerifyDoubleData(txtEnterHours.Text);
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage("The Hours is not Numeric");
                    return;
                }

                gdecHours = Convert.ToDecimal(txtEnterHours.Text);

                //adding the record
                ProjectWorkCompletedDataSet.workcompletedRow NewWorkRow = TheEmployeeWorkCompleteDataSet.workcompleted.NewworkcompletedRow();

                NewWorkRow.EmployeeID        = MainWindow.gintEmployeeID;
                NewWorkRow.FirstName         = MainWindow.gstrFirstName;
                NewWorkRow.LastName          = MainWindow.gstrLastName;
                NewWorkRow.ProjectID         = MainWindow.gintProjectID;
                NewWorkRow.AssignedProjectID = MainWindow.gstrAssignedProjectID;
                NewWorkRow.TaskID            = 0;
                NewWorkRow.WorkTask          = "";
                NewWorkRow.Hours             = gdecHours;
                NewWorkRow.FootagePieces     = 0;

                TheEmployeeWorkCompleteDataSet.workcompleted.Rows.Add(NewWorkRow);

                dgrResults.ItemsSource = TheEmployeeWorkCompleteDataSet.workcompleted;

                txtEnterLastLame.Text = "";
                btnAddHours.IsEnabled = true;
                txtEnterFootage.Text  = "0";
                gdecTotalHours       += gdecHours;
                txtTotalHours.Text    = Convert.ToString(gdecTotalHours);
                gblnHoursEntered      = false;
                txtEnterLastLame.Focus();
                gintEmployeeCounter++;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Enter Approved Transactions // Add Employee Button " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        private void btnAddHours_Click(object sender, RoutedEventArgs e)
        {
            int    intCounter;
            int    intNumberOfRecords;
            string strValueForValidation;
            bool   blnFatalError      = false;
            bool   blnThereIsAProblem = false;
            string strErrorMessage    = "";
            int    intFootagePieces   = 0;

            try
            {
                mitRemoveEmployee.IsEnabled     = false;
                mitRemoveTransactions.IsEnabled = true;

                intNumberOfRecords = TheEmployeeWorkCompleteDataSet.workcompleted.Rows.Count - 1;

                if (intNumberOfRecords == -1)
                {
                    TheMessagesClass.ErrorMessage("There Are No Employees Assigned to this Project");
                    return;
                }

                strValueForValidation = txtEnterHours.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    strErrorMessage += "Total Hours is not Numeric\n";
                    blnFatalError    = true;
                }
                else
                {
                    gdecHours = Convert.ToDecimal(strValueForValidation);
                }
                strValueForValidation = txtEnterFootage.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    strErrorMessage += "The Footage or Pieces is not an Integer\n";
                    blnFatalError    = true;
                }
                else
                {
                    intFootagePieces = Convert.ToInt32(strValueForValidation);
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                if (gblnHoursEntered == true)
                {
                    gdecHours = 0;
                }

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    ProjectWorkCompletedDataSet.workcompletedRow NewWorkRow = TheProjectWorkCompletedDataSet.workcompleted.NewworkcompletedRow();

                    NewWorkRow.AssignedProjectID = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].AssignedProjectID;
                    NewWorkRow.EmployeeID        = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].EmployeeID;
                    NewWorkRow.FirstName         = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].FirstName;
                    NewWorkRow.LastName          = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].LastName;
                    NewWorkRow.ProjectID         = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].ProjectID;
                    NewWorkRow.TaskID            = MainWindow.gintWorkTaskID;
                    NewWorkRow.WorkTask          = MainWindow.gstrWorkTask;
                    NewWorkRow.Hours             = gdecHours;
                    NewWorkRow.FootagePieces     = intFootagePieces;

                    TheProjectWorkCompletedDataSet.workcompleted.Rows.Add(NewWorkRow);
                    gblnHoursEntered = true;

                    txtEnterFootage.Text = "";
                    txtEnterTask.Text    = "";

                    txtEnterTask.Focus();
                }


                gintTaskCounter++;
                dgrResults.ItemsSource = TheProjectWorkCompletedDataSet.workcompleted;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Enter Approved Transaction // Add Hours " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Ejemplo n.º 3
0
        private void btnAddHours_Click(object sender, RoutedEventArgs e)
        {
            int    intCounter;
            int    intNumberOfRecords;
            string strValueForValidation;
            bool   blnFatalError      = false;
            bool   blnThereIsAProblem = false;
            string strErrorMessage    = "";
            int    intFootagePieces   = 0;
            int    intRecordsReturned = 0;
            double douProbability;
            double douMean;
            double douHoursEntered;
            bool   blnOverHours;

            try
            {
                mitRemoveEmployee.IsEnabled     = false;
                mitRemoveTransactions.IsEnabled = true;

                intNumberOfRecords = TheEmployeeWorkCompleteDataSet.workcompleted.Rows.Count - 1;

                if (intNumberOfRecords == -1)
                {
                    TheMessagesClass.ErrorMessage("There Are No Employees Assigned to this Project");
                    return;
                }
                if (cboSelectTask.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Work Task was not Selected\n";
                }
                strValueForValidation = txtEnterHours.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    strErrorMessage += "Total Hours is not Numeric\n";
                    blnFatalError    = true;
                }
                else
                {
                    gdecHours = Convert.ToDecimal(strValueForValidation);
                }
                strValueForValidation = txtEnterFootage.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    strErrorMessage += "The Footage or Pieces is not an Integer\n";
                    blnFatalError    = true;
                }
                else
                {
                    intFootagePieces = Convert.ToInt32(strValueForValidation);
                }
                strValueForValidation = txtTransactionDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Date is not a Date\n";
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                if (gblnHoursEntered == true)
                {
                    gdecHours = 0;
                }

                TheFindWorkTaskStatsByTaskIDDataSet = TheWorkTaskStatsClass.FindWorkTaskStatsByTaskID(MainWindow.gintWorkTaskID);

                intRecordsReturned = TheFindWorkTaskStatsByTaskIDDataSet.FindWorkTaskStatsByWorkTaskID.Rows.Count;

                if (intRecordsReturned > 0)
                {
                    douMean         = Convert.ToDouble(TheFindWorkTaskStatsByTaskIDDataSet.FindWorkTaskStatsByWorkTaskID[0].TaskMean);
                    douHoursEntered = Convert.ToDouble(gdecHours);

                    douProbability = CalculatePropability(douMean, douHoursEntered);


                    if (douProbability < .0001)
                    {
                        TheMessagesClass.ErrorMessage("The Hours Entered Are Outside Expected Range\nPlease Return Return Sheet To Manager");
                        return;
                    }
                }



                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    blnOverHours = CheckEmployeeTotalHours(TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].EmployeeID, gdecHours);

                    if (blnOverHours == true)
                    {
                        TheMessagesClass.ErrorMessage(TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].FirstName + " " + TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].LastName + " Has Worked Over 16 Hours\nPlease Return Sheet To Manager");

                        return;
                    }

                    ProjectWorkCompletedDataSet.workcompletedRow NewWorkRow = TheProjectWorkCompletedDataSet.workcompleted.NewworkcompletedRow();

                    NewWorkRow.AssignedProjectID = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].AssignedProjectID;
                    NewWorkRow.EmployeeID        = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].EmployeeID;
                    NewWorkRow.FirstName         = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].FirstName;
                    NewWorkRow.LastName          = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].LastName;
                    NewWorkRow.ProjectID         = TheEmployeeWorkCompleteDataSet.workcompleted[intCounter].ProjectID;
                    NewWorkRow.TaskID            = MainWindow.gintWorkTaskID;
                    NewWorkRow.WorkTask          = MainWindow.gstrWorkTask;
                    NewWorkRow.Hours             = gdecHours;
                    NewWorkRow.FootagePieces     = intFootagePieces;

                    TheProjectWorkCompletedDataSet.workcompleted.Rows.Add(NewWorkRow);
                    gblnHoursEntered = true;

                    txtEnterFootage.Text = "";
                    txtEnterTask.Text    = "";

                    txtEnterTask.Focus();
                }


                gintTaskCounter++;
                dgrResults.ItemsSource = TheProjectWorkCompletedDataSet.workcompleted;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Add Project Labor // Add Hours " + Ex.Message);

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