private void LoadBasicData(int projectId, int refId)
        {
            RevenueInformationBasicInformationGateway revenueInformationBasicInformationGateway = new RevenueInformationBasicInformationGateway(revenueInformationTDS);
            if (revenueInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load employee basic data
                tbxClient.Text = revenueInformationBasicInformationGateway.GetClient(projectId, refId);
                tbxProject.Text = revenueInformationBasicInformationGateway.GetProject(projectId, refId);
                tbxDate.Text = revenueInformationBasicInformationGateway.GetDate(projectId, refId).ToShortDateString();
                tbxRevenue.Text = decimal.Round(revenueInformationBasicInformationGateway.GetRevenue(projectId, refId), 2).ToString();
                tbxComments.Text = revenueInformationBasicInformationGateway.GetComment(projectId, refId);

                string money = "";

                // Load the money
                if (revenueInformationBasicInformationGateway.GetCountryId(projectId, refId) == 1) // Canada
                {
                    lblRevenue.Text = "Revenue (CAD)";
                    money = " (CAD)";
                }
                else
                {
                    lblRevenue.Text = "Revenue (USD)";
                    money = " (USD)";
                }

                lblTitleRevenue.Text = "Revenue: " + tbxRevenue.Text + money + " (" + tbxDate.Text + ")";
            }
        }
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            RevenueInformationTDS revenueInformationChanges = (RevenueInformationTDS)Data.GetChanges();

            if (revenueInformationChanges.BasicInformation.Rows.Count > 0)
            {
                RevenueInformationBasicInformationGateway revenueBasicInformationGateway = new RevenueInformationBasicInformationGateway(revenueInformationChanges);

                // Update revneue
                foreach (RevenueInformationTDS.BasicInformationRow row in (RevenueInformationTDS.BasicInformationDataTable)revenueInformationChanges.BasicInformation)
                {
                    // Insert new revenue
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        string comment = ""; if (!row.IsCommentNull()) comment = row.Comment;

                        ProjectRevenue projectRevenue = new ProjectRevenue(null);
                        projectRevenue.InsertDirect(row.ProjectID, row.RefID, row.Date, row.Revenue, comment, row.Deleted, row.COMPANY_ID);
                    }

                    // Update revenue
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int projectId = row.ProjectID;
                        int refId = row.RefID;
                        bool originalDeleted = false;
                        int originalCompanyId = companyId;

                        // Original values
                        DateTime originalDate = revenueBasicInformationGateway.GetDateOriginal(projectId, refId);
                        decimal originalRevenue = revenueBasicInformationGateway.GetRevenueOriginal(projectId, refId);
                        string originalComment = revenueBasicInformationGateway.GetCommentOriginal(projectId, refId);

                        // New values
                        DateTime newDate = revenueBasicInformationGateway.GetDate(projectId, refId);
                        decimal newRevenue = revenueBasicInformationGateway.GetRevenue(projectId, refId);
                        string newComment = revenueBasicInformationGateway.GetComment(projectId, refId);

                        ProjectRevenue projectRevenue = new ProjectRevenue(null);
                        projectRevenue.UpdateDirect(projectId, refId, originalDate, originalRevenue, originalComment, originalDeleted, originalCompanyId, projectId, refId, newDate, newRevenue, newComment, originalDeleted, originalCompanyId);
                    }

                    // Delete revenue
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        ProjectRevenue projectRevenue = new ProjectRevenue(null);
                        projectRevenue.DeleteDirect(row.ProjectID, row.RefID, row.COMPANY_ID);
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

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

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfCurrentProjectId.Value = Request.QueryString["project_id"];
                hdfCurrentRefId.Value = Request.QueryString["ref_id"];

                // ... for team member title
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int projectId = Int32.Parse(hdfCurrentProjectId.Value);
                int refId = Int32.Parse(hdfCurrentRefId.Value);

                RevenueInformationBasicInformationGateway revenueInformationBasicInformationGatewayForTitle = new RevenueInformationBasicInformationGateway();
                revenueInformationBasicInformationGatewayForTitle.LoadByProjectIdRefId(projectId, refId, companyId);
                decimal revenue = decimal.Round(revenueInformationBasicInformationGatewayForTitle.GetRevenue(projectId, refId), 2);
                string money = "";
                if (revenueInformationBasicInformationGatewayForTitle.GetCountryId(projectId, refId) == 1) // Canada
                {
                    money = " (CAD)";
                }
                else
                {
                    money = " (USD)";
                }

                lblTitleRevenue.Text = "Revenue: " + revenue + money + " (" + revenueInformationBasicInformationGatewayForTitle.GetDate(projectId, refId).ToShortDateString() + ")";

                // If coming from
                // ... revenue_navigator2.aspx
                if (Request.QueryString["source_page"] == "revenue_navigator2.aspx")
                {
                    revenueInformationTDS = new RevenueInformationTDS();
                    RevenueInformationBasicInformation revenueInformationBasicInformationForEdit = new RevenueInformationBasicInformation(revenueInformationTDS);
                    revenueInformationBasicInformationForEdit.LoadByProjectIdRefId(projectId, refId, companyId);

                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    // Store dataset
                    Session["revenueInformationTDS"] = revenueInformationTDS;
                }

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

                    // Restore dataset
                    revenueInformationTDS = (RevenueInformationTDS)Session["revenueInformationTDS"];
                }
            }
            else
            {
                // Restore dataset
                revenueInformationTDS = (RevenueInformationTDS)Session["revenueInformationTDS"];
            }
        }