// ////////////////////////////////////////////////////////////////////////
        //  PUBLIC METHODS
        //
        public TimesheetAllTDS.TIMESHEET_ALLDataTable GetTimesheets()
        {
            timesheetAll = (TimesheetAllTDS.TIMESHEET_ALLDataTable)Session["timesheetAllDummy"];
            if (timesheetAll == null)
            {
                timesheetAll = ((TimesheetAllTDS.TIMESHEET_ALLDataTable)Session["timesheetAll"]);
            }

            return timesheetAll;
        }
        protected void AddTimesheetNewEmptyFix(GridView grdTimesheetAll)
        {
            if (grdTimesheetAll.Rows.Count == 0)
            {
                TimesheetAllTDS.TIMESHEET_ALLDataTable dt = new TimesheetAllTDS.TIMESHEET_ALLDataTable();
                dt.AddTIMESHEET_ALLRow("", DateTime.Now, DateTime.Now, -1, false);
                Session["timesheetAllDummy"] = dt;

                grdTimesheetAll.DataBind();
            }

            // normally executes at all postbacks
            if (grdTimesheetAll.Rows.Count == 1)
            {
                TimesheetAllTDS.TIMESHEET_ALLDataTable dt = (TimesheetAllTDS.TIMESHEET_ALLDataTable)Session["timesheetAllDummy"];
                if (dt != null)
                {
                    grdTimesheetAll.Rows[0].Visible = false;
                    grdTimesheetAll.Rows[0].Controls.Clear();
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // 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_FULL_EDITING"]))
                {
                    if (Request.QueryString["others"] == "no")
                    {
                        if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]))
                        {
                            if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"]))
                            {
                                if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"]))
                                {
                                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]))
                        {
                            if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"]))
                            {
                                if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"]))
                                {
                                    if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_VIEW"]))
                                    {
                                        if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT"]))
                                        {
                                            if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"]))
                                            {
                                                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["others"] == null) && ((string)Request.QueryString["employee_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in timesheet_all.aspx");
                }

                // Tag page
                Session.Remove("timesheetAllDummy");

                // Initialize  variables
                lblError.Visible = false;

                ViewState["others"] = Request.QueryString["others"];
                if ((string)ViewState["others"] == "yes")
                {
                    ViewState["employee_id"] = int.Parse(Request.QueryString["employee_id"]);
                }
                else
                {
                    EmployeeGateway employeeGateway1 = new EmployeeGateway(new DataSet());
                    ViewState["employee_id"] = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));
                }
                System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader();
                ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString();

                // Prepare initial data for client
                // ... Title
                if ((string)ViewState["others"] == "no")
                {
                    lblTitle.Text = "All My Timesheets";
                }
                else
                {
                    EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
                    employeeGateway.LoadByEmployeeId((int)ViewState["employee_id"]);
                    lblTitle.Text = "All Timesheets For " + employeeGateway.GetFullName((int)ViewState["employee_id"]);
                }

                // Load data
                timesheetAllTDS = this.SubmitSearch();
                Session["timesheetAllTDS"] = timesheetAllTDS;
                timesheetAll = timesheetAllTDS.TIMESHEET_ALL;
                Session["timesheetAll"] = timesheetAll;
            }
            else
            {
                // Restore dataset
                timesheetAllTDS = (TimesheetAllTDS)Session["timesheetAllTDS"];
                timesheetAll = timesheetAllTDS.TIMESHEET_ALL;
                Session["timesheetAll"] = timesheetAll;
            }
        }