Example #1
0
        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);

                if (gdecHours > 16)
                {
                    TheMessagesClass.ErrorMessage("Employees Cannot work more than 16 Hours");
                    return;
                }

                gdecHours = gdecHours - gdecDriveTime - gdecNonProductiveTime - gdecLunchHour;

                gdecTotalProjectHours = gdecHours;

                //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);

                dgrTransactions.ItemsSource = TheEmployeeWorkCompleteDataSet.workcompleted;

                txtEnterLastName.Text = "";
                btnAddTask.IsEnabled  = true;
                txtEnterFootage.Text  = "0";
                gdecTotalHours       += gdecHours;
                txtTotalHours.Text    = Convert.ToString(gdecTotalHours);
                gblnHoursEntered      = false;
                txtEnterLastName.Focus();
                gintEmployeeCounter++;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Add Project Labor // Add Employee Button " + Ex.Message);

                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Add Project Labor // Add Employee Button " + Ex.ToString());

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Example #2
0
        private void btnAddTask_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
            {
                btnResetEmployees.IsEnabled = false;
                btnResetTask.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 = gdecTotalProjectHours;
                }
                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 = txtEnterDate.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++;
                dgrTransactions.ItemsSource = TheProjectWorkCompletedDataSet.workcompleted;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Add Project Labor // Add Task Button " + Ex.Message);

                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Add Project Labor // Add Task Button " + Ex.ToString());

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