/// <summary> /// Delete /// </summary> /// <param name="costId">costId</param> /// <param name="employeeId">employeeId</param> public void Delete(int costId, int employeeId) { EmployeeInformationTDS.CostInformationRow row = GetRow(costId); row.Deleted = true; EmployeeInformationCostExceptionsInformation model = new EmployeeInformationCostExceptionsInformation(Data); model.DeleteAll(costId); }
// //////////////////////////////////////////////////////////////////////// // 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 grdCostsExceptions_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("EditCostException"); if (Page.IsValid) { int costId = Int32.Parse(((Label)grdCostsExceptions.Rows[e.RowIndex].Cells[0].FindControl("lblExceptionCostIDEdit")).Text); int refId = Int32.Parse(((Label)grdCostsExceptions.Rows[e.RowIndex].Cells[0].FindControl("lblExceptionRefIDEdit")).Text); string work_ = ((DropDownList)grdCostsExceptions.Rows[e.RowIndex].Cells[0].FindControl("ddlExceptionWork_Edit")).SelectedValue; string unitOfMeasurement = ((DropDownList)grdCostsExceptions.Rows[e.RowIndex].Cells[0].FindControl("ddlExceptionUnitOfMeasurementEdit")).SelectedValue; decimal payRateCad = Decimal.Parse(((TextBox)grdCostsExceptions.Rows[e.RowIndex].Cells[0].FindControl("tbxExceptionPayRateCadEdit")).Text.Trim()); decimal payRateUsd = Decimal.Parse(((TextBox)grdCostsExceptions.Rows[e.RowIndex].Cells[0].FindControl("tbxExceptionPayRateUsdEdit")).Text.Trim()); decimal burdenRateCad = 0; decimal burdenRateUsd = 0; decimal totalCostCad = 0; decimal totalCostUsd = 0; if (tbxBourdenFactor.Text != "") { decimal boudenFactor = decimal.Parse(tbxBourdenFactor.Text) / 100; burdenRateCad = payRateCad * boudenFactor; totalCostCad = payRateCad + burdenRateCad; totalCostCad = Decimal.Round(totalCostCad, 2); burdenRateUsd = payRateUsd * boudenFactor; totalCostUsd = payRateUsd + burdenRateUsd; totalCostUsd = Decimal.Round(totalCostUsd, 2); } decimal healthBenefitUsd = 0; if (tbxUSHealthBenefitFactor.Text != "") { if (tbxBenefitFactorUsd.Text != "") { decimal healthBenefitFactor = Decimal.Parse(tbxUSHealthBenefitFactor.Text) / 100; healthBenefitUsd = decimal.Parse(tbxBenefitFactorUsd.Text) * healthBenefitFactor; } } // Update data EmployeeInformationCostExceptionsInformation model = new EmployeeInformationCostExceptionsInformation(employeeInformationTDS); model.Update(costId, refId, work_, unitOfMeasurement, payRateCad, burdenRateCad, totalCostCad, payRateUsd, burdenRateUsd, totalCostUsd, healthBenefitUsd); // Store dataset Session["employeeInformationTDS"] = employeeInformationTDS; string filterOptions = string.Format("CostID = {0} AND Deleted = {1}", costId, 0); odsCostsExceptions.FilterExpression = filterOptions; } else { e.Cancel = true; } }
protected void grdCostsExceptions_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Costs exceptions Gridview, if the gridview is edition mode if (grdCostsExceptions.EditIndex >= 0) { grdCostsExceptions.UpdateRow(grdCostsExceptions.EditIndex, true); } int costId = (int)e.Keys["CostID"]; int refId = (int)e.Keys["RefID"]; EmployeeInformationCostExceptionsInformation model = new EmployeeInformationCostExceptionsInformation(employeeInformationTDS); // Delete cost exception model.Delete(costId, refId); grdCostsExceptions.DataBind(); grdCosts.DataBind(); // Store dataset Session["employeeInformationTDS"] = employeeInformationTDS; }
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); } }
private void GrdCostsExceptionsAdd() { if (ValidateCostsExceptionsFooter()) { Page.Validate("AddCostException"); if (Page.IsValid) { int costId = Convert.ToInt32(Session["costIdSelected"]); int companyId = Int32.Parse(hdfCompanyId.Value); string work_ = ((DropDownList)grdCostsExceptions.FooterRow.FindControl("ddlExceptionWork_New")).SelectedValue; string unitOfMeasurement = ((DropDownList)grdCostsExceptions.FooterRow.FindControl("ddlExceptionUnitOfMeasurementNew")).SelectedValue; decimal payRateCad = Decimal.Parse(((TextBox)grdCostsExceptions.FooterRow.FindControl("tbxExceptionPayRateCadNew")).Text.Trim()); decimal payRateUsd = Decimal.Parse(((TextBox)grdCostsExceptions.FooterRow.FindControl("tbxExceptionPayRateUsdNew")).Text.Trim()); decimal burdenRateCad = 0; decimal totalCostCad = 0; decimal burdenRateUsd = 0; decimal totalCostUsd = 0; if (tbxBourdenFactor.Text != "") { decimal boudenFactor = decimal.Parse(tbxBourdenFactor.Text)/100; burdenRateCad = payRateCad * boudenFactor; totalCostCad = payRateCad + burdenRateCad; totalCostCad = Decimal.Round(totalCostCad, 2); burdenRateUsd = payRateUsd * boudenFactor; totalCostUsd = payRateUsd + burdenRateUsd; totalCostUsd = Decimal.Round(totalCostUsd, 2); } decimal benefitFactorCad = Decimal.Parse(tbxBenefitFactorCad.Text); decimal benefitFactorUsd = Decimal.Parse(tbxBenefitFactorUsd.Text); decimal healthBenefitUsd = 0; if (tbxUSHealthBenefitFactor.Text != "") { if (tbxBenefitFactorUsd.Text != "") { decimal healthBenefitFactor = Decimal.Parse(tbxUSHealthBenefitFactor.Text) / 100; healthBenefitUsd = decimal.Parse(tbxBenefitFactorUsd.Text) * healthBenefitFactor; } } EmployeeInformationCostExceptionsInformation model = new EmployeeInformationCostExceptionsInformation(employeeInformationTDS); model.Insert(costId, work_, unitOfMeasurement, payRateCad, burdenRateCad, totalCostCad, payRateUsd, burdenRateUsd, totalCostUsd, false, companyId, false, benefitFactorCad, benefitFactorUsd, healthBenefitUsd); Session.Remove("employeesCostsExceptionsDummy"); Session["employeeInformationTDS"] = employeeInformationTDS; string filterOptions = string.Format("CostID = {0} AND Deleted = {1}", costId, 0); odsCostsExceptions.FilterExpression = filterOptions; grdCostsExceptions.DataBind(); } } }