partial void DeleteWorkPackageStatusReport(WorkPackageStatusReport instance);
partial void UpdateWorkPackageStatusReport(WorkPackageStatusReport instance);
partial void InsertWorkPackageStatusReport(WorkPackageStatusReport instance);
private void detach_WorkPackageStatusReports(WorkPackageStatusReport entity) { this.SendPropertyChanging(); entity.WorkPackage = null; }
/// <summary> /// Saves the report details into the database. /// Tests for validity. /// Checks if it's a new report or an existing report. /// Persists report. /// </summary> /// <param name="sender">The object that generated the event.</param> /// <param name="e">The event.</param> protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { Boolean isNewReport = false; WorkPackageStatusReport wpsr = getExistingReportDetails(); if (wpsr == null) { wpsr = new WorkPackageStatusReport(); wpsr.projId = Convert.ToInt32(ViewState["projId"]); wpsr.wpId = ddlWorkpackages.SelectedValue; wpsr.cutOffDate = (DateTime)(ViewState["cutOffDate"]); isNewReport = true; } wpsr.comments = tbComments.Text; wpsr.workAccomplished = tbWorkAccomplished.Text; wpsr.workPlannedNext = tbWorkPlannedNext.Text; wpsr.problemsEncountered = tbProblemsEncountered.Text; wpsr.problemsAnticipated = tbProblemsAncticipatedNext.Text; if (isNewReport) { ffdb.WorkPackageStatusReports.InsertOnSubmit(wpsr); } try { ffdb.SubmitChanges(); SetResults("The report details were successfully saved.", false, SuccessColour); } catch (Exception ex) { SetResults("The report details could not be saved at this time.", false, FailColour); Trace.Write(ex.Message); return; } GetWorkPackageStatusReport(); } }
/// <summary> /// Populates the GridView. /// Calculates two sets of data for each employee on the selected WorkPackage (the days and the dollars). /// </summary> public void GetWorkPackageStatusReport() { // Store the ACWP for each employee List <KeyValuePair <int, decimal> > acwpForAll = getAcwpForAll(); // Store the ETC for each employee allEmployeeWpETCs = getEtcForAll(); SetResults(String.Empty, false, SuccessColour); // Get the WP's responsible engineer Employee respEng = (Employee) (from re in ffdb.WorkPackageResponsibleEngineers join e in ffdb.Employees on re.responsibleEngineer equals e.empId where (re.projId == Convert.ToInt32(ViewState["projId"])) && re.wpId.Equals(ViewState["wpId"]) select e).FirstOrDefault(); // Get the Project's project manager var projMan = (Employee) (from pm in ffdb.Projects join e in ffdb.Employees on pm.manager equals e.empId where (pm.projId == Convert.ToInt32(ViewState["projId"])) select e).FirstOrDefault(); // Get the data for each employee who's worked on the timesheet at some point var qry = (from tse in ffdb.TimesheetEntries join e in ffdb.Employees on tse.empId equals e.empId where (tse.projId == Convert.ToInt32(ViewState["projId"])) && (tse.wpId.Equals(ViewState["wpId"])) select new { e.firstName, e.lastName, e.empId, ACWP = getAcwpForEmployee(tse.empId, acwpForAll), ETC = getEtcForEmployee(tse.empId, allEmployeeWpETCs) }).Distinct(); if (qry.Count() == 0) { SetResults("No employees are assigned to this workpackage.", false, FailColour); } // Format the data for the Grid View DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Employee", typeof(System.String))); dt.Columns.Add(new DataColumn("ACWP", typeof(System.String))); dt.Columns.Add(new DataColumn("ETC", typeof(System.String))); dt.Columns.Add(new DataColumn("EAC", typeof(System.String))); dt.Columns.Add(new DataColumn("PercentComplete", typeof(System.String))); // Generate rows for each employee foreach (var employee in qry) { // Employee DataRow drEmployee = dt.NewRow(); drEmployee["Employee"] = employee.firstName + " " + employee.lastName + " (" + employee.empId + ")"; dt.Rows.Add(drEmployee); // P-Days DataRow drDays = dt.NewRow(); drDays["Employee"] = "Days:"; drDays["ACWP"] = employee.ACWP; drDays["ETC"] = employee.ETC; drDays["EAC"] = calculateEac(employee.ACWP.ToString(), employee.ETC.ToString(), "{0:0.0}"); drDays["PercentComplete"] = getPercentComplete(employee.ACWP, drDays["EAC"].ToString()); dt.Rows.Add(drDays); // P-Dollars DataRow drDollars = dt.NewRow(); drDollars["Employee"] = "Dollars:"; drDollars["ACWP"] = getAcwpDollars(employee.empId); drDollars["ETC"] = calculatePDollars(employee.ETC.ToString(), getMaxPLvl(employee.empId).ToString()); drDollars["EAC"] = calculateEac(drDollars["ACWP"].ToString(), drDollars["ETC"].ToString(), "{0:C}"); drDollars["PercentComplete"] = getPercentComplete(drDollars["ACWP"].ToString(), drDollars["EAC"].ToString()); dt.Rows.Add(drDollars); } decimal totalAcwpDays = 0; decimal totalEtcDays = 0; decimal totalEacDays = 0; decimal totalPercentCompleteDays = 0; decimal totalAcwpDollars = 0; decimal totalEtcDollars = 0; decimal totalEacDollars = 0; decimal totalPercentCompleteDollars = 0; int temp = gvStatus.Rows.Count; for (int i = 2; i <= dt.Rows.Count;) { String acwp = dt.Rows[i - 1][1].ToString(); String etc = dt.Rows[i - 1][2].ToString(); String eac = dt.Rows[i - 1][3].ToString(); String pc = dt.Rows[i - 1][4].ToString(); if (!(acwp.Equals(String.Empty) || acwp.Equals(UnknownValue))) { totalAcwpDays += Convert.ToDecimal(acwp); } if (!(etc.Equals(String.Empty) || etc.Equals(UnknownValue))) { totalEtcDays += Convert.ToDecimal(etc); } if (!(eac.Equals(String.Empty) || eac.Equals(UnknownValue))) { totalEacDays += Convert.ToDecimal(eac); } if (!(pc.Equals(String.Empty) || pc.Equals(UnknownValue))) { totalPercentCompleteDays += Convert.ToDecimal(stripFormatting(pc)); } acwp = dt.Rows[i][1].ToString(); etc = dt.Rows[i][2].ToString(); eac = dt.Rows[i][3].ToString(); pc = dt.Rows[i][4].ToString(); if (!(acwp.Equals(String.Empty) || acwp.Equals(UnknownValue))) { totalAcwpDollars += Convert.ToDecimal(stripFormatting(acwp)); } if (!(etc.Equals(String.Empty) || etc.Equals(UnknownValue))) { totalEtcDollars += Convert.ToDecimal(stripFormatting(etc)); } if (!(eac.Equals(String.Empty) || eac.Equals(UnknownValue))) { totalEacDollars += Convert.ToDecimal(stripFormatting(eac)); } if (!(pc.Equals(String.Empty) || pc.Equals(UnknownValue))) { totalPercentCompleteDollars += Convert.ToDecimal(stripFormatting(pc)); } i += 3; } if (dt.Rows.Count > 0) { totalPercentCompleteDays = totalPercentCompleteDays / dt.Rows.Count; totalPercentCompleteDollars = totalPercentCompleteDollars / dt.Rows.Count; } else { totalPercentCompleteDays = 0; totalPercentCompleteDollars = 0; } DataRow drTotalHeader = dt.NewRow(); drTotalHeader["Employee"] = "Total"; dt.Rows.Add(drTotalHeader); // P-Days DataRow drTotalDays = dt.NewRow(); drTotalDays["Employee"] = "Days:"; drTotalDays["ACWP"] = String.Format(decimalFormat, totalAcwpDays); drTotalDays["ETC"] = String.Format(decimalFormat, totalEtcDays); drTotalDays["EAC"] = String.Format(decimalFormat, totalEacDays); drTotalDays["PercentComplete"] = String.Format(percentFormat, totalPercentCompleteDays); dt.Rows.Add(drTotalDays); // P-Dollars DataRow drTotalDollars = dt.NewRow(); drTotalDollars["Employee"] = "Dollars:"; drTotalDollars["ACWP"] = String.Format(currencyFormat, totalAcwpDollars); drTotalDollars["ETC"] = String.Format(currencyFormat, totalEtcDollars); drTotalDollars["EAC"] = String.Format(currencyFormat, totalEacDollars); drTotalDollars["PercentComplete"] = String.Format(percentFormat, totalPercentCompleteDollars); dt.Rows.Add(drTotalDollars); // Populate the Grid View with the formatted data gvStatus.DataSource = dt; gvStatus.DataBind(); // Customize the views for (int i = 1; i <= gvStatus.Rows.Count;) { gvStatus.Rows[i - 1].Cells[1].Visible = false; gvStatus.Rows[i - 1].Cells[2].Visible = false; gvStatus.Rows[i - 1].Cells[3].Visible = false; gvStatus.Rows[i - 1].Cells[4].Visible = false; gvStatus.Rows[i - 1].Cells[5].Text = String.Empty; gvStatus.Rows[i - 1].Cells[5].Enabled = false; gvStatus.Rows[i - 1].Cells[0].ColumnSpan = 5; gvStatus.Rows[i + 1].Cells[5].Text = String.Empty; gvStatus.Rows[i + 1].Cells[5].Enabled = false; i += 3; // skip 3 rows } // Populate the Report Details lblProject.Text = ViewState["Project"].ToString(); lblWp.Text = ViewState["WorkPackage"].ToString(); lblRe.Text = respEng.firstName + " " + respEng.lastName + " (" + respEng.empId + ")"; lblPm.Text = projMan.firstName + " " + projMan.lastName + " (" + projMan.empId + ")"; lblReportPeriod.Text = ((DateTime)ViewState["cutOffDate"]).ToString("yyyy/MM/dd"); lblPmBac.Text = String.Format("{0:C}", this.getPMBudget()); // Get most recent RE budget for this workpackage. lblReBac.Text = getResponsibleEngineerBudget(); // Get the WorkPackageStatusReport details WorkPackageStatusReport wpsr = getExistingReportDetails(); // Create empty WorkPackageStatusReport if (wpsr == null) { tbComments.Text = ""; tbWorkAccomplished.Text = ""; tbWorkPlannedNext.Text = ""; tbProblemsEncountered.Text = ""; tbProblemsAncticipatedNext.Text = ""; SetResults("This report does not exist. Creating a blank report for you.\n", true, SuccessColour); } // Populate WorkPackageStatusReport details else { tbComments.Text = wpsr.comments; tbWorkAccomplished.Text = wpsr.workAccomplished; tbWorkPlannedNext.Text = wpsr.workPlannedNext; tbProblemsEncountered.Text = wpsr.problemsEncountered; tbProblemsAncticipatedNext.Text = wpsr.problemsAnticipated; } // Show the report divReportData.Visible = true; btnSave.Visible = true; }