// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP1 - BEGIN // // //////////////////////////////////////////////////////////////////////// // STEP1 - BEGIN - AUXILIAR EVENTS // protected void ddlSelectAPeriod_SelectedIndexChanged(object sender, EventArgs e) { Page.Validate("Begin"); if (Page.IsValid) { StepBeginProcessGrid(); // Load VacationsSetupTDS dataSet = new VacationsSetupTDS(); dataSet.VacationsSetup.Merge(vacationsSetup, true); VacationsSetup model = new VacationsSetup(dataSet); if (dataSet.VacationsSetup.Select(string.Format("Year = {0}", Int32.Parse(ddlSelectAPeriod.SelectedValue))).Length == 0) { // ... Load model.LoadByYear(Int32.Parse(ddlSelectAPeriod.SelectedValue), Int32.Parse(hdfCompanyId.Value)); dataSet.VacationsSetup.Merge(vacationsSetup, true); odsVacationsSetup.FilterExpression = string.Format("Year = {0}", Int32.Parse(ddlSelectAPeriod.SelectedValue)); } else { odsVacationsSetup.FilterExpression = string.Format("Year = {0}", Int32.Parse(ddlSelectAPeriod.SelectedValue)); } // Store tables vacationsSetup = (VacationsSetupTDS.VacationsSetupDataTable)model.Table; Session["vacationsSetup"] = vacationsSetup; } grdVacationsSetup.DataBind(); }
public VacationsSetupTDS.VacationsSetupDataTable GetVacationsSetupNew() { vacationsSetup = (VacationsSetupTDS.VacationsSetupDataTable)Session["vacationsSetupDummy"]; if (vacationsSetup == null) { vacationsSetup = ((VacationsSetupTDS.VacationsSetupDataTable)Session["vacationsSetup"]); } return vacationsSetup; }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_HOLIDAY_FULL_EDITING"]))) { 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) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in vacations_setup.aspx"); } // Tag page // ... for non vacation managers EmployeeGateway employeeGatewayManager = new EmployeeGateway(); int employeeIdNow = employeeGatewayManager.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"])); employeeGatewayManager.LoadByEmployeeId(employeeIdNow); if (employeeGatewayManager.GetIsVacationsManager(employeeIdNow)) { hdfIsVacationManager.Value = "True"; } else { hdfIsVacationManager.Value = "False"; } hdfCompanyId.Value = Session["companyID"].ToString(); hdfUpdate.Value = "no"; Session.Remove("vacationsSetup"); Session.Remove("vacationsSetupDummy"); // Prepare initial data // ... For Grids vacationsSetup = new VacationsSetupTDS.VacationsSetupDataTable(); // ... Store datasets Session["vacationsSetup"] = vacationsSetup; // StepSection1In wizard.ActiveStepIndex = 0; StepBeginIn(); } else { // Restore datasets vacationsSetup = (VacationsSetupTDS.VacationsSetupDataTable)Session["vacationsSetup"]; } }
private void StepBeginProcessGrid() { if (ExistsDataModified()) { VacationsSetupTDS dataSet = new VacationsSetupTDS(); dataSet.VacationsSetup.Merge(vacationsSetup, true); VacationsSetup model = new VacationsSetup(dataSet); // update rows foreach (GridViewRow row in grdVacationsSetup.Rows) { int year = Int32.Parse(grdVacationsSetup.DataKeys[row.RowIndex].Values["Year"].ToString()); int employeeId = Int32.Parse(grdVacationsSetup.DataKeys[row.RowIndex].Values["EmployeeID"].ToString()); double newVacationDays = double.Parse(((TextBox)row.FindControl("tbxVacationDays")).Text); double newCarryOverDays = double.Parse(((TextBox)row.FindControl("tbxCarryOverDays")).Text); model.Update(year, employeeId, newVacationDays, newCarryOverDays); } vacationsSetup = (VacationsSetupTDS.VacationsSetupDataTable)model.Table; Session["vacationsSetup"] = vacationsSetup; hdfUpdate.Value = "yes"; } }
// //////////////////////////////////////////////////////////////////////// // STEP1 - BEGIN - METHODS // private void StepBeginIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Please provide paid vacation days information"; // Initiaize data vacationsSetup = new VacationsSetupTDS.VacationsSetupDataTable(); // Load VacationsSetupTDS dataSet = new VacationsSetupTDS(); VacationsSetup model = new VacationsSetup(dataSet); model.LoadByYear(Int32.Parse(ddlSelectAPeriod.SelectedValue), Int32.Parse(hdfCompanyId.Value)); // Store tables vacationsSetup = (VacationsSetupTDS.VacationsSetupDataTable)model.Table; Session["vacationsSetup"] = vacationsSetup; }