partial void UpdateEmployeeWorkPackageETC(EmployeeWorkPackageETC instance);
 partial void DeleteEmployeeWorkPackageETC(EmployeeWorkPackageETC instance);
 partial void InsertEmployeeWorkPackageETC(EmployeeWorkPackageETC instance);
	private void detach_EmployeeWorkPackageETCs(EmployeeWorkPackageETC entity)
	{
		this.SendPropertyChanging();
		entity.WorkPackage = null;
	}
	private void attach_EmployeeWorkPackageETCs(EmployeeWorkPackageETC entity)
	{
		this.SendPropertyChanging();
		entity.Employee = this;
	}
    protected void gvStatus_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        // Get the row that's changing.
        GridViewRow row = gvStatus.Rows[e.RowIndex];
        GridViewRow empRow = gvStatus.Rows[e.RowIndex - 1];
        int empId = extractEmpId(((Label)empRow.Cells[0].Controls[1]).Text);
        String strEtc = UnknownValue;
        String strEac = UnknownValue;
        String strAcwp = ((Label)row.Cells[1].Controls[1]).Text;
        decimal acwp = 0;
        decimal etc = 0;
        decimal eac = 0;
        String format = "{0:0.0}";
        String result = "";

        // Get the new values.
        if (e.NewValues["ETC"] != null) {
            if (!(e.NewValues["ETC"].Equals(String.Empty))) {
                strEtc = e.NewValues["ETC"].ToString();
            }
        }

        if (e.NewValues["EAC"] != null) {
            if (!(e.NewValues["EAC"].Equals(String.Empty))) {
                strEac = e.NewValues["EAC"].ToString();
            }
        }

        if (!Regex.IsMatch(strEac, "^(^[U]{1}[n]{1}[k]{1}[n]{1}[o]{1}[w]{1}[n]{1}$)|(^[0-9]*([.]+[0-9]*)*)$")) {
            SetResults("* EAC can only contain a dollar sign, comma, period, positive numbers, or 'Unknown'.", false, FailColour);
            return;
        }

        if (!Regex.IsMatch(strEtc, "^(^[U]{1}[n]{1}[k]{1}[n]{1}[o]{1}[w]{1}[n]{1}$)|(^[0-9]*([.]+[0-9]*)*)$")) {
            SetResults("* ETC can only contain a dollar sign, comma, period, positive numbers, or 'Unknown'.", false, FailColour);
            return;
        }

        if (!(strEac.Equals(UnknownValue) && strEtc.Equals(UnknownValue))) {
            SetResults("* At least one value must be 'Unknown' or blank. Please change one value to 'Unknown' or blank.", false, FailColour);
            return;
        }

        // Check for existing empWPEtc for the cut off date.
        EmployeeWorkPackageETC empWpEtc = (from ewetc in ffdb.EmployeeWorkPackageETCs
                                           where ewetc.empId == empId
                                                && ewetc.dateUpdated.Equals(Convert.ToDateTime(ViewState["cutOffDate"]))
                                           select ewetc).FirstOrDefault();

        if (!((result = calculateEac(strAcwp, strEtc, format)).Equals(UnknownValue))) {
            eac = Convert.ToDecimal(result);
            strAcwp = this.stripFormatting(strAcwp);
            acwp = Convert.ToDecimal(strAcwp);
            etc = eac - acwp;
        } else if (!((result = calculateEtc(strAcwp, strEac, format)).Equals(UnknownValue))) {
            etc = Convert.ToDecimal(result);
            strAcwp = this.stripFormatting(strAcwp);
            acwp = Convert.ToDecimal(strAcwp);
            eac = etc + acwp;
            if (eac < acwp) {
                SetResults("* The EAC '" + strEac + "' is less than the ACWP. Please use a higher EAC or click cancel.", false, FailColour);
                return;
            }
            if (eac == 0) {
                SetResults("* The EAC must be greater than 0. Please use a different EAC or click cancel.", false, FailColour);
                return;
            }
        } else {
            if (empWpEtc != null) {
                SetResults("* Cannot set both existing estimates to 'Unknown' or blank values. Please give at least 1 value.", false, FailColour);
                return;
            }
            // Error, exit method and redraw grid view normally
            gvStatus.EditIndex = -1;
            e.Cancel = true;
            GetWorkPackageStatusReport();
            SetResults("* An error has occured, we've exited edit mode.", false, FailColour);
            return;
        }

        // If ETC exists, update it
        if (empWpEtc != null) {
            empWpEtc.ETC_days = etc;
        }
        else {
            // If ETC doesn't exist, create one
            empWpEtc = new EmployeeWorkPackageETC();

            empWpEtc.ETC_days = etc;
            empWpEtc.empId = empId;
            empWpEtc.projId = Convert.ToInt32(ViewState["projId"]);
            empWpEtc.wpId = (String)ViewState["wpId"];

            // If the current date is earlier than the cut off date, use the current date
            // Otherwise, use the cut-off date
            if (DateTime.Now <= Convert.ToDateTime(ViewState["cutOffDate"])) {
                empWpEtc.dateUpdated = DateTime.Now;
            } else {
                empWpEtc.dateUpdated = Convert.ToDateTime(ViewState["cutOffDate"]);
            }

            ffdb.EmployeeWorkPackageETCs.InsertOnSubmit(empWpEtc);
        }

        // Persist the changes, exit edit mode, redraw the grid
        ffdb.SubmitChanges();
        gvStatus.EditIndex = -1;
        e.Cancel = true;
        GetWorkPackageStatusReport();
        SetResults("The report updated successfully.", false, SuccessColour);
    }
    protected void gvStatus_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        // Get the row that's changing.
        GridViewRow row     = gvStatus.Rows[e.RowIndex];
        GridViewRow empRow  = gvStatus.Rows[e.RowIndex - 1];
        int         empId   = extractEmpId(((Label)empRow.Cells[0].Controls[1]).Text);
        String      strEtc  = UnknownValue;
        String      strEac  = UnknownValue;
        String      strAcwp = ((Label)row.Cells[1].Controls[1]).Text;
        decimal     acwp    = 0;
        decimal     etc     = 0;
        decimal     eac     = 0;
        String      format  = "{0:0.0}";
        String      result  = "";

        // Get the new values.
        if (e.NewValues["ETC"] != null)
        {
            if (!(e.NewValues["ETC"].Equals(String.Empty)))
            {
                strEtc = e.NewValues["ETC"].ToString();
            }
        }

        if (e.NewValues["EAC"] != null)
        {
            if (!(e.NewValues["EAC"].Equals(String.Empty)))
            {
                strEac = e.NewValues["EAC"].ToString();
            }
        }

        if (!Regex.IsMatch(strEac, "^(^[U]{1}[n]{1}[k]{1}[n]{1}[o]{1}[w]{1}[n]{1}$)|(^[0-9]*([.]+[0-9]*)*)$"))
        {
            SetResults("* EAC can only contain a dollar sign, comma, period, positive numbers, or 'Unknown'.", false, FailColour);
            return;
        }

        if (!Regex.IsMatch(strEtc, "^(^[U]{1}[n]{1}[k]{1}[n]{1}[o]{1}[w]{1}[n]{1}$)|(^[0-9]*([.]+[0-9]*)*)$"))
        {
            SetResults("* ETC can only contain a dollar sign, comma, period, positive numbers, or 'Unknown'.", false, FailColour);
            return;
        }

        if (!(strEac.Equals(UnknownValue) && strEtc.Equals(UnknownValue)))
        {
            SetResults("* At least one value must be 'Unknown' or blank. Please change one value to 'Unknown' or blank.", false, FailColour);
            return;
        }

        // Check for existing empWPEtc for the cut off date.
        EmployeeWorkPackageETC empWpEtc = (from ewetc in ffdb.EmployeeWorkPackageETCs
                                           where ewetc.empId == empId &&
                                           ewetc.dateUpdated.Equals(Convert.ToDateTime(ViewState["cutOffDate"]))
                                           select ewetc).FirstOrDefault();

        if (!((result = calculateEac(strAcwp, strEtc, format)).Equals(UnknownValue)))
        {
            eac     = Convert.ToDecimal(result);
            strAcwp = this.stripFormatting(strAcwp);
            acwp    = Convert.ToDecimal(strAcwp);
            etc     = eac - acwp;
        }
        else if (!((result = calculateEtc(strAcwp, strEac, format)).Equals(UnknownValue)))
        {
            etc     = Convert.ToDecimal(result);
            strAcwp = this.stripFormatting(strAcwp);
            acwp    = Convert.ToDecimal(strAcwp);
            eac     = etc + acwp;
            if (eac < acwp)
            {
                SetResults("* The EAC '" + strEac + "' is less than the ACWP. Please use a higher EAC or click cancel.", false, FailColour);
                return;
            }
            if (eac == 0)
            {
                SetResults("* The EAC must be greater than 0. Please use a different EAC or click cancel.", false, FailColour);
                return;
            }
        }
        else
        {
            if (empWpEtc != null)
            {
                SetResults("* Cannot set both existing estimates to 'Unknown' or blank values. Please give at least 1 value.", false, FailColour);
                return;
            }
            // Error, exit method and redraw grid view normally
            gvStatus.EditIndex = -1;
            e.Cancel           = true;
            GetWorkPackageStatusReport();
            SetResults("* An error has occured, we've exited edit mode.", false, FailColour);
            return;
        }

        // If ETC exists, update it
        if (empWpEtc != null)
        {
            empWpEtc.ETC_days = etc;
        }
        else
        {
            // If ETC doesn't exist, create one
            empWpEtc = new EmployeeWorkPackageETC();

            empWpEtc.ETC_days = etc;
            empWpEtc.empId    = empId;
            empWpEtc.projId   = Convert.ToInt32(ViewState["projId"]);
            empWpEtc.wpId     = (String)ViewState["wpId"];

            // If the current date is earlier than the cut off date, use the current date
            // Otherwise, use the cut-off date
            if (DateTime.Now <= Convert.ToDateTime(ViewState["cutOffDate"]))
            {
                empWpEtc.dateUpdated = DateTime.Now;
            }
            else
            {
                empWpEtc.dateUpdated = Convert.ToDateTime(ViewState["cutOffDate"]);
            }

            ffdb.EmployeeWorkPackageETCs.InsertOnSubmit(empWpEtc);
        }

        // Persist the changes, exit edit mode, redraw the grid
        ffdb.SubmitChanges();
        gvStatus.EditIndex = -1;
        e.Cancel           = true;
        GetWorkPackageStatusReport();
        SetResults("The report updated successfully.", false, SuccessColour);
    }