private void mitExit_Click(object sender, RoutedEventArgs e)
 {
     txtEnterStartDate.Text = "";
     txtEnterEndDate.Text   = "";
     TheFindLaborHoursByDateRangeDataSet = TheEmployeeProjectAssignmentClass.FindLaborHoursByDateRange(DateTime.Now, DateTime.Now);
     dgvResults.ItemsSource = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange;
     Visibility             = Visibility.Hidden;
 }
        private void mitFindTransactions_Click(object sender, RoutedEventArgs e)
        {
            //setting local variables
            string strValueForValidation;
            bool   blnThereIsAProblem = false;
            bool   blnFatalError      = false;
            string strErrorMessage    = "";

            strValueForValidation = txtEnterStartDate.Text;
            blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
            if (blnThereIsAProblem == true)
            {
                blnFatalError    = true;
                strErrorMessage += "The Start Date is not a Date\n";
            }
            else
            {
                MainWindow.gdatStartDate = Convert.ToDateTime(strValueForValidation);
            }
            strValueForValidation = txtEnterEndDate.Text;
            blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
            if (blnThereIsAProblem == true)
            {
                blnFatalError    = true;
                strErrorMessage += "The End Date is not a Date\n";
            }
            else
            {
                MainWindow.gdatEndDate = Convert.ToDateTime(strValueForValidation);
            }
            if (blnFatalError == true)
            {
                TheMessagesClass.ErrorMessage(strErrorMessage);
                return;
            }
            else
            {
                blnFatalError = TheDataValidationClass.verifyDateRange(MainWindow.gdatStartDate, MainWindow.gdatEndDate);
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage("The Start Date is after the End Date");
                    return;
                }
            }

            TheFindLaborHoursByDateRangeDataSet = TheEmployeeProjectAssignmentClass.FindLaborHoursByDateRange(MainWindow.gdatStartDate, MainWindow.gdatEndDate);

            dgvResults.ItemsSource = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange;
        }
Exemple #3
0
        public FindLaborHoursByDateRangeDataSet FindLaborHoursByDateRange(DateTime datStartDate, DateTime datEndDate)
        {
            try
            {
                aFindLaborHoursByDateRangeDataSet      = new FindLaborHoursByDateRangeDataSet();
                aFindLaborHoursByDateRangeTableAdapter = new FindLaborHoursByDateRangeDataSetTableAdapters.FindLaborHoursByDateRangeTableAdapter();
                aFindLaborHoursByDateRangeTableAdapter.Fill(aFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange, datStartDate, datEndDate);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Employee Project Assignment Class // Find Labor Hours By Date Range " + Ex.Message);
            }

            return(aFindLaborHoursByDateRangeDataSet);
        }
        private void dgvResults_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid     dataGrid;
            DataGridRow  selectedRow;
            DataGridCell TransactionID;
            string       strTransactionID;

            try
            {
                if (dgvResults.SelectedIndex > -1)
                {
                    //setting local variable
                    dataGrid         = dgvResults;
                    selectedRow      = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(dataGrid.SelectedIndex);
                    TransactionID    = (DataGridCell)dataGrid.Columns[0].GetCellContent(selectedRow).Parent;
                    strTransactionID = ((TextBlock)TransactionID.Content).Text;
                    TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Has Selected A Transaction to Be Editted");

                    //find the record
                    MainWindow.gintTransactionID = Convert.ToInt32(strTransactionID);

                    EditSelectedLaborTransaction EditSelectedLaborTransaction = new EditSelectedLaborTransaction();
                    EditSelectedLaborTransaction.ShowDialog();

                    TheFindLaborHoursByDateRangeDataSet = TheEmployeeProjectAssignmentClass.FindLaborHoursByDateRange(MainWindow.gdatStartDate, MainWindow.gdatEndDate);

                    dgvResults.ItemsSource = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange;
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Edit Project Labor // Grid Selection " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemple #5
0
        public bool UpdateWorkTaskStatsTable()
        {
            bool     blnFatalError = false;
            DateTime datStartDate  = DateTime.Now;
            DateTime datEndDate    = DateTime.Now;
            int      intCounter;
            int      intNumberOfRecords;
            double   douHours;
            int      intTaskCounter;
            bool     blnItemFound;
            int      intWorkTaskID;
            decimal  decMean;
            decimal  decVariance;
            decimal  dectotalHours;
            int      intItems;
            string   strWorkTask;
            double   douTaskHours;
            decimal  decStandardDeviation;
            int      intRecordsReturned;
            decimal  decLimiter;

            try
            {
                TheWorkStatsDataSet.workstats.Rows.Clear();

                datEndDate = TheDateSearchClass.RemoveTime(datEndDate);

                datStartDate = TheDateSearchClass.SubtractingDays(datEndDate, 900);

                gintCounter        = 0;
                gdecTotal          = 0;
                gdecVariance       = 0;
                gintTaskUpperLimit = 0;

                TheFindLaborHoursByDateRangeDataSet = TheEmployeeProjectAssignmentClass.FindLaborHoursByDateRange(datStartDate, datEndDate);

                intNumberOfRecords = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange.Rows.Count - 1;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    if (TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].TotalHours > 0)
                    {
                        intWorkTaskID = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].WorkTaskID;
                        blnItemFound  = false;

                        if (gintTaskUpperLimit > 0)
                        {
                            for (intTaskCounter = 0; intTaskCounter < gintTaskUpperLimit; intTaskCounter++)
                            {
                                if (intWorkTaskID == TheWorkStatsDataSet.workstats[intTaskCounter].WorkTaskID)
                                {
                                    blnItemFound = true;
                                    TheWorkStatsDataSet.workstats[intTaskCounter].HoursPerTask += TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].TotalHours;
                                    TheWorkStatsDataSet.workstats[intTaskCounter].ItemCounter++;
                                }
                            }
                        }

                        gdecTotal += TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].TotalHours;
                        gintCounter++;

                        if (blnItemFound == false)
                        {
                            WorkStatsDataSet.workstatsRow NewTaskRow = TheWorkStatsDataSet.workstats.NewworkstatsRow();

                            NewTaskRow.HoursPerTask      = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].TotalHours;
                            NewTaskRow.ItemCounter       = 1;
                            NewTaskRow.Limiter           = 0;
                            NewTaskRow.Mean              = 0;
                            NewTaskRow.StandardDeviation = 0;
                            NewTaskRow.Variance          = 0;
                            NewTaskRow.WorkTask          = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].WorkTask;
                            NewTaskRow.WorkTaskID        = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].WorkTaskID;

                            TheWorkStatsDataSet.workstats.Rows.Add(NewTaskRow);
                            gintTaskUpperLimit++;
                        }
                    }
                }

                decVariance = 0;

                for (intTaskCounter = 0; intTaskCounter < gintTaskUpperLimit; intTaskCounter++)
                {
                    intItems      = TheWorkStatsDataSet.workstats[intTaskCounter].ItemCounter;
                    dectotalHours = TheWorkStatsDataSet.workstats[intTaskCounter].HoursPerTask;
                    intWorkTaskID = TheWorkStatsDataSet.workstats[intTaskCounter].WorkTaskID;
                    strWorkTask   = TheWorkStatsDataSet.workstats[intTaskCounter].WorkTask;

                    decMean = dectotalHours / intItems;

                    decMean = Math.Round(decMean, 4);

                    TheWorkStatsDataSet.workstats[intTaskCounter].Mean = decMean;

                    TheFindWorkTaskHoursDataSet = TheWorkTaskClass.FindWorkTaskHours(strWorkTask, datStartDate, datEndDate);

                    intNumberOfRecords = TheFindWorkTaskHoursDataSet.FindWorkTaskHours.Rows.Count - 1;

                    for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                    {
                        if (TheFindWorkTaskHoursDataSet.FindWorkTaskHours[intCounter].TotalHours > 0)
                        {
                            douTaskHours = Convert.ToDouble(TheFindWorkTaskHoursDataSet.FindWorkTaskHours[intCounter].TotalHours - decMean);

                            decVariance += Convert.ToDecimal(Math.Pow(douTaskHours, 2));
                        }
                    }

                    decVariance = decVariance / intItems;

                    decVariance = Math.Round(decVariance, 4);

                    decStandardDeviation = Math.Round(Convert.ToDecimal(Math.Sqrt(Convert.ToDouble(decVariance))), 4);

                    TheWorkStatsDataSet.workstats[intTaskCounter].Variance = decVariance;

                    TheWorkStatsDataSet.workstats[intTaskCounter].StandardDeviation = decStandardDeviation;

                    TheWorkStatsDataSet.workstats[intTaskCounter].Limiter = decMean + (5 * decStandardDeviation);
                }

                gdecMean = gdecTotal / gintCounter;

                gdecMean = Math.Round(gdecMean, 4);

                intNumberOfRecords = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange.Rows.Count - 1;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    if (TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].TotalHours > 0)
                    {
                        douHours = Convert.ToDouble(TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intCounter].TotalHours - gdecMean);

                        gdecVariance += Convert.ToDecimal(Math.Pow(douHours, 2));
                    }
                }

                gdecVariance = gdecVariance / gintCounter;

                gdecStandardDeviation = Convert.ToDecimal(Math.Sqrt(Convert.ToDouble(gdecVariance)));

                gdecStandardDeviation = Math.Round(gdecStandardDeviation, 4);

                gdecLimiter = gdecMean + (gdecStandardDeviation * 5);

                //adding to the table
                intNumberOfRecords = TheWorkStatsDataSet.workstats.Rows.Count - 1;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    intWorkTaskID        = TheWorkStatsDataSet.workstats[intCounter].WorkTaskID;
                    decMean              = TheWorkStatsDataSet.workstats[intCounter].Mean;
                    decVariance          = TheWorkStatsDataSet.workstats[intCounter].Variance;
                    decStandardDeviation = TheWorkStatsDataSet.workstats[intCounter].StandardDeviation;
                    decLimiter           = TheWorkStatsDataSet.workstats[intCounter].Limiter;

                    TheFindWorkTaskStatsByTaskIDDataSet = TheWorkTaskStatsClass.FindWorkTaskStatsByTaskID(intWorkTaskID);

                    intRecordsReturned = TheFindWorkTaskStatsByTaskIDDataSet.FindWorkTaskStatsByWorkTaskID.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        blnFatalError = TheWorkTaskStatsClass.UpdatetWorkTaskStats(intWorkTaskID, decMean, decVariance, decStandardDeviation, decLimiter);

                        if (blnFatalError == true)
                        {
                            throw new Exception();
                        }
                    }
                    if (intRecordsReturned == 0)
                    {
                        blnFatalError = TheWorkTaskStatsClass.InsertWorkTaskStats(intWorkTaskID, decMean, decVariance, decStandardDeviation, decLimiter);

                        if (blnFatalError == true)
                        {
                            throw new Exception();
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Event Log Tracker // Update Work Task Stats Class // Update Work Task Stats Table " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());

                blnFatalError = true;
            }

            return(blnFatalError);
        }
        private void mitGenerateReport_Click(object sender, RoutedEventArgs e)
        {
            //setting local viarables
            string  strValueForValidation;
            string  strErrorMessage    = "";
            bool    blnThereIsAProblem = false;
            bool    blnFatalError      = false;
            int     intLaborCounter;
            int     intLaborNumberOfRecords;
            int     intEmployeeCounter;
            int     intEmployeeNumberOfRecords;
            int     intEmployeeID;
            decimal decHours;
            bool    blnItemFound;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                TheTotalHoursDataSet.totalhours.Rows.Clear();

                strValueForValidation = txtEnterStartDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Start Date is not a Date\n";
                }
                else
                {
                    MainWindow.gdatStartDate = Convert.ToDateTime(strValueForValidation);
                }
                strValueForValidation = txtEnterEndDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The End Date is not a Date\n";
                }
                else
                {
                    MainWindow.gdatEndDate = Convert.ToDateTime(strValueForValidation);
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    PleaseWait.Close();
                    return;
                }
                else
                {
                    blnFatalError = TheDataValidationClass.verifyDateRange(MainWindow.gdatStartDate, MainWindow.gdatEndDate);
                    if (blnFatalError == true)
                    {
                        TheMessagesClass.ErrorMessage("The Start Date is after the End Date");
                        PleaseWait.Close();
                        return;
                    }
                }

                TheFindLaborHoursByDateRangeDataSet = TheEmployeeProjectAssignmentClass.FindLaborHoursByDateRange(MainWindow.gdatStartDate, MainWindow.gdatEndDate);

                intLaborNumberOfRecords    = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange.Rows.Count - 1;
                intEmployeeNumberOfRecords = 0;

                for (intLaborCounter = 0; intLaborCounter <= intLaborNumberOfRecords; intLaborCounter++)
                {
                    intEmployeeID = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intLaborCounter].EmployeeID;
                    decHours      = TheFindLaborHoursByDateRangeDataSet.FindLaborHoursByDateRange[intLaborCounter].TotalHours;
                    blnItemFound  = false;

                    if (intEmployeeNumberOfRecords > 0)
                    {
                        for (intEmployeeCounter = 0; intEmployeeCounter < intEmployeeNumberOfRecords; intEmployeeCounter++)
                        {
                            if (intEmployeeID == TheTotalHoursDataSet.totalhours[intEmployeeCounter].EmployeeID)
                            {
                                blnItemFound = true;
                                TheTotalHoursDataSet.totalhours[intEmployeeCounter].TotalHours += decHours;
                            }
                        }
                    }

                    if (blnItemFound == false)
                    {
                        TheFindEmployeeByEmployeeIDDataSet = TheEmployeeClass.FindEmployeeByEmployeeID(intEmployeeID);

                        TotalHoursDataSet.totalhoursRow NewEmployeeRow = TheTotalHoursDataSet.totalhours.NewtotalhoursRow();

                        NewEmployeeRow.EmployeeID   = intEmployeeID;
                        NewEmployeeRow.EmployeeType = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].EmployeeType;
                        NewEmployeeRow.FirstName    = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].FirstName;
                        NewEmployeeRow.HomeOffice   = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].HomeOffice;
                        NewEmployeeRow.LastName     = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].LastName;
                        NewEmployeeRow.TotalHours   = decHours;

                        TheTotalHoursDataSet.totalhours.Rows.Add(NewEmployeeRow);
                        intEmployeeNumberOfRecords++;
                    }
                }

                TheTotalHoursDataSet.totalhours.DefaultView.Sort = "TotalHours DESC";


                dgrResults.ItemsSource = TheTotalHoursDataSet.totalhours;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Find Labor Hours // Generate Report Menu Item " + Ex.Message);

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

            PleaseWait.Close();
        }