private void Window_Loaded(object sender, RoutedEventArgs e) { //setting up the local variables int intCounter; int intNumberOfRecords; int intProjectID; DateTime datTransactionDate = DateTime.Now; try { datTransactionDate = TheDateSearchClass.RemoveTime(datTransactionDate); datTransactionDate = TheDateSearchClass.SubtractingDays(datTransactionDate, 31); TheFindProjectByAssignedProjectIDDataSet = TheProjectClass.FindProjectByAssignedProjectID("SHOP"); intProjectID = TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID[0].ProjectID; TheFindProjectHoursDataSet = TheEmployeeProjectAssignmentClass.FindProjectHours(intProjectID, datTransactionDate); TheFindProjectStatsDataSet = TheEmployeeProductivityStatsClass.FindProjectStats(intProjectID); intNumberOfRecords = TheFindProjectHoursDataSet.FindProjectHours.Rows.Count - 1; gdecMean = TheFindProjectStatsDataSet.FindProjectStats[0].AveHours; gdecStandDeviation = Convert.ToDecimal(TheFindProjectStatsDataSet.FindProjectStats[0].HoursSTDev); gdecVariance = Convert.ToDecimal(TheFindProjectStatsDataSet.FindProjectStats[0].HoursVariance); gdecTotalHours = Convert.ToDecimal(TheFindProjectStatsDataSet.FindProjectStats[0].TotalHours); gdecMean = Math.Round(gdecMean, 4); txtAverageHours.Text = Convert.ToString(gdecMean); gdecVariance = Math.Round(gdecVariance, 4); gdecStandDeviation = Math.Round(gdecStandDeviation, 4); gdecUpperBound = gdecMean + gdecStandDeviation; txtUpperBound.Text = Convert.ToString(gdecUpperBound); for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++) { if (TheFindProjectHoursDataSet.FindProjectHours[intCounter].TransactionDate > datTransactionDate) { if (TheFindProjectHoursDataSet.FindProjectHours[intCounter].TotalHours > gdecUpperBound) { ShopViolatorDataSet.violatorRow NewViolatorRow = TheShopViolatorDataSet.violator.NewviolatorRow(); NewViolatorRow.FirstName = TheFindProjectHoursDataSet.FindProjectHours[intCounter].FirstName; NewViolatorRow.LastName = TheFindProjectHoursDataSet.FindProjectHours[intCounter].LastName; NewViolatorRow.Hours = TheFindProjectHoursDataSet.FindProjectHours[intCounter].TotalHours; NewViolatorRow.TransactionDate = TheFindProjectHoursDataSet.FindProjectHours[intCounter].TransactionDate; NewViolatorRow.HomeOffice = TheFindProjectHoursDataSet.FindProjectHours[intCounter].HomeOffice; TheShopViolatorDataSet.violator.Rows.Add(NewViolatorRow); } } } dgrResults.ItemsSource = TheShopViolatorDataSet.violator; gdecProjectHours = gdecMean * 5 * 52; txtProjectHours.Text = Convert.ToString(gdecProjectHours); gdecProjectCost = gdecProjectHours * 12; txtProjectedCost.Text = Convert.ToString(gdecProjectCost); } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Shop Hours Analysis // Window Loaded " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }
private void ResetControls() { //setting up the local variables int intCounter; int intNumberOfRecords; int intProjectID; DateTime datTransactionDate = DateTime.Now; DateTime datStartDate = DateTime.Now; decimal decAveragePayRate; try { PleaseWait PleaseWait = new PleaseWait(); PleaseWait.Show(); TheShopViolatorDataSet.violator.Rows.Clear(); datTransactionDate = TheDateSearchClass.RemoveTime(datTransactionDate); datTransactionDate = TheDateSearchClass.SubtractingDays(datTransactionDate, 31); TheFindProjectMatrixByAssignedProjectIDDataSet = TheProjectMatrixClass.FindProjectMatrixByAssignedProjectID("SHOP"); intProjectID = TheFindProjectMatrixByAssignedProjectIDDataSet.FindProjectMatrixByAssignedProjectID[0].ProjectID; datStartDate = TheDateSearchClass.SubtractingDays(datStartDate, 31); TheFindProjectStatsDataSet = TheEmployeeProductivityStatsClass.FindProjectStats(intProjectID); gdecMean = TheFindProjectStatsDataSet.FindProjectStats[0].AveHours; gdecStandDeviation = Convert.ToDecimal(TheFindProjectStatsDataSet.FindProjectStats[0].HoursSTDev); gdecVariance = Convert.ToDecimal(TheFindProjectStatsDataSet.FindProjectStats[0].HoursVariance); gdecTotalHours = Convert.ToDecimal(TheFindProjectStatsDataSet.FindProjectStats[0].TotalHours); decAveragePayRate = TheFindProjectStatsDataSet.FindProjectStats[0].AveragePayRate; gdecMean = Math.Round(gdecMean, 4); txtAverageHours.Text = Convert.ToString(gdecMean); gdecVariance = Math.Round(gdecVariance, 4); gdecStandDeviation = Math.Round(gdecStandDeviation, 4); gdecUpperBound = gdecMean + gdecStandDeviation; txtUpperBound.Text = Convert.ToString(gdecUpperBound); TheFindProjectHoursAboveLimitDataSet = TheEmployeeProjectAssignmentClass.FindProjectHoursAboveLimit(intProjectID, datStartDate, gdecUpperBound); intNumberOfRecords = TheFindProjectHoursAboveLimitDataSet.FindProjectHoursAboveLimit.Rows.Count; if (intNumberOfRecords > 0) { for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { ShopViolatorDataSet.violatorRow NewViolatorRow = TheShopViolatorDataSet.violator.NewviolatorRow(); NewViolatorRow.FirstName = TheFindProjectHoursAboveLimitDataSet.FindProjectHoursAboveLimit[intCounter].FirstName; NewViolatorRow.HomeOffice = TheFindProjectHoursAboveLimitDataSet.FindProjectHoursAboveLimit[intCounter].HomeOffice; NewViolatorRow.Hours = TheFindProjectHoursAboveLimitDataSet.FindProjectHoursAboveLimit[intCounter].TotalHours; NewViolatorRow.LastName = TheFindProjectHoursAboveLimitDataSet.FindProjectHoursAboveLimit[intCounter].LastName; NewViolatorRow.TransactionDate = TheFindProjectHoursAboveLimitDataSet.FindProjectHoursAboveLimit[intCounter].TransactionDate; TheShopViolatorDataSet.violator.Rows.Add(NewViolatorRow); } } dgrResults.ItemsSource = TheShopViolatorDataSet.violator; gdecProjectHours = TheFindProjectStatsDataSet.FindProjectStats[0].TotalHours; txtShopHours.Text = Convert.ToString(gdecProjectHours); gdecProjectCost = gdecProjectHours * decAveragePayRate; gdecProjectCost = Math.Round(gdecProjectCost, 4); txtProjectCost.Text = Convert.ToString(gdecProjectCost); PleaseWait.Close(); } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Shop Hours Analysis // Reset Controls " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }