protected void grdProjectTime_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("generalData"); if (Page.IsValid) { Page.Validate("editValidData"); if (Page.IsValid) { Page.Validate("editData"); if (Page.IsValid) { int projectTimeId = (int)e.Keys["ProjectTimeID"]; int employeeId = Int32.Parse(hdfEmployeeID.Value); int companiesId = int.Parse(ddlClient.SelectedValue); int projectId = int.Parse(ddlProject.SelectedValue); DateTime date_ = tkrdpStartDate.SelectedDate.Value; string workingDetails = hdfWorkingDetails.Value; if (projectId == 35 || projectId == 39 || projectId == 716) { Page.Validate("specialData"); } if (Page.IsValid) { if (projectId == 35 || projectId == 39 || projectId == 716) { date_ = Convert.ToDateTime(((HiddenField)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("hdfDateEdit")).Value); workingDetails = ddlWorkingDetails.SelectedValue; } Int64? mealsCountry = null; if (ddlMealsCountry.SelectedValue != "-1") mealsCountry = Int64.Parse(ddlMealsCountry.SelectedValue); string startTime = ""; string startHoursEdit = ((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlStartTimeHourEdit")).SelectedValue.Trim(); string startMinutesEdit = ((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlStartTimeMinuteEdit")).SelectedValue.Trim(); if ((startHoursEdit != "") && (startMinutesEdit != "") ) { startTime = startHoursEdit + ":" + startMinutesEdit; } string endTime = ""; string endHoursEdit = ((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlEndTimeHourEdit")).SelectedValue.Trim(); string endMinutesEdit = ((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlEndTimeMinuteEdit")).SelectedValue.Trim(); if ((endHoursEdit != "") && (endMinutesEdit != "")) { endTime = endHoursEdit + ":" + endMinutesEdit; } decimal? offset = 0; if (((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlLunchEdit")).SelectedValue != "0") offset = decimal.Round(Decimal.Parse(((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlLunchEdit")).SelectedValue), 2); double? offsetFinal = null; if (offset.HasValue) offsetFinal = double.Parse(((decimal)offset).ToString()); bool isMealsAllowance = false;// ((CheckBox)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ckbxMealsAllowanceEdit")).Checked; int? unitId = null; if (((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlUnitEdit")).SelectedValue != "-1") unitId = Int32.Parse(((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlUnitEdit")).SelectedValue); int? towedUnitId = null; if (((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlTowedEdit")).SelectedValue != "-1") towedUnitId = Int32.Parse(((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlTowedEdit")).SelectedValue); string comments = ((TextBox)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("tbxCommentsEdit")).Text; string workFunctionConcat = ((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlTypeOfWorkFunctionEdit")).SelectedValue; ProjectGateway projectGateway = new ProjectGateway(new DataSet()); projectGateway.LoadByProjectId(projectId); bool fairWage = projectGateway.GetFairWageApplies(projectId); string work_ = ""; string function_ = ""; if (workFunctionConcat != "(Select)" && workFunctionConcat != "") { string[] workFunction = workFunctionConcat.ToString().Trim().Split('.'); work_ = workFunction[0].Trim(); function_ = workFunction[1].Trim(); } CountryGateway countryGateway = new CountryGateway(new DataSet()); countryGateway.LoadByCountryId(projectGateway.GetCountryID(projectId)); string location = countryGateway.GetName(projectGateway.GetCountryID(projectId)); string mealsAllowanceType = ""; if (isMealsAllowance) mealsAllowanceType = "Full Day"; decimal mealsAllowance = MealsAllowance.GetMealsAllowance(mealsCountry, isMealsAllowance, "Full Day"); string jobClassType = ((DropDownList)grdProjectTime.Rows[e.RowIndex].Cells[1].FindControl("ddlJobClassTypeEdit")).SelectedValue; // Update data ProjectTimeTemp model = new ProjectTimeTemp(projectTimeTDS); model.Update(projectTimeId, companiesId, projectId, date_, startTime, endTime, offsetFinal, workingDetails, location, mealsCountry, mealsAllowanceType, isMealsAllowance, mealsAllowance, unitId, towedUnitId, comments, work_, function_, workFunctionConcat, fairWage, jobClassType); // Store dataset Session.Remove("projectTimeTempNewDummy"); Session["projectTimeTDS"] = projectTimeTDS; Session["projectTimeTemp"] = projectTimeTDS.LFS_PROJECT_TIME_TEMP; } else { e.Cancel = true; } } else { e.Cancel = true; } } else { e.Cancel = true; } } else { e.Cancel = true; } }