// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Validate query string if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["others"] == null) && ((string)Request.QueryString["employee_id"] == null) && ((string)Request.QueryString["period_id"] == null) && ((string)Request.QueryString["projecttime_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in timesheet_summary.aspx"); } // Security check if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { if (Request.QueryString["others"] == "no") { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } } else { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_VIEW"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } } } } } } // Initialize viewstate's variables ViewState["others"] = Request.QueryString["others"]; ViewState["employee_id"] = int.Parse(Request.QueryString["employee_id"]); ViewState["period_id"] = int.Parse(Request.QueryString["period_id"]); ViewState["projecttime_id"] = int.Parse(Request.QueryString["projecttime_id"]); System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader(); ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString(); // Get ProjectTime record projectTimeTDS = new ProjectTimeTDS(); ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway(projectTimeTDS); projectTimeGateway.LoadByProjectTimeId((int)ViewState["projecttime_id"]); // Store datasets Session["projectTimeTDS"] = projectTimeTDS; // Databind tbxDate.DataBind(); tbxWorkingDetails.DataBind(); tbxStartTime.DataBind(); tbxEndTime.DataBind(); tbxLunch.DataBind(); tbxComments.DataBind(); tbxState.DataBind(); // Prepare initial data for client StoreNavigatorState(); EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet()); employeeGateway.LoadByEmployeeId((int)ViewState["employee_id"]); tbxEmployee.Text = employeeGateway.GetFullName((int)ViewState["employee_id"]); int companyId = Int32.Parse(Session["companyID"].ToString()); CompaniesGateway companiesGateway = new CompaniesGateway(new DataSet()); companiesGateway.LoadAllByCompaniesId(projectTimeGateway.GetCompaniesId((int)ViewState["projecttime_id"]), companyId); tbxClient.Text = companiesGateway.GetName(projectTimeGateway.GetCompaniesId((int)ViewState["projecttime_id"])); ProjectGateway projectGateway = new ProjectGateway(new DataSet()); projectGateway.LoadByProjectId(projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])); tbxProject.Text = projectGateway.GetName(projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])) + "(" + projectGateway.GetProjectNumber(projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])) + ")"; if (projectGateway.GetFairWageApplies(projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"]))) { tbxJobClassType.Visible = true; lblJobClassType.Visible = true; tbxJobClassType.Text = projectTimeGateway.GetJobClassType((int)ViewState["projecttime_id"]); } else { tbxJobClassType.Visible = false; lblJobClassType.Visible = false; } if (projectTimeGateway.GetMealsCountry((int)ViewState["projecttime_id"]).HasValue) { CountryGateway countryGateway = new CountryGateway(new DataSet()); countryGateway.LoadByCountryId((Int64)projectTimeGateway.GetMealsCountry((int)ViewState["projecttime_id"])); tbxMealsCountry.Text = countryGateway.GetName((Int64)projectTimeGateway.GetMealsCountry((int)ViewState["projecttime_id"])); } //if (projectTimeGateway.GetMealsAllowance((int)ViewState["projecttime_id"]) > 0) //{ // cbxMealsAllowance.Checked = true; //} //if (projectTimeGateway.GetFairWage((int)ViewState["projecttime_id"])) //{ // cbxFairWage.Checked = true; //} if (projectTimeGateway.GetUnitId((int)ViewState["projecttime_id"]).HasValue) { UnitsGateway unitGateway = new UnitsGateway(new DataSet()); unitGateway.LoadByUnitId((int)projectTimeGateway.GetUnitId((int)ViewState["projecttime_id"]), Convert.ToInt32(Session["companyID"])); tbxUnit.Text = unitGateway.GetUnitCode((int)projectTimeGateway.GetUnitId((int)ViewState["projecttime_id"])); } if (projectTimeGateway.GetTowedUnitId((int)ViewState["projecttime_id"]).HasValue) { UnitsGateway unitGateway = new UnitsGateway(new DataSet()); unitGateway.LoadByUnitId((int)projectTimeGateway.GetTowedUnitId((int)ViewState["projecttime_id"]), Convert.ToInt32(Session["companyID"])); tbxTowed.Text = unitGateway.GetUnitCode((int)projectTimeGateway.GetTowedUnitId((int)ViewState["projecttime_id"])); } tbxTypeOfWork.Text = ""; if (projectTimeGateway.GetWork((int)ViewState["projecttime_id"]) != "") { tbxTypeOfWork.Text = projectTimeGateway.GetWork((int)ViewState["projecttime_id"]); } tbxFunction.Text = ""; if (projectTimeGateway.GetFunction((int)ViewState["projecttime_id"]) != "") { tbxFunction.Text = projectTimeGateway.GetFunction((int)ViewState["projecttime_id"]); } } else { // Restore datasets projectTimeTDS = (ProjectTimeTDS)Session["projectTimeTDS"]; } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Validate query string if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["others"] == null) && ((string)Request.QueryString["employee_id"] == null) && ((string)Request.QueryString["period_id"] == null) && ((string)Request.QueryString["projecttime_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in timesheet_delete.aspx"); } // Security check if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { if (Request.QueryString["others"] == "no") { if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_DELETE"]))) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } } else { if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_DELETE"]))) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"])) { if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_DELETE"]))) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } } } } } } // Initialize viewstate variables ViewState["others"] = Request.QueryString["others"]; ViewState["employee_id"] = int.Parse(Request.QueryString["employee_id"]); ViewState["period_id"] = int.Parse(Request.QueryString["period_id"]); ViewState["projecttime_id"] = int.Parse(Request.QueryString["projecttime_id"]); System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader(); ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString(); // Get ProjectTime record projectTimeTDS = new ProjectTimeTDS(); ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway(projectTimeTDS); projectTimeGateway.LoadByProjectTimeId((int)ViewState["projecttime_id"]); // Project time state check if ((!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"]))) { if (projectTimeGateway.GetProjectTimeState((int)ViewState["projecttime_id"]) == "Approved") { Response.Redirect("./../../error_page.aspx?error=" + "You cannot delete an approved project time."); } } if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { if (Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT"])) { bool isValidLimitPayPeriodToManagementEdit = LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime.ValidateLimitedPayPeriodToManagementEdit(projectTimeGateway.GetDate_((int)ViewState["projecttime_id"]), projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])); if (!isValidLimitPayPeriodToManagementEdit) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } if (Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"])) { bool isValidLimitPayPeriodToManagementEdit = LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime.ValidateLimitedPayPeriodToWednesdayManagementEdit(projectTimeGateway.GetDate_((int)ViewState["projecttime_id"]), projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])); if (!isValidLimitPayPeriodToManagementEdit) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } // Prepare initial data for client StoreNavigatorState(); // Store datasets Session["projectTimeTDS"] = projectTimeTDS; } else { // Restore datasets projectTimeTDS = (ProjectTimeTDS)Session["projectTimeTDS"]; } }
private bool ValidateWedManagement() { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { if (Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"])) { List<int> projectTimesIdSelected = ((List<int>)Session["projectTimesIdSelected"]); ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway(); foreach (int projectTimeId in projectTimesIdSelected) { projectTimeGateway.LoadByProjectTimeId(projectTimeId); bool isValidLimitPayPeriodToManagementEdit = LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime.ValidateLimitedPayPeriodToWednesdayManagementEdit(projectTimeGateway.GetDate_(projectTimeId), projectTimeGateway.GetProjectId(projectTimeId)); if (!isValidLimitPayPeriodToManagementEdit) { return false; } } } } return true; }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Validate query string if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["others"] == null) && ((string)Request.QueryString["employee_id"] == null) && ((string)Request.QueryString["period_id"] == null) && ((string)Request.QueryString["projecttime_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in timesheet_edit.aspx"); } // Security check if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { if (Request.QueryString["others"] == "no") { if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_EDIT"]))) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } } else { if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_EDIT"]))) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"])) { if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_EDIT"]))) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT"])) { if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } } } } } } // Initialize viewstate variables ViewState["others"] = Request.QueryString["others"]; ViewState["employee_id"] = int.Parse(Request.QueryString["employee_id"]); ViewState["period_id"] = int.Parse(Request.QueryString["period_id"]); ViewState["projecttime_id"] = int.Parse(Request.QueryString["projecttime_id"]); System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader(); ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString(); hdfCompanyId.Value = Session["companyID"].ToString(); // Get ProjectTime record ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway(projectTimeTDS); projectTimeGateway.LoadByProjectTimeId((int)ViewState["projecttime_id"]); // Project time state check if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { if (projectTimeGateway.GetProjectTimeState((int)ViewState["projecttime_id"]) == "Approved") { Response.Redirect("./../../error_page.aspx?error=" + "You cannot edit an approved project time."); } } if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"])) { if (Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT"])) { bool isValidLimitPayPeriodToManagementEdit = LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime.ValidateLimitedPayPeriodToManagementEdit(projectTimeGateway.GetDate_((int)ViewState["projecttime_id"]), projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])); if (!isValidLimitPayPeriodToManagementEdit) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } else { if (Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"]) || Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"])) { bool isValidLimitPayPeriodToManagementEdit = LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime.ValidateLimitedPayPeriodToWednesdayManagementEdit(projectTimeGateway.GetDate_((int)ViewState["projecttime_id"]), projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])); if (!isValidLimitPayPeriodToManagementEdit) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } } // Store datasets Session["projectTimeTDS"] = projectTimeTDS; // Databind tkrdpDate_.DataBind(); ddlLunch.DataBind(); tbxComments.DataBind(); tbxState.DataBind(); // Prepare initial data for client StoreNavigatorState(); EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet()); employeeGateway.LoadByEmployeeId((int)ViewState["employee_id"]); tbxEmployee.Text = employeeGateway.GetFullName(int.Parse(Request.QueryString["employee_id"])); int companyId = Int32.Parse(hdfCompanyId.Value); CompaniesList companiesList = new CompaniesList(); companiesList.LoadAndAddItem(-1, "(Select a client)", companyId); ddlClient.DataSource = companiesList.Table; ddlClient.DataValueField = "COMPANIES_ID"; ddlClient.DataTextField = "Name"; ddlClient.DataBind(); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(Int32.Parse(DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].CompaniesID").ToString()), companyId); // ... If Company is active bool deleted = companiesGateway.GetDeleted(Int32.Parse(DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].CompaniesID").ToString())); if (deleted) { ddlClient.SelectedIndex = -1; } else { ddlClient.SelectedValue = DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].CompaniesID").ToString(); } ProjectList projectList = new ProjectList(); projectList.LoadProjectsInternalProjectsBallparkProjectsAndAddItem(-1, "(Select a project)", int.Parse(ddlClient.SelectedValue)); ddlProject.DataSource = projectList.Table; ddlProject.DataValueField = "ProjectID"; ddlProject.DataTextField = "Name"; ddlProject.DataBind(); if (!deleted) { try { ddlProject.SelectedValue = DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].ProjectID").ToString(); } catch { ddlProject.SelectedIndex = -1; } } else { ddlProject.SelectedIndex = -1; } if (ddlProject.SelectedIndex != 0) { ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(Int32.Parse(ddlProject.SelectedValue)); if (projectGateway.GetCountryID(Int32.Parse(ddlProject.SelectedValue)) == 1) //Canada { if (projectGateway.GetFairWageApplies(int.Parse(ddlProject.SelectedValue))) { ddlJobClassType.Visible = true; lblJobClassType.Visible = true; ProjectTimeJobClassTypeList projectTimeJobClassTypeList = new ProjectTimeJobClassTypeList(); projectTimeJobClassTypeList.LoadAndAddItem(1, companyId, "(Select a Job Class Type)"); ddlJobClassType.DataSource = projectTimeJobClassTypeList.Table; ddlJobClassType.DataValueField = "JobClassType"; ddlJobClassType.DataTextField = "JobClassType"; ddlJobClassType.DataBind(); if (projectTimeGateway.GetJobClassType((int)ViewState["projecttime_id"]).ToString() == "") { ddlJobClassType.SelectedIndex = 0; } else { ddlJobClassType.SelectedValue = (string)DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].JobClassType"); } } else { ddlJobClassType.Visible = false; lblJobClassType.Visible = false; } } else { if (projectGateway.GetFairWageApplies(int.Parse(ddlProject.SelectedValue))) { ddlJobClassType.Visible = true; lblJobClassType.Visible = true; ProjectTimeJobClassTypeList projectTimeJobClassTypeList = new ProjectTimeJobClassTypeList(); projectTimeJobClassTypeList.LoadAndAddItem(2, companyId, "(Select a Job Class Type)"); ddlJobClassType.DataSource = projectTimeJobClassTypeList.Table; ddlJobClassType.DataValueField = "JobClassType"; ddlJobClassType.DataTextField = "JobClassType"; ddlJobClassType.DataBind(); if (projectTimeGateway.GetJobClassType((int)ViewState["projecttime_id"]).ToString() == "") { ddlJobClassType.SelectedIndex = 0; } else { ddlJobClassType.SelectedValue = (string)DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].JobClassType"); } } else { ddlJobClassType.Visible = false; lblJobClassType.Visible = false; } } } else { ddlJobClassType.Visible = false; lblJobClassType.Visible = false; } WorkingDetailsGateway workingDetailsGateway = new WorkingDetailsGateway(new DataSet()); workingDetailsGateway.Load(); ddlWorkingDetails.DataSource = workingDetailsGateway.Table; ddlWorkingDetails.DataValueField = "WorkingDetails"; ddlWorkingDetails.DataTextField = "WorkingDetails"; ddlWorkingDetails.DataBind(); if (!deleted) { ddlWorkingDetails.SelectedValue = projectTimeGateway.GetWorkingDetails((int)ViewState["projecttime_id"]); } else { ddlWorkingDetails.SelectedIndex = -1; } ProjectTimeWorkList projectTimeWorkList = new ProjectTimeWorkList(new DataSet()); int projectId = 0; try { projectId = Int32.Parse(ddlProject.SelectedValue); } catch { } if (projectId == 35 || projectId == 39 || projectId == 716) { projectTimeWorkList.LoadAndAddItem(""); } else { projectTimeWorkList.LoadAndAddItem("(Select a Type)"); } // Setting start time, end time string startTime = DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].StartTime", "{0:H:mm}").ToString(); if (!String.IsNullOrEmpty(startTime)) { string[] hoursMin1 = startTime.Split(':'); ddlStartTimeHour.SelectedValue = hoursMin1[0].Trim(); ddlStartTimeMinute.SelectedValue = hoursMin1[1].Trim(); } else { ddlStartTimeHour.SelectedIndex = 0; ddlStartTimeMinute.SelectedIndex = 0; } string endTime = DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].EndTime", "{0:H:mm}").ToString(); if (!String.IsNullOrEmpty(endTime)) { string[] endHoursMin1 = endTime.Split(':'); ddlEndTimeHour.SelectedValue = endHoursMin1[0].Trim(); ddlEndTimeMinute.SelectedValue = endHoursMin1[1].Trim(); } else { ddlEndTimeHour.SelectedIndex = 0; ddlEndTimeMinute.SelectedIndex = 0; } // Setting type of Work ddlTypeOfWork.DataSource = projectTimeWorkList.Table; ddlTypeOfWork.DataValueField = "Work_"; ddlTypeOfWork.DataTextField = "Work_"; ddlTypeOfWork.DataBind(); if (projectTimeGateway.GetWork((int)ViewState["projecttime_id"]) == "") ddlTypeOfWork.SelectedIndex = -1; else ddlTypeOfWork.SelectedValue = projectTimeGateway.GetWork((int)ViewState["projecttime_id"]); ProjectTimeWorkFunctionList projectTimeWorkFunctionList = new ProjectTimeWorkFunctionList(new DataSet()); if (projectTimeGateway.GetWork((int)ViewState["projecttime_id"]) == "") { // ... If there is no type of Work, no function should be loaded projectTimeWorkFunctionList.LoadAndAddItem("", "-1"); } else { projectTimeWorkFunctionList.LoadAndAddItem("(Select a Function)", projectTimeGateway.GetWork((int)ViewState["projecttime_id"]).ToString()); } ddlFunction.DataSource = projectTimeWorkFunctionList.Table; ddlFunction.DataValueField = "Function_"; ddlFunction.DataTextField = "Function_"; ddlFunction.DataBind(); if (projectTimeGateway.GetWork((int)ViewState["projecttime_id"]).ToString() == "") { ddlFunction.SelectedValue = ""; } else { ddlFunction.SelectedValue = (string)DataBinder.Eval(projectTimeTDS, "Tables[LFS_PROJECT_TIME].DefaultView.[0].Function_"); } CountryList countryList = new CountryList(new DataSet()); countryList.LoadAndAddItem(-1, " "); ddlMealsCountry.DataSource = countryList.Table; ddlMealsCountry.DataValueField = "CountryID"; ddlMealsCountry.DataTextField = "Name"; ddlMealsCountry.DataBind(); if (!deleted) { if (projectTimeGateway.GetMealsCountry((int)ViewState["projecttime_id"]).HasValue) { ddlMealsCountry.SelectedValue = projectTimeGateway.GetMealsCountry((int)ViewState["projecttime_id"]).ToString(); } else { ddlMealsCountry.SelectedValue = "-1"; } } else { ddlMealsCountry.SelectedIndex = -1; } //if (projectTimeGateway.GetMealsAllowance((int)ViewState["projecttime_id"]) > 0) //{ // cbxMealsAllowance.Checked = true; //} string unitType = "Vehicle"; UnitsList unitsList = new UnitsList(new DataSet()); unitsList.LoadAndAddItem("-1", " ", Int32.Parse(Session["companyID"].ToString()), true, 0, unitType); ddlUnit.DataSource = unitsList.Table; ddlUnit.DataValueField = "UnitID"; ddlUnit.DataTextField = "UnitCode"; ddlUnit.DataBind(); if (projectTimeGateway.GetUnitId((int)ViewState["projecttime_id"]).HasValue) { ddlUnit.SelectedValue = ((int)projectTimeGateway.GetUnitId((int)ViewState["projecttime_id"])).ToString(); } UnitsList towed = new UnitsList(new DataSet()); towed.LoadAndAddItem("-1", " ", Int32.Parse(Session["companyID"].ToString()), true, 1, unitType); ddlTowed.DataSource = towed.Table; ddlTowed.DataValueField = "UnitID"; ddlTowed.DataTextField = "UnitCode"; ddlTowed.DataBind(); if (projectTimeGateway.GetTowedUnitId((int)ViewState["projecttime_id"]).HasValue) { ddlTowed.SelectedValue = ((int)projectTimeGateway.GetTowedUnitId((int)ViewState["projecttime_id"])).ToString(); } } else { // Restore datasets projectTimeTDS = (ProjectTimeTDS)Session["projectTimeTDS"]; } }
/// <summary> /// FillData2 /// </summary> private void FillData2() { PrintHoursForPayrollPeriodOriginalGateway originalGateway = new PrintHoursForPayrollPeriodOriginalGateway(Data); foreach (PrintHoursForPayrollPeriodTDS.OriginalRow originalRow in (PrintHoursForPayrollPeriodTDS.OriginalDataTable)originalGateway.Table) { PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodRow newRow = ((PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodDataTable)Table).NewPrintHoursForPayrollPeriodRow(); newRow.EmployeeID = originalRow.EmployeeID; newRow.EmployeeName = originalRow.EmployeeName; newRow.CountryID = originalRow.CountryID; newRow.CountryName = originalRow.CountryName; newRow.Date_ = originalRow.Date_; newRow.ProjectName = originalRow.ProjectName; if (!originalRow.IsWork_Null()) newRow.Work_ = originalRow.Work_; else newRow.SetWork_Null(); if (!originalRow.IsFunction_Null()) newRow.Function_ = originalRow.Function_; else newRow.SetFunction_Null(); if (!originalRow.IsStartTimeNull()) newRow.StartTime = originalRow.StartTime; else newRow.SetStartTimeNull(); if (!originalRow.IsEndTimeNull()) newRow.EndTime = originalRow.EndTime; else newRow.SetEndTimeNull(); if (!originalRow.IsOffsetNull()) newRow.Offset = originalRow.Offset; else newRow.SetOffsetNull(); newRow.FairWage = false; originalRow.FairWage = false; if (!originalRow.IsJobClassTypeNull()) newRow.JobClassType = originalRow.JobClassType; else newRow.JobClassType = " "; if (originalRow.CountryID == 1) { newRow.TimeCA = originalRow.ProjectTime; newRow.TimeUS = originalRow.ProjectTime; } else { newRow.TimeCA = originalRow.ProjectTime; newRow.TimeUS = originalRow.ProjectTime; } newRow.TimeFairWage = 0; newRow.TimeFairWageOt = 0; newRow.TimeMob = 0; newRow.TimeMobOt = 0; newRow.TimeStandard = 0; newRow.TimeStandardOt = 0; if (!originalRow.IsStartTimeNull() && !originalRow.IsEndTimeNull()) { if (originalRow.IsWork_Null()) originalRow.Work_ = ""; if (originalRow.IsFunction_Null()) originalRow.Function_ = ""; ProjectGateway projectGateway = new ProjectGateway(null); ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway(); projectTimeGateway.LoadByProjectTimeId(originalRow.ProjectTimeID); if (projectGateway.IsFairWageProjectWorkFunction(projectTimeGateway.GetProjectId(originalRow.ProjectTimeID), originalRow.Work_, originalRow.Function_)) { newRow.FairWage = true; originalRow.FairWage = true; } int overtime = 40; //Default for USA // Canada if (originalRow.CountryID == 1) { switch (originalRow.Category) { case "Special Forces": overtime = 50; break; case "Field": overtime = 50; break; case "Field 44": overtime = 44; break; case "Office/Admin": overtime = 44; break; case "Mechanic/Manufactoring": overtime = 44; break; } if ((originalRow.Work_ == "Mobilization") && (originalRow.Function_ == "Prevail/Min Wage")) { double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtime) { newRow.TimeMob = 0; newRow.TimeMobOt = originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtime) { newRow.TimeMobOt = newAcumPeriod - overtime; newRow.TimeMob = originalRow.ProjectTime - newRow.TimeMobOt; } else { newRow.TimeMob = originalRow.ProjectTime; newRow.TimeMobOt = 0; } } } else { if ((originalRow.FairWage) && (originalRow.Work_ != "Mobilization")) { double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtime) { newRow.TimeFairWage = 0; newRow.TimeFairWageOt = originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtime) { newRow.TimeFairWageOt = newAcumPeriod - overtime; newRow.TimeFairWage = originalRow.ProjectTime - newRow.TimeFairWageOt; } else { newRow.TimeFairWage = originalRow.ProjectTime; newRow.TimeFairWageOt = 0; } } } else { double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtime) { newRow.TimeStandard = 0; newRow.TimeStandardOt = originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtime) { newRow.TimeStandardOt = newAcumPeriod - overtime; newRow.TimeStandard = originalRow.ProjectTime - newRow.TimeStandardOt; } else { newRow.TimeStandard = originalRow.ProjectTime; newRow.TimeStandardOt = 0; } } } } } else //USA { if ((originalRow.FairWage) && (originalRow.Work_ != "Mobilization")) { double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtime) { newRow.TimeFairWage = 0; newRow.TimeFairWageOt = originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtime) { newRow.TimeFairWageOt = newAcumPeriod - overtime; newRow.TimeFairWage = originalRow.ProjectTime - newRow.TimeFairWageOt; } else { newRow.TimeFairWage = originalRow.ProjectTime; newRow.TimeFairWageOt = 0; } } } else { double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtime) { newRow.TimeStandard = 0; newRow.TimeStandardOt = originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtime) { newRow.TimeStandardOt = newAcumPeriod - overtime; newRow.TimeStandard = originalRow.ProjectTime - newRow.TimeStandardOt; } else { newRow.TimeStandard = originalRow.ProjectTime; newRow.TimeStandardOt = 0; } } } } } if ((originalRow.WorkingDetails == "Sick Day") || (originalRow.WorkingDetails == "Holiday") || (originalRow.WorkingDetails == "Vacation / Other") || (originalRow.WorkingDetails == "Day Off - No Pay")) { newRow.WorkingDetails = originalRow.WorkingDetails; } else { newRow.WorkingDetails = ""; } newRow.ClientName = originalRow.ClientName; newRow.Location = originalRow.Location; if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsCountry == 1) { newRow.MealsCA = true; newRow.MealsUS = false; } else { newRow.MealsCA = false; newRow.MealsUS = true; } } else { newRow.MealsCA = false; newRow.MealsUS = false; } if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsCountry == 1) { newRow.TotalCA = originalRow.MealsAllowance; newRow.TotalUS = 0; } else { newRow.TotalCA = 0; newRow.TotalUS = originalRow.MealsAllowance; } } else { newRow.TotalCA = 0; newRow.TotalUS = 0; } if (!originalRow.IsProjectTimeStateNull()) { if (originalRow.ProjectTimeState == "Approved") { newRow.IsApproved = true; } else { newRow.IsApproved = false; } } else { newRow.IsApproved = false; } if (!originalRow.IsApprovedByNull()) { newRow.ApprovedBy = originalRow.ApprovedBy; } else { newRow.ApprovedBy = ""; } if (!originalRow.IsProjectTimeStateNull()) { string projectTimeState = originalRow.ProjectTimeState; if (projectTimeState == "Approved") { newRow.ProjectTimeState = originalRow.ApprovedBy; } else { newRow.ProjectTimeState = "--"; } } else { newRow.ProjectTimeState = "--"; } if (!originalRow.IsJobClassProjectTimeNull()) { string jobClassProjectTime = originalRow.JobClassProjectTime; switch (jobClassProjectTime) { case "Laborer Group 2": originalRow.JobClassProjectTime = "Lab 2"; break; case "Laborer Group 6": originalRow.JobClassProjectTime = "Lab 6"; break; case "Operator Group 1": originalRow.JobClassProjectTime = "Op 1"; break; case "Operator Group 2": originalRow.JobClassProjectTime = "Op 2"; break; case "Regular Rate": originalRow.JobClassProjectTime = "Reg Rate"; break; } } // Show or not Job Class Project Time if (!originalRow.IsWork_Null()) { if (originalRow.Work_ != "Mobilization") { if (!originalRow.IsJobClassProjectTimeNull()) { newRow.JobClassProjectTime = originalRow.JobClassProjectTime; } else { newRow.JobClassProjectTime = ""; } } else { newRow.JobClassProjectTime = ""; } } else { if (!originalRow.IsJobClassProjectTimeNull()) { newRow.JobClassProjectTime = originalRow.JobClassProjectTime; } else { newRow.JobClassProjectTime = ""; } } if (!originalRow.IsCommentsNull()) newRow.Comments = originalRow.Comments; else newRow.SetCommentsNull(); ((PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodDataTable)Table).AddPrintHoursForPayrollPeriodRow(newRow); } }