// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_RESOURCES_EMPLOYEES_VIEW"]) && Convert.ToBoolean(Session["sgLFS_RESOURCES_EMPLOYEES_EDIT"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["employee_id"] == null) || ((string)Request.QueryString["active_tab"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in employees_summary.aspx"); } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); hdfResourceType.Value = "Employees"; hdfActiveTab.Value = Request.QueryString["active_tab"].ToString(); hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString(); hdfCurrentEmployeeId.Value = Request.QueryString["employee_id"]; // Prepare initial data Session.Remove("employeesNotesDummy"); Session.Remove("employeesCostsDummy"); Session.Remove("employeesCostsExceptionsDummy"); Session.Remove("employeesVacationsDummy"); Session.Remove("costIdSelected"); // ... for team member title int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); int employeeId = Int32.Parse(hdfCurrentEmployeeId.Value); EmployeeGateway employeeGateway = new EmployeeGateway(); employeeGateway.LoadByEmployeeId(employeeId); lblTitleTeamMember.Text = "Team Member: " + employeeGateway.GetFullName(employeeId); // If coming from // ... employees_navigator2.aspx, employees_add.aspx if ((Request.QueryString["source_page"] == "employees_navigator2.aspx") || (Request.QueryString["source_page"] == "employees_add.aspx")) { StoreNavigatorState(); ViewState["update"] = "yes"; // ... ... Set initial tab if ((string)Session["dialogOpenedEmployees"] != "1") { hdfActiveTab.Value = Request.QueryString["active_tab"]; employeeInformationTDS = new EmployeeInformationTDS(); EmployeeInformationBasicInformation employeeInformationBasicInformation = new EmployeeInformationBasicInformation(employeeInformationTDS); employeeInformationBasicInformation.LoadByEmployeeId(employeeId, companyId); EmployeeInformationCostInformation employeeInformationCostInformation = new EmployeeInformationCostInformation(employeeInformationTDS); employeeInformationCostInformation.LoadAllByEmployeeId(employeeId, companyId); EmployeeInformationCostExceptionsInformation employeeInformationCostExceptionsInformation = new EmployeeInformationCostExceptionsInformation(employeeInformationTDS); employeeInformationCostExceptionsInformation.LoadAllByEmployeeId(employeeId, companyId); Session["costIdSelected"] = 0; EmployeeInformationNoteInformation employeeInformationNoteInformationForEdit = new EmployeeInformationNoteInformation(employeeInformationTDS); employeeInformationNoteInformationForEdit.LoadAllByEmployeeId(employeeId, companyId); EmployeeInformationCategoryApproveTimesheetsInformation employeeInformationCategoryApproveTimesheetsInformation = new EmployeeInformationCategoryApproveTimesheetsInformation(employeeInformationTDS); employeeInformationCategoryApproveTimesheetsInformation.LoadByEmployeeId(employeeId); } else { hdfActiveTab.Value = (string)Session["activeTabEmployees"]; // Restore datasets employeeInformationTDS = (EmployeeInformationTDS)Session["employeeInformationTDS"]; } tcDetailedInformation.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value); // Store dataset Session["employeeInformationTDS"] = employeeInformationTDS; } // ... employees_delete.aspx or employees_edit.aspx if ((Request.QueryString["source_page"] == "employees_delete.aspx") || (Request.QueryString["source_page"] == "employees_edit.aspx")) { StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; // Restore dataset employeeInformationTDS = (EmployeeInformationTDS)Session["employeeInformationTDS"]; // ... Set initial tab if ((string)Session["dialogOpenedEmployees"] != "1") { hdfActiveTab.Value = Request.QueryString["active_tab"]; } else { hdfActiveTab.Value = (string)Session["activeTabEmployees"]; } tcDetailedInformation.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value); } string filterOptions = string.Format("CostID = {0} AND Deleted = {1}", 0, 0); odsCostsExceptions.FilterExpression = filterOptions; // Prepare initial data // ... Data for current employee LoadData(); // Databind Page.DataBind(); } else { // Restore datasets employeeInformationTDS = (EmployeeInformationTDS)Session["employeeInformationTDS"]; // Set initial tab int activeTab = Int32.Parse(hdfActiveTab.Value); tcDetailedInformation.ActiveTabIndex = activeTab; } }
protected void grdNotes_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("notesDataEdit"); if (Page.IsValid) { int employeeId = (int)e.Keys["EmployeeID"]; int refId = (int)e.Keys["RefID"]; string subject = ((TextBox)grdNotes.Rows[e.RowIndex].Cells[2].FindControl("tbxNoteSubjectEdit")).Text.Trim(); string Note = ((TextBox)grdNotes.Rows[e.RowIndex].Cells[3].FindControl("tbxNoteNoteEdit")).Text.Trim(); // Update data EmployeeInformationNoteInformation model = new EmployeeInformationNoteInformation(employeeInformationTDS); model.Update(employeeId, refId, subject, Note); // Store dataset Session["employeeInformationTDS"] = employeeInformationTDS; } else { e.Cancel = true; } }
private void UpdateDatabase() { int companyId = Int32.Parse(hdfCompanyId.Value); int employeeId = Int32.Parse(hdfCurrentEmployeeId.Value); DB.Open(); DB.BeginTransaction(); try { // Save type history information EmployeeInformationTypeHistoryInformation employeeInformationTypeHistoryInformation = new EmployeeInformationTypeHistoryInformation(employeeInformationTDS); employeeInformationTypeHistoryInformation.Save(employeeId, companyId); // Save notes information EmployeeInformationNoteInformation employeeInformationNoteInformation = new EmployeeInformationNoteInformation(employeeInformationTDS); employeeInformationNoteInformation.Save(companyId); // Save costs information EmployeeInformationCostInformation employeeInformationCostInformation = new EmployeeInformationCostInformation(employeeInformationTDS); employeeInformationCostInformation.Save(companyId); // Save costs exceptions information EmployeeInformationCostExceptionsInformation employeeInformationCostExceptionsInformation = new EmployeeInformationCostExceptionsInformation(employeeInformationTDS); employeeInformationCostExceptionsInformation.Save(companyId, employeeId); // Save categories approve timesheets information EmployeeInformationCategoryApproveTimesheetsInformation employeeInformationCategoryApproveTimesheetsInformation = new EmployeeInformationCategoryApproveTimesheetsInformation(employeeInformationTDS); employeeInformationCategoryApproveTimesheetsInformation.Save(); // Save employee information EmployeeInformationBasicInformation employeeInformationBasicInformation = new EmployeeInformationBasicInformation(employeeInformationTDS); employeeInformationBasicInformation.Save(companyId); DB.CommitTransaction(); // Store datasets employeeInformationTDS.AcceptChanges(); Session["employeeInformationTDS"] = employeeInformationTDS; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
protected void grdNotes_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Notes Gridview, if the gridview is edition mode if (grdNotes.EditIndex >= 0) { grdNotes.UpdateRow(grdNotes.EditIndex, true); } // Delete note int employeeId = (int)e.Keys["EmployeeID"]; int refId = (int)e.Keys["RefID"]; EmployeeInformationNoteInformation model = new EmployeeInformationNoteInformation(employeeInformationTDS); // ... Delete at model model.Delete(employeeId, refId); // ... Store dataset Session["employeeInformationTDS"] = employeeInformationTDS; }
private void GrdNotesAdd() { if (ValidateNotesFooter()) { Page.Validate("notesDataAdd"); if (Page.IsValid) { int employeeId = Int32.Parse(hdfCurrentEmployeeId.Value); int companyId = Int32.Parse(hdfCompanyId.Value); string newSubject = ((TextBox)grdNotes.FooterRow.FindControl("tbxNoteSubjectNew")).Text.Trim(); int loginId = Convert.ToInt32(Session["loginID"]); DateTime dateTime_ = DateTime.Now; string newNote = ((TextBox)grdNotes.FooterRow.FindControl("tbxNoteNoteNew")).Text.Trim(); bool inServiceNoteDatabase = false; EmployeeInformationNoteInformation model = new EmployeeInformationNoteInformation(employeeInformationTDS); model.Insert(employeeId, newSubject, loginId, dateTime_, newNote, false, companyId, inServiceNoteDatabase); Session.Remove("employeesNotesDummy"); Session["employeeInformationTDS"] = employeeInformationTDS; grdNotes.DataBind(); grdNotes.PageIndex = grdNotes.PageCount - 1; } } }