// ////////////////////////////////////////////////////////////////////////
        // INITIAL EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_CHECKLISTRULES_VIEW"]) && Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_CHECKLISTRULES_ADD"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfUpdate.Value = "no";

                // Initialize viewstate variables
                ViewState["StepFrom"] = "Out";

                // Prepare initial data
                checklistRulesAddTDS = new ChecklistRulesAddTDS();
                Session["checklistRulesAddTDS"] = checklistRulesAddTDS;

                arrayCategoriesSelected = new ArrayList();
                arrayCompanyLevelsSelected = new ArrayList();
                arrayUnitsSelected = new ArrayList();
                Session["arrayCategoriesSelected"] = arrayCategoriesSelected;
                Session["arrayCompanyLevelsSelected"] = arrayCompanyLevelsSelected;
                Session["arrayUnitsSelected"] = arrayUnitsSelected;

                // ... for frecuency
                RuleFrecuencyList ruleFrecuency = new RuleFrecuencyList();
                ruleFrecuency.LoadAndAddItem("(Select a frequency)", int.Parse(hdfCompanyId.Value));
                ddlFrequency.DataSource = ruleFrecuency.Table;
                ddlFrequency.DataValueField = "Frequency";
                ddlFrequency.DataTextField = "Frequency";
                ddlFrequency.DataBind();

                // ... for Categories
                categoriesTDS = new CategoriesTDS();
                Category category = new Category(categoriesTDS);
                category.Load(int.Parse(hdfCompanyId.Value));
                GetNodeForCategory(tvCategoriesRoot.Nodes, 0);

                // .. for Company Levels
                companyLevelsTDS = new CompanyLevelsTDS();
                CompanyLevel companyLevel = new CompanyLevel(companyLevelsTDS);
                companyLevel.Load(int.Parse(hdfCompanyId.Value));
                GetNodeForCompanyLevels(tvCompanyLevelsRoot.Nodes, 0);

                StepGeneralInformationIn();
            }
            else
            {
                checklistRulesAddTDS = (ChecklistRulesAddTDS)Session["checklistRulesAddTDS"];
                arrayCategoriesSelected = (ArrayList)Session["arrayCategoriesSelected"];
                arrayCompanyLevelsSelected = (ArrayList)Session["arrayCompanyLevelsSelected"];
                arrayUnitsSelected = (ArrayList)Session["arrayUnitsSelected"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_CHECKLISTRULES_VIEW"]) && Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_CHECKLISTRULES_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["rule_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in checklist_rules_summary.aspx");
                }

                // If coming from
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfRuleId.Value = Request.QueryString["rule_id"].ToString();
                arrayCategoriesSelected = new ArrayList();
                arrayCompanyLevelsSelected = new ArrayList();

                int companyId = Int32.Parse(hdfCompanyId.Value);
                int ruleId = Int32.Parse(hdfRuleId.Value);

                // ... checklist_rules_navigator.aspx
                if (Request.QueryString["source_page"] == "checklist_rules_navigator.aspx")
                {
                    ViewState["update"] = "no";

                    // ... For rule
                    ruleTDS = new RuleTDS();
                    LiquiForce.LFSLive.BL.FleetManagement.ChecklistRules.Rule rule = new LiquiForce.LFSLive.BL.FleetManagement.ChecklistRules.Rule(ruleTDS);
                    rule.LoadByRuleId(ruleId, companyId);

                    // ... For Categories
                    categoriesTDS = new CategoriesTDS();
                    Category category = new Category(categoriesTDS);
                    category.Load(companyId);

                    // .. For Company Levels
                    companyLevelsTDS = new CompanyLevelsTDS();
                    CompanyLevel companyLevel = new CompanyLevel(companyLevelsTDS);
                    companyLevel.Load(companyId);

                    // Store dataset
                    Session["ruleTDS"] = ruleTDS;
                    Session["categoriesTDSForChecklist"] = categoriesTDS;
                    Session["companyLevelsTDS"] = companyLevelsTDS;
                }

                // ... checklist_rules_add.aspx
                if (Request.QueryString["source_page"] == "checklist_rules_add.aspx")
                {
                    ViewState["update"] = "yes";

                    // ... For rule
                    ruleTDS = new RuleTDS();
                    LiquiForce.LFSLive.BL.FleetManagement.ChecklistRules.Rule rule = new LiquiForce.LFSLive.BL.FleetManagement.ChecklistRules.Rule(ruleTDS);
                    rule.LoadByRuleId(ruleId, companyId);

                    // ... For Categories
                    categoriesTDS = new CategoriesTDS();
                    Category category = new Category(categoriesTDS);
                    category.Load(companyId);

                    // ... For Company Levels
                    companyLevelsTDS = new CompanyLevelsTDS();
                    CompanyLevel companyLevel = new CompanyLevel(companyLevelsTDS);
                    companyLevel.Load(companyId);

                    // Store dataset
                    Session["ruleTDS"] = ruleTDS;
                    Session["categoriesTDSForChecklist"] = categoriesTDS;
                    Session["companyLevelsTDS"] = companyLevelsTDS;
                }

                // ... checklist_rules_delete.aspx or checklist_rules_edit.aspx
                if ((Request.QueryString["source_page"] == "checklist_rules_delete.aspx") || (Request.QueryString["source_page"] == "checklist_rules_edit.aspx"))
                {
                    ViewState["update"] = Request.QueryString["update"];

                    // ... For rule
                    ruleTDS = new RuleTDS();
                    LiquiForce.LFSLive.BL.FleetManagement.ChecklistRules.Rule rule = new LiquiForce.LFSLive.BL.FleetManagement.ChecklistRules.Rule(ruleTDS);
                    rule.LoadByRuleId(ruleId, companyId);

                    // ... For Categories
                    categoriesTDS = new CategoriesTDS();
                    Category category = new Category(categoriesTDS);
                    category.Load(companyId);

                    // ... For Company Levels
                    companyLevelsTDS = new CompanyLevelsTDS();
                    CompanyLevel companyLevel = new CompanyLevel(companyLevelsTDS);
                    companyLevel.Load(companyId);

                    // Store dataset
                    Session["ruleTDS"] = ruleTDS;
                    Session["categoriesTDSForChecklist"] = categoriesTDS;
                    Session["companyLevelsTDS"] = companyLevelsTDS;
                }

                // Load Data for current rule
                LoadData(ruleId);

                // Databind
                Page.DataBind();
            }
            else
            {
                // Restore datasets
                ruleTDS = (RuleTDS)Session["ruleTDS"];
                categoriesTDS = (CategoriesTDS)Session["categoriesTDSForChecklist"];
                companyLevelsTDS = (CompanyLevelsTDS)Session["companyLevelsTDS"];
            }
        }