// //////////////////////////////////////////////////////////////////////// // 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) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in timesheet_approve.aspx"); } // Security check EmployeeGateway employeeGateway1 = new EmployeeGateway(new DataSet()); int employeeId = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"])); hdfCurrentEmployeeId.Value = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"])).ToString(); employeeGateway1.LoadByEmployeeId(employeeId); if (!employeeGateway1.GetApproveTimesheets(employeeId)) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Tag page Session.Remove("projectTimeApproveDummy"); // Initialize variables lblError.Visible = false; // ... Initialize viewstate variables System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader(); ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString(); // Labour Hours Mode check if ((string)ViewState["LHMode"] == "Partial") { Response.Redirect("./../../error_page.aspx?error=" + "The system is on partial mode. Contact your system administrator."); } ViewState["others"] = Request.QueryString["others"]; PayPeriodGateway payPeriodGateway = new PayPeriodGateway(new DataSet()); ViewState["period_id"] = payPeriodGateway.GetPayPeriodId(DateTime.Now); // Load data // ... Loading employees accordingly to the admins country. EmployeeList employeeList = new EmployeeList(new DataSet()); string employeeType = employeeGateway1.GetType(employeeId); odsClient.SelectParameters.RemoveAt(2); if (employeeType.Contains("CA")) { employeeList.LoadByRequestProjectTimeEmployeeTypeEmployeeIdApproveManagerAndAddItem(1, "CA", -1, "(All)", employeeId); odsClient.SelectParameters.Add("countryId", "1"); } else { if (employeeType.Contains("US")) { employeeList.LoadByRequestProjectTimeEmployeeTypeEmployeeIdApproveManagerAndAddItem(1, "US", -1, "(All)", employeeId); odsClient.SelectParameters.Add("countryId", "2"); } else { employeeList.LoadByRequestProjectTimeEmployeeTypeEmployeeIdApproveManagerAndAddItem(1, "SOTA", -1, "(All)", employeeId); odsClient.SelectParameters.Add("countryId", "-1"); } } odsClient.Select(); ddlClient.SelectedIndex = 0; upnlClient.Update(); ddlTeamMember.DataSource = employeeList.Table; ddlTeamMember.DataValueField = "EmployeeID"; ddlTeamMember.DataTextField = "FullName"; ddlTeamMember.DataBind(); odsProject.SelectParameters.RemoveAt(2); odsProject.SelectParameters.Add("clientId", "-1"); odsProject.Select(); ddlProject.DataBind(); ddlProject.SelectedIndex = 0; upnlProject.Update(); projectTimeApproveTDS = this.SubmitSearch(); // Store Datasets Session["projectTimeApproveTDS"] = projectTimeApproveTDS; projectTimeApprove = projectTimeApproveTDS.ProjectTimeApprove; Session["projectTimeApprove"] = projectTimeApproveTDS.ProjectTimeApprove; // If coming from // ... timesheet_edit.aspx, timesheet_summary.aspx or timesheet_delete.aspx if ((Request.QueryString["source_page"] == "timesheet_edit.aspx") || (Request.QueryString["source_page"] == "timesheet_summary.aspx") || (Request.QueryString["source_page"] == "timesheet_delete.aspx")) { // ... restore top values RestoreNavigatorState(); // ... filter grid information //SetFilterByCountryIdClientIdProjectId(); //SetFilterByEmployeeIdDate(); SetFilterByClientIdProjectIdEmployeeIdDate(); } ViewState["filter_expression"] = "Deleted = 0"; SetFocus(); } else { // Restore dataset projectTimeApproveTDS = (ProjectTimeApproveTDS)Session["projectTimeApproveTDS"]; projectTimeApprove = projectTimeApproveTDS.ProjectTimeApprove; Session["projectTimeApprove"] = projectTimeApproveTDS.ProjectTimeApprove; } }