/// <summary> /// LoadForDropDownListByLoginIdAndAddItem /// </summary> /// <param name="loginId"></param> /// <param name="teamProjectTimeId"></param> /// <param name="templateName"></param> /// <returns></returns> public DataSet LoadForDropDownListByLoginIdAndAddItem(int loginId, int teamProjectTimeId, string templateName) { // Create structure DestroyTableStructure(); CreateTableStructureForDropDownList(); // Insert extra template InsertForDropDownList(teamProjectTimeId, templateName); // Load templates TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(Data); teamProjectTime2Gateway.ClearBeforeFill = false; teamProjectTime2Gateway.LoadForDropDownListByLoginId(loginId); teamProjectTime2Gateway.ClearBeforeFill = true; // Return DataSet return Data; }
/// <summary> /// Update /// </summary> /// <param name="teamProjectTimeId">teamProjectTimeId</param> /// <param name="teamProjectTimeIdForReplace">teamProjectTimeIdForReplace</param> /// <param name="teamProjectTime2TDSToSave">teamProjectTime2TDSToSave</param> public void Update(int teamProjectTimeId, int teamProjectTimeIdForReplace, TeamProjectTime2TDS teamProjectTime2TDSToSave) { // Update existing row TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIMERow masterRow = GetRow(teamProjectTimeId); int companiesId = masterRow.CompaniesID; int projectId = masterRow.ProjectID; DateTime date_ = masterRow.Date_; DateTime? startTime = null; if (!masterRow.IsNull("StartTime")) startTime = masterRow.StartTime; DateTime? endTime = null; if (!masterRow.IsNull("EndTime")) endTime = masterRow.EndTime; double? offset = null; if (!masterRow.IsNull("Offset")) offset = masterRow.Offset; string workingDetails = ""; if (!masterRow.IsNull("WorkingDetails")) workingDetails = masterRow.WorkingDetails; string location = ""; if (!masterRow.IsNull("Location")) location = masterRow.Location; Int64? mealsCountry = null; if (!masterRow.IsNull("MealsCountry")) mealsCountry = masterRow.MealsCountry; String mealsAllowanceType = ""; if (!masterRow.IsNull("MealsAllowanceType")) mealsAllowanceType = masterRow.MealsAllowanceType; decimal mealsAllowance = masterRow.MealsAllowance; int? unitId = null; if (!masterRow.IsNull("UnitID")) unitId = masterRow.UnitID; int? towedUnitId = null; if (!masterRow.IsNull("TowedUnitID")) towedUnitId = masterRow.TowedUnitID; string comments = ""; if (!masterRow.IsNull("Comments")) comments = masterRow.Comments; string type = "Template"; string state = "Done"; int loginId = masterRow.LoginID; bool deleted = false; string work_ = masterRow.Work_; string function_ = masterRow.Function_; bool fairWage = masterRow.FairWage; // ... Load existing row TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDSToSave); teamProjectTime2Gateway.LoadByTeamProjectTimeId(teamProjectTimeIdForReplace); // ... Replace existing row TeamProjectTime2 teamProjectTime2ToSave = new TeamProjectTime2(teamProjectTime2TDSToSave); teamProjectTime2ToSave.Update(teamProjectTimeIdForReplace, teamProjectTime2Gateway.GetTemplateName(teamProjectTimeIdForReplace), companiesId, projectId, date_, startTime, endTime, offset, workingDetails, location, mealsCountry, mealsAllowanceType, mealsAllowance, unitId, towedUnitId, comments, type, state, loginId, deleted, work_, function_, fairWage); // Update or delete detail rows TeamProjectTime2Detail teamProjectTime2Detail = new TeamProjectTime2Detail(Data); teamProjectTime2Detail.Update(teamProjectTimeId, teamProjectTimeIdForReplace, teamProjectTime2TDSToSave); }
protected void cvEndSaveNewExist_ServerValidate(object source, ServerValidateEventArgs args) { if (cbxEndSave.Checked && rbtnEndSaveNew.Checked && (tbxEndSaveNew.Text.Trim() != "")) { TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(new DataSet()); if (teamProjectTime2Gateway.IsTemplateNameInUseByTemplateNameLoginId(args.Value, Convert.ToInt32(Session["loginID"]))) { args.IsValid = false; } else { args.IsValid = true; } } }
private void UpdateDatabaseForTemplate() { try { TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDSToSave); teamProjectTime2Gateway.UpdateForTemplate(); teamProjectTime2TDS.AcceptChanges(); teamProjectTime2TDSToSave.AcceptChanges(); // Store dataset Session["teamProjectTime2TDS"] = teamProjectTime2TDS; template = teamProjectTime2TDS.Template; Session["template"] = teamProjectTime2TDS.Template; teamProjectTimeDetailTemp = teamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAIL_TEMP; Session["teamProjectTimeDetailTemp"] = teamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAIL_TEMP; ; } catch (Exception ex) { string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
private void UpdateDatabase() { try { TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDSToSave); teamProjectTime2Gateway.Update(projectTime2TDS); teamProjectTime2TDSToSave.AcceptChanges(); teamProjectTime2TDS.AcceptChanges(); projectTime2TDS.AcceptChanges(); Session["teamProjectTime2TDS"] = teamProjectTime2TDS; } catch (Exception ex) { string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } DB.Open(); DB.BeginTransaction(); try { if (ddlTypeOfWork.SelectedValue == "MH Rehab") { int companyId = Int32.Parse(hdfCompanyId.Value); // Get ids & location int projectId = Int32.Parse(ddlProject.SelectedValue); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); Int64 countryId = projectGateway.GetCountryID(projectId); Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = (Int64)projectGateway.GetProvinceID(projectId); Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = (Int64)projectGateway.GetCountyID(projectId); Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = (Int64)projectGateway.GetCityID(projectId); manholeRehabilitationTDS = new ManholeRehabilitationTDS(); ManholeRehabilitationWorkDetails manholeRehabilitationWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS); ManholeRehabilitationWorkDetailsGateway manholeRehabilitationWorkDetailsGateway = new ManholeRehabilitationWorkDetailsGateway(manholeRehabilitationTDS); switch (ddlFunction.SelectedValue) { case "Prep": foreach (GridViewRow row in grdManholesRehabPrep.Rows) { bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked; DateTime? prepDate = Convert.ToDateTime(((Label)row.FindControl("lblPrepDate")).Text); if (selected) { int assetId = Convert.ToInt32(grdManholesRehabPrep.DataKeys[row.RowIndex].Values["AssetID"].ToString()); int workId = 0; workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Manhole Rehabilitation", companyId); manholeRehabilitationWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value)); if (manholeRehabilitationWorkDetailsGateway.Table.Rows.Count > 0) { int? batchId = manholeRehabilitationWorkDetailsGateway.GetBatchID(workId); manholeRehabilitationWorkDetails.Update(workId, prepDate, manholeRehabilitationWorkDetailsGateway.GetSprayedDate(workId), batchId, manholeRehabilitationWorkDetailsGateway.GetDate(workId).Value, companyId); } else { manholeRehabilitationWorkDetails.Update(workId, prepDate, null, null, DateTime.Now, companyId); } manholeRehabilitationWorkDetails.Save2(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, true); } } break; case "Spray": foreach (GridViewRow row in grdManholesRehabSpray.Rows) { bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked; DateTime? sprayDate = Convert.ToDateTime(((Label)row.FindControl("lblSprayDate")).Text); if (selected) { int assetId = Convert.ToInt32(grdManholesRehabSpray.DataKeys[row.RowIndex].Values["AssetID"].ToString()); int workId = 0; workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Manhole Rehabilitation", companyId); manholeRehabilitationWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value)); if (manholeRehabilitationWorkDetailsGateway.Table.Rows.Count > 0) { int? batchId = manholeRehabilitationWorkDetailsGateway.GetBatchID(workId); manholeRehabilitationWorkDetails.Update(workId, manholeRehabilitationWorkDetailsGateway.GetPreppedDate(workId), sprayDate, batchId, manholeRehabilitationWorkDetailsGateway.GetDate(workId).Value, companyId); } else { manholeRehabilitationWorkDetails.Update(workId, null, sprayDate, null, DateTime.Now, companyId); } manholeRehabilitationWorkDetails.Save2(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, true); } } break; } DB.CommitTransaction(); // Store datasets manholeRehabilitationTDS.AcceptChanges(); } else { if (ddlTypeOfWork.SelectedValue == "Full Length") { fullLengthLiningTDS = new FullLengthLiningTDS(); AssetSewerSectionGateway aass = new AssetSewerSectionGateway(); FullLengthLiningWorkDetails fullLengthLiningWorkDetails = new FullLengthLiningWorkDetails(fullLengthLiningTDS); FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(fullLengthLiningTDS); int assetId = 0; int workId = 0; // Get ids & location int projectId = Int32.Parse(ddlProject.SelectedValue); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); Int64 countryId = projectGateway.GetCountryID(projectId); Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = (Int64)projectGateway.GetProvinceID(projectId); Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = (Int64)projectGateway.GetCountyID(projectId); Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = (Int64)projectGateway.GetCityID(projectId); int companyId = Int32.Parse(hdfCompanyId.Value); switch (ddlFunction.SelectedValue) { case "Install": foreach (GridViewRow row in grdSectionsInstall.Rows) { bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked; DateTime? installDate = Convert.ToDateTime(((Label)row.FindControl("lblInstallDate")).Text); if (selected) { if (installDate != tkrdpDate_.SelectedDate.Value) { installDate = tkrdpDate_.SelectedDate.Value; } string sectionId = grdSectionsInstall.DataKeys[row.RowIndex].Values["SectionID"].ToString(); aass.LoadBySectionId(sectionId, companyId); assetId = aass.GetAssetID(sectionId); workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId); fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value)); fullLengthLiningWorkDetails.Update(workId, fullLengthLiningWorkDetailsGateway.GetP1Date(workId), fullLengthLiningWorkDetailsGateway.GetP1Completed(workId), installDate, fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId)); fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false); } } break; case "Prep & Measure": foreach (GridViewRow row in grdSections.Rows) { bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked; bool completed = ((CheckBox)row.FindControl("cbxCompleted")).Checked; DateTime? prepDate = Convert.ToDateTime(((Label)row.FindControl("lblPrepDate")).Text); if (selected) { if (completed) { if (prepDate != tkrdpDate_.SelectedDate.Value) { prepDate = tkrdpDate_.SelectedDate.Value; } } else { prepDate = null; } string sectionId = grdSections.DataKeys[row.RowIndex].Values["SectionID"].ToString(); aass.LoadBySectionId(sectionId, companyId); assetId = aass.GetAssetID(sectionId); workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId); fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value)); fullLengthLiningWorkDetails.Update(workId, prepDate, completed, fullLengthLiningWorkDetailsGateway.GetInstallDate(workId), fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId)); fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false); } } break; case "Reinstate & Post Video": FullLengthLiningLateralDetails fullLengthLiningLateralDetails = new FullLengthLiningLateralDetails(fullLengthLiningTDS); FullLengthLiningLateralDetailsGateway fullLengthLiningLateralDetailsGateway = new FullLengthLiningLateralDetailsGateway(fullLengthLiningTDS); foreach (GridViewRow row in grdSectionsReinstatePostVideo.Rows) { bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked; bool completed = ((CheckBox)row.FindControl("cbxCompleted")).Checked; DateTime? postVideo = Convert.ToDateTime(((Label)row.FindControl("lblPostVideo")).Text); string sectionId = grdSectionsReinstatePostVideo.DataKeys[row.RowIndex].Values["SectionID"].ToString(); aass.LoadBySectionId(sectionId, companyId); assetId = aass.GetAssetID(sectionId); workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId); if (selected) { if (completed) { if (postVideo != tkrdpDate_.SelectedDate.Value) { postVideo = tkrdpDate_.SelectedDate.Value; } } else { postVideo = null; } fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value)); fullLengthLiningWorkDetails.Update(workId, fullLengthLiningWorkDetailsGateway.GetP1Date(workId), fullLengthLiningWorkDetailsGateway.GetP1Completed(workId), fullLengthLiningWorkDetailsGateway.GetInstallDate(workId), postVideo); fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false); } } foreach (GridViewRow row in grdLaterals.Rows) { string sectionId = grdLaterals.DataKeys[row.RowIndex].Values["SectionID"].ToString(); int assetIdLateral = Convert.ToInt32(((Label)row.FindControl("lblAssetIDLateral")).Text); bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked; DateTime? opened = null; if (((CheckBox)row.FindControl("cbxOpened")).Checked) opened = tkrdpDate_.SelectedDate; DateTime? brushed = null; if (((CheckBox)row.FindControl("cbxBrushed")).Checked) brushed = tkrdpDate_.SelectedDate; if (selected) { aass.LoadBySectionId(sectionId, companyId); assetId = aass.GetAssetID(sectionId); workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId); fullLengthLiningLateralDetails.SaveFll(workId, assetIdLateral, companyId, opened, brushed); } } break; } DB.CommitTransaction(); // Store datasets fullLengthLiningTDS.AcceptChanges(); } } } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
// //////////////////////////////////////////////////////////////////////// // STEP3 - DATA - METHODS // private void StepDataIn() { // Set instruction mWizard2 master = (mWizard2)this.Master; master.WizardInstruction = "Please define global data, it will be applied to your team members on the next step."; // Wizard type & step from check if ((hdfNewOrTemplate.Value == "New") && ((string)ViewState["StepFrom"] != "Employees")) { // Prepare initial data ddlClient.Enabled = true; ddlProject.Enabled = true; ProjectTimeWorkList projectTimeWorkList = new ProjectTimeWorkList(new DataSet()); projectTimeWorkList.LoadAndAddItem("(Select a Type)"); ddlTypeOfWork.DataSource = projectTimeWorkList.Table; ddlTypeOfWork.DataValueField = "Work_"; ddlTypeOfWork.DataTextField = "Work_"; ddlTypeOfWork.DataBind(); ddlTypeOfWork.SelectedIndex = 0; ProjectTimeWorkFunctionList projectTimeWorkFunctionList = new ProjectTimeWorkFunctionList(new DataSet()); projectTimeWorkFunctionList.LoadActiveForAddAndAddItem("(Select a Function)", "-1"); ddlFunction.DataSource = projectTimeWorkFunctionList.Table; ddlFunction.DataValueField = "Function_"; ddlFunction.DataTextField = "Function_"; ddlFunction.DataBind(); ddlFunction.SelectedIndex = 0; } else { TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDS); TeamProjectTime2DetailTemp teamProjectTime2DetailTemp = new TeamProjectTime2DetailTemp(teamProjectTime2TDS); // Prepare initial data if ((string)ViewState["StepFrom"] == "Template") { ViewState["teamProjectTimeId"] = Int32.Parse(hdfSelectedIdTemplate.Value); // ... for TeamProjectTime teamProjectTime2Gateway.LoadByTeamProjectTimeId((int)ViewState["teamProjectTimeId"]); // ... for TeamProjectTimeDetailTemp teamProjectTime2DetailTemp.LoadAllByTeamProjectTimeId((int)ViewState["teamProjectTimeId"]); } // ... for Client string companiesId = teamProjectTime2Gateway.GetCompaniesId((int)ViewState["teamProjectTimeId"]).ToString(); int companyId = Int32.Parse(hdfCompanyId.Value); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(Int32.Parse(companiesId), companyId); // ... If Company is active bool deleted = companiesGateway.GetDeleted(Int32.Parse(companiesId)); if (deleted) { ddlClient.SelectedIndex = -1; } else { ddlClient.SelectedValue = companiesId; } if (ddlClient.SelectedValue.Length == 0) { odsClient.DataBind(); ddlClient.DataSourceID = "odsClient"; ddlClient.DataValueField = "COMPANIES_ID"; ddlClient.DataTextField = "Name"; ddlClient.DataBind(); if (deleted) { ddlClient.SelectedIndex = -1; } else { ddlClient.SelectedValue = companiesId; } } if (!deleted) { // ... for project odsProjectsInternalProjectsBallparkProjects.SelectParameters.RemoveAt(2); odsProjectsInternalProjectsBallparkProjects.SelectParameters.Add("ClientId", ddlClient.SelectedValue); odsProjectsInternalProjectsBallparkProjects.Select(); odsProjectsInternalProjectsBallparkProjects.DataBind(); ddlProject.DataSourceID = "odsProjectsInternalProjectsBallparkProjects"; ddlProject.DataValueField = "ProjectID"; ddlProject.DataTextField = "NAME"; ddlProject.DataBind(); try { ddlProject.SelectedValue = teamProjectTime2Gateway.GetProjectId((int)ViewState["teamProjectTimeId"]).ToString(); } catch { ddlProject.SelectedIndex = -1; } } else { ddlProject.SelectedIndex = -1; } // ... for Date if ((string)ViewState["StepFrom"] == "Employees") { tkrdpDate_.SelectedDate = teamProjectTime2Gateway.GetDate_((int)ViewState["teamProjectTimeId"]); } // ... for Type of work ProjectTimeWorkList projectTimeWorkList = new ProjectTimeWorkList(new DataSet()); projectTimeWorkList.LoadAndAddItem("(Select a Type)"); ddlTypeOfWork.DataSource = projectTimeWorkList.Table; ddlTypeOfWork.DataValueField = "Work_"; ddlTypeOfWork.DataTextField = "Work_"; ddlTypeOfWork.DataBind(); if (teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]).ToString() == "") { ddlTypeOfWork.SelectedValue = "(Select a Type)"; } else { ddlTypeOfWork.SelectedValue = (string)teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]); } // ... for function ProjectTimeWorkFunctionList projectTimeWorkFunctionList = new ProjectTimeWorkFunctionList(new DataSet()); if (teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]).ToString() == "") { // ... If there is no type of Work, no function should be loaded projectTimeWorkFunctionList.LoadActiveForAddAndAddItem("(Select a Function)", "-1"); } else { projectTimeWorkFunctionList.LoadActiveForAddAndAddItem("(Select a Function)", teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"])); } ddlFunction.DataSource = projectTimeWorkFunctionList.Table; ddlFunction.DataValueField = "Function_"; ddlFunction.DataTextField = "Function_"; ddlFunction.DataBind(); if (teamProjectTime2Gateway.GetWork((int)ViewState["teamProjectTimeId"]).ToString() == "") { ddlFunction.SelectedValue = "(Select a Function)"; } else { ddlFunction.SelectedValue = (string)teamProjectTime2Gateway.GetFunction((int)ViewState["teamProjectTimeId"]); } // ... for working details if (!deleted) { tbxWorkingDetails.Text = teamProjectTime2Gateway.GetWorkingDetails((int)ViewState["teamProjectTimeId"]); } else { tbxWorkingDetails.Text = ""; } // ... for start time if (teamProjectTime2Gateway.GetStartTime((int)ViewState["teamProjectTimeId"]).HasValue) { string startTime = ((DateTime)teamProjectTime2Gateway.GetStartTime((int)ViewState["teamProjectTimeId"])).ToString("H:mm"); string[] hoursMin1 = startTime.Split(':'); ddlStartTimeHour.SelectedValue = hoursMin1[0].Trim(); ddlStartTimeMinute.SelectedValue = hoursMin1[1].Trim(); } // ... for end time if (teamProjectTime2Gateway.GetEndTime((int)ViewState["teamProjectTimeId"]).HasValue) { string endTime = ((DateTime)teamProjectTime2Gateway.GetEndTime((int)ViewState["teamProjectTimeId"])).ToString("H:mm"); string[] endHoursMin1 = endTime.Split(':'); ddlEndTimeHour.SelectedValue = endHoursMin1[0].Trim(); ddlEndTimeMinute.SelectedValue = endHoursMin1[1].Trim(); } // ... for offset if (teamProjectTime2Gateway.GetOffset((int)ViewState["teamProjectTimeId"]).HasValue) ddlLunch.SelectedValue = Math.Round(teamProjectTime2Gateway.GetOffset((int)ViewState["teamProjectTimeId"]).Value, 2).ToString(); // ... for meals country if (!deleted) { if (teamProjectTime2Gateway.GetMealsCountry((int)ViewState["teamProjectTimeId"]).HasValue) { ddlMealsCountry.SelectedValue = teamProjectTime2Gateway.GetMealsCountry((int)ViewState["teamProjectTimeId"]).Value.ToString(); } else { ddlMealsCountry.SelectedIndex = 0; } } else { ddlMealsCountry.SelectedIndex = -1; } // ... for meals allowance //if (teamProjectTime2Gateway.GetMealsAllowance((int)ViewState["teamProjectTimeId"]) > 0) cbxMealsAllowance.Checked = true; // ... for fair wage if (teamProjectTime2Gateway.GetFairWage((int)ViewState["teamProjectTimeId"])) hdfFairWage.Value = "True"; // Store datasets Session["teamProjectTime2TDS"] = teamProjectTime2TDS; template = teamProjectTime2TDS.Template; Session["template"] = teamProjectTime2TDS.Template; } //cbxClearUnitAssigment.Checked = false; }
private void DeleteTemplate(int teamProjectTimeId) { // Create TDS to save teamProjectTime2TDSToSave = new TeamProjectTime2TDS(); // Delete Template TeamProjectTime2Template teamProjectTime2Template = new TeamProjectTime2Template(teamProjectTime2TDS); teamProjectTime2Template.Delete(teamProjectTimeId); // ... Store datasets for teplate Session.Remove("templateDummy"); Session["teamProjectTime2TDS"] = teamProjectTime2TDS; template = teamProjectTime2TDS.Template; Session["template"] = teamProjectTime2TDS.Template; // Delete associated TeamProjectTime to Template // ... load TeamProjectTime TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDSToSave); teamProjectTime2Gateway.LoadByTeamProjectTimeId(teamProjectTimeId); // ... delete TeamProjectTime TeamProjectTime2 teamProjectTime2 = new TeamProjectTime2(teamProjectTime2TDSToSave); teamProjectTime2.Delete(teamProjectTimeId); // Delete associated TeamProjectTimeDetails to Template // ... load TeamProjectTimeDetails TeamProjectTime2DetailGateway teamProjectTime2DetailGateway = new TeamProjectTime2DetailGateway(teamProjectTime2TDSToSave); teamProjectTime2DetailGateway.LoadByTeamProjectTimeId(teamProjectTimeId); // ... delete TeamProjectTimeDetails TeamProjectTime2Detail teamProjectTime2Detail = new TeamProjectTime2Detail(teamProjectTime2TDSToSave); teamProjectTime2Detail.Delete(teamProjectTimeId); }