protected void grdCompaniesSetup_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // Delete subcontractor
            int companiesId = (int)e.Keys["COMPANIES_ID"];
            DateTime date = (DateTime)e.Keys["Date"];

            HotelsSetupHotelsSetup model = new HotelsSetupHotelsSetup(hotelsSetupTDS);
            model.Delete(companiesId, date);

            // Store dataset
            Session["hotelsSetupTDS"] = hotelsSetupTDS;
            Session["hotelsSetupTable"] = hotelsSetupTDS.HotelsSetup;
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_RESOURCES_HOTELS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_RESOURCES_HOTELS_EDIT"]))  && Convert.ToBoolean(Session["sgLFS_RESOURCES_HOTELS_DELETE"]))
                {
                    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 hotels_navigator.aspx");
                }

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

                // Prepare initial data
                Session.Remove("hotelsSetupTableDummy");
                tdNoResults.Visible = false;

                // If coming from
                // ... Left Menu or select_project
                if (Request.QueryString["source_page"] == "out")
                {
                    // Load
                    hotelsSetupTDS = new HotelsSetupTDS();

                    HotelsSetupHotelsSetup model = new HotelsSetupHotelsSetup(hotelsSetupTDS);
                    int companyId = Int32.Parse(hdfCompanyId.Value);
                    model.LoadAll(companyId);

                    // Check if there is data
                    HotelsSetupHotelsSetup modelForMessage = new HotelsSetupHotelsSetup(hotelsSetupTDS);
                    modelForMessage.Load(companyId);

                    if (modelForMessage.Table.Rows.Count > 0)
                    {
                        tdNoResults.Visible = false;
                    }
                    else
                    {
                        tdNoResults.Visible = true;
                    }

                    // Store tables
                    Session["hotelsSetupTDS"] = hotelsSetupTDS;
                    Session["hotelsSetupTable"] = hotelsSetupTDS.HotelsSetup;
                }
            }
            else
            {
                // Restore datasets
                hotelsSetupTDS = (HotelsSetupTDS)Session["hotelsSetupTDS"];
                Session["hotelsSetupTable"] = hotelsSetupTDS.HotelsSetup;
            }
        }
        private void UpdateDatabase()
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);

            DB.Open();
            DB.BeginTransaction();
            try
            {
                // Save hotels
                HotelsSetupHotelsSetup hotelsSetupHotelsSetup = new HotelsSetupHotelsSetup(hotelsSetupTDS);
                hotelsSetupHotelsSetup.Save(companyId);

                DB.CommitTransaction();

                // Store datasets
                hotelsSetupTDS.AcceptChanges();
                Session["hotelsSetupTDS"] = hotelsSetupTDS;
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }