/// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            ToDoListInformationTDS toDoListInformationChanges = (ToDoListInformationTDS)Data.GetChanges();

            if (toDoListInformationChanges != null)
            {
                if (toDoListInformationChanges.BasicInformation.Rows.Count > 0)
                {
                    ToDoListInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new ToDoListInformationBasicInformationGateway(toDoListInformationChanges);

                    // Update to do
                    foreach (ToDoListInformationTDS.BasicInformationRow row in (ToDoListInformationTDS.BasicInformationDataTable)toDoListInformationChanges.BasicInformation)
                    {
                        // Unchanged values
                        int toDoId = row.ToDoID;
                        string subject = toDoListInformationBasicInformationGateway.GetSubject(toDoId);
                        DateTime creationDate = toDoListInformationBasicInformationGateway.GetCreationDate(toDoId);
                        int createdById = toDoListInformationBasicInformationGateway.GetCreatedByID(toDoId);

                        // Original values
                        DateTime? originalDueDate = null; if (toDoListInformationBasicInformationGateway.GetDueDateOriginal(toDoId).HasValue) originalDueDate = (DateTime)toDoListInformationBasicInformationGateway.GetDueDateOriginal(toDoId);
                        int? originalUnitId = null; if (toDoListInformationBasicInformationGateway.GetUnitIDOriginal(toDoId).HasValue) originalUnitId = (int)toDoListInformationBasicInformationGateway.GetUnitIDOriginal(toDoId);
                        string originalState = toDoListInformationBasicInformationGateway.GetStateOriginal(toDoId);

                        // New variables
                        DateTime? newDueDate = null; if (toDoListInformationBasicInformationGateway.GetDueDate(toDoId).HasValue) newDueDate = (DateTime)toDoListInformationBasicInformationGateway.GetDueDate(toDoId);
                        int? newUnitId = null; if (toDoListInformationBasicInformationGateway.GetUnitID(toDoId).HasValue) newUnitId = (int)toDoListInformationBasicInformationGateway.GetUnitID(toDoId);
                        string newState = toDoListInformationBasicInformationGateway.GetState(toDoId);

                        ToDoListToDoList toDoListToDoList = new ToDoListToDoList(null);
                        toDoListToDoList.UpdateDirect(toDoId, subject, creationDate, createdById, originalState, originalDueDate, originalUnitId, row.Deleted, row.COMPANY_ID, toDoId, subject, creationDate, createdById, newState, newDueDate, newUnitId, row.Deleted, row.COMPANY_ID);
                    }
                }
            }
        }
        private void LoadData(int toDoId)
        {
            ToDoListInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new ToDoListInformationBasicInformationGateway(toDoListInformationTDS);
            if (toDoListInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load to do Details
                int companyId = Int32.Parse(hdfCompanyId.Value);

                int createdById = toDoListInformationBasicInformationGateway.GetCreatedByID(toDoId);
                hdfCreatedById.Value = createdById.ToString();
                EmployeeGateway employeeGateway = new EmployeeGateway();
                employeeGateway.LoadByEmployeeId(createdById);
                tbxCreatedBy.Text = employeeGateway.GetFullName(createdById);

                tbxCreationDate.Text = toDoListInformationBasicInformationGateway.GetCreationDate(toDoId).ToString();
                tbxState.Text = toDoListInformationBasicInformationGateway.GetState(toDoId);

                if (toDoListInformationBasicInformationGateway.GetDueDate(toDoId).HasValue)
                {
                    DateTime dueDateValue = (DateTime)toDoListInformationBasicInformationGateway.GetDueDate(toDoId);
                    tbxDueDate.Text = dueDateValue.Month.ToString() + "/" + dueDateValue.Day.ToString() + "/" + dueDateValue.Year.ToString();
                }

                int? unitId = toDoListInformationBasicInformationGateway.GetUnitID(toDoId);
                tbxUnit.Text = "";
                if (unitId.HasValue)
                {
                    UnitsGateway unitsGateway = new UnitsGateway();
                    unitsGateway.LoadByUnitId((int)unitId, companyId);
                    tbxUnit.Text = unitsGateway.GetUnitCode((int)unitId) + " " + unitsGateway.GetDescription((int)unitId);
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_TODOLIST_VIEW"]) && Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_TODOLIST_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["toDo_id"] == null) || ((string)Request.QueryString["action"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in toDoList_activity.aspx");
                }

                // Tag Page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfToDoId.Value = Request.QueryString["toDo_id"].ToString();
                hdfAction.Value = Request.QueryString["action"].ToString();
                hdfDashboard.Value = Request.QueryString["dashboard"].ToString();

                // If coming from
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int currentToDoId = Int32.Parse(hdfToDoId.Value.ToString());

                Session.Remove("activityInformationDummy");

                // ... toDoList_navigator2.aspx
                if (Request.QueryString["source_page"] == "toDoList_navigator2.aspx")
                {
                    StoreNavigatorState();
                    toDoListInformationTDS = new ToDoListInformationTDS();
                    activityInformation = new ToDoListInformationTDS.ActivityInformationDataTable();

                    ToDoListInformationBasicInformation toDoListInformationBasicInformation = new ToDoListInformationBasicInformation(toDoListInformationTDS);
                    toDoListInformationBasicInformation.LoadAllByToDoId(currentToDoId, companyId);

                    ToDoListInformationBasicInformationGateway toDoListInformationBasicInformationGatewayForState = new ToDoListInformationBasicInformationGateway(toDoListInformationBasicInformation.Data);
                    string state = toDoListInformationBasicInformationGatewayForState.GetState(currentToDoId);
                    if (state == "Completed") hdfCompleted.Value = "True";

                    ToDoListInformationActivityInformation toDoListInformationActivityInformation = new ToDoListInformationActivityInformation(toDoListInformationTDS);
                    toDoListInformationActivityInformation.LoadAllByToDoId(currentToDoId, companyId);

                    // Store dataset
                    Session["toDoListInformationTDS"] = toDoListInformationTDS;
                    Session["activityInformation"] = activityInformation;
                }

                // ... toDoList_summary.aspx or toDoList_edit.aspx
                if ((Request.QueryString["source_page"] == "toDoList_summary.aspx") || (Request.QueryString["source_page"] == "toDoList_edit.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // Restore dataset
                    toDoListInformationTDS = (ToDoListInformationTDS)Session["toDoListInformationTDS"];
                    activityInformation = (ToDoListInformationTDS.ActivityInformationDataTable)Session["activityInformation"];

                    if (ViewState["update"].ToString().Trim() == "yes")
                    {
                        ToDoListInformationBasicInformation toDoListInformationBasicInformation = new ToDoListInformationBasicInformation(toDoListInformationTDS);
                        toDoListInformationBasicInformation.LoadAllByToDoId(currentToDoId, companyId);

                        ToDoListInformationBasicInformationGateway toDoListInformationBasicInformationGatewayForState = new ToDoListInformationBasicInformationGateway(toDoListInformationBasicInformation.Data);
                        string state = toDoListInformationBasicInformationGatewayForState.GetState(currentToDoId);
                        if (state == "Completed") hdfCompleted.Value = "True";

                        ToDoListInformationActivityInformation toDoListInformationActivityInformation = new ToDoListInformationActivityInformation(toDoListInformationTDS);
                        toDoListInformationActivityInformation.LoadAllByToDoId(currentToDoId, companyId);

                        // Store dataset
                        Session["toDoListInformationTDS"] = toDoListInformationTDS;
                        Session["activityInformation"] = activityInformation;
                    }
                }

                // Prepare initial data
                // ... for subject
                ToDoListInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new ToDoListInformationBasicInformationGateway();
                toDoListInformationBasicInformationGateway.LoadAllByToDoId(currentToDoId, companyId);
                lblTitleSubjectName.Text = " " + toDoListInformationBasicInformationGateway.GetSubject(currentToDoId);

                // ... Data for current to do list
                LoadToDoListData(currentToDoId, companyId);
            }
            else
            {
                // Restore datasets
                toDoListInformationTDS = (ToDoListInformationTDS)Session["toDoListInformationTDS"];
                activityInformation = (ToDoListInformationTDS.ActivityInformationDataTable)Session["activityInformation"];
            }
        }
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// LoadAllByToDoId
 /// </summary>
 /// <param name="toDoId">toDoId</param>              
 /// <param name="companyId">companyId</param>
 public void LoadAllByToDoId(int toDoId, int companyId)
 {
     ToDoListInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new ToDoListInformationBasicInformationGateway(Data);
     toDoListInformationBasicInformationGateway.LoadAllByToDoId(toDoId, companyId);
 }
        private void LoadData(int toDoId)
        {
            ToDoListInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new ToDoListInformationBasicInformationGateway(toDoListInformationTDS);
            if (toDoListInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load to do Details
                int companyId = Int32.Parse(hdfCompanyId.Value);

                int createdById = toDoListInformationBasicInformationGateway.GetCreatedByID(toDoId);
                EmployeeGateway employeeGateway = new EmployeeGateway();
                employeeGateway.LoadByEmployeeId(createdById);
                tbxCreatedBy.Text = employeeGateway.GetFullName(createdById);

                tbxCreationDate.Text = toDoListInformationBasicInformationGateway.GetCreationDate(toDoId).ToString();
                tbxState.Text = toDoListInformationBasicInformationGateway.GetState(toDoId);

                if (toDoListInformationBasicInformationGateway.GetDueDate(toDoId).HasValue)
                {
                    tkrdpDueDate.SelectedDate = (DateTime)toDoListInformationBasicInformationGateway.GetDueDate(toDoId);
                }

                int? unitId = toDoListInformationBasicInformationGateway.GetUnitID(toDoId);

                if (unitId.HasValue)
                {
                    ddlUnit.SelectedValue = unitId.ToString();
                }
            }
        }