protected void grdHotelCostsByClientProject_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Page.Validate("DataEditHotelByClientProject");
            if (Page.IsValid)
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int refId = Int32.Parse(((Label)grdHotelCostsByClientProject.Rows[e.RowIndex].FindControl("lblRefIdEditHotelByClientProject")).Text);
                DateTime date = (DateTime)((RadDatePicker)grdHotelCostsByClientProject.Rows[e.RowIndex].FindControl("tkrdpDateEditHotelByClientProject")).SelectedDate;

                int hotelId = Int32.Parse(((DropDownList)grdHotelCostsByClientProject.Rows[e.RowIndex].FindControl("ddlHotelEditHotelByClientProject")).Text);
                string name = ((DropDownList)grdHotelCostsByClientProject.Rows[e.RowIndex].FindControl("ddlHotelEditHotelByClientProject")).SelectedItem.Text;

                int projectId = Int32.Parse(((Label)grdHotelCostsByClientProject.Rows[e.RowIndex].FindControl("lblProjectIdEditHotelByClientProject")).Text);

                decimal rate = decimal.Round(decimal.Parse(((TextBox)grdHotelCostsByClientProject.Rows[e.RowIndex].FindControl("tbxRateEditHotelByClientProject")).Text), 2);
                decimal rateCad = 0;
                decimal rateUsd = 0;

                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(projectId);

                if (projectGateway.GetCountryID(projectId) == 1) //Canada
                {
                    rateCad = rate;
                }
                else
                {
                    rateUsd = rate;
                }

                string comment = ((TextBox)grdHotelCostsByClientProject.Rows[e.RowIndex].FindControl("tbxCommentEditHotelByClientProject")).Text;
                bool deleted = false;

                // Update Data
                ActualCostsAddHotelCosts actualCostsAddHotelCosts = new ActualCostsAddHotelCosts(actualCostsAddTDS);
                actualCostsAddHotelCosts.Update(projectId, refId, hotelId, date, rateCad, rateUsd, comment, deleted, companyId, name);

                // Store dataset
                Session.Remove("hotelCostsByClientProjectDummy");

                Session["actualCostsAddTDS"] = actualCostsAddTDS;
                Session["hotelCosts"] = actualCostsAddTDS.HotelCosts;

                hotelCosts = actualCostsAddTDS.HotelCosts;
            }
            else
            {
                e.Cancel = true;
            }
        }
        protected void grdHotelCostsByClientProject_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // Hotel Gridview, if the gridview is edition mode
            if (grdHotelCostsByClientProject.EditIndex >= 0)
            {
                grdHotelCostsByClientProject.UpdateRow(grdHotelCostsByClientProject.EditIndex, true);
            }

            // Delete Hotel
            int projectId = (int)e.Keys["ProjectID"];
            int refId = (int)e.Keys["RefID"];

            // Delete costs details
            ActualCostsAddHotelCosts actualCostsAddHotelCosts = new ActualCostsAddHotelCosts(actualCostsAddTDS);
            actualCostsAddHotelCosts.Delete(projectId, refId);

            // Store dataset
            Session.Remove("hotelCostsByClientProjectDummy");

            Session["actualCostsAddTDS"] = actualCostsAddTDS;
            Session["hotelCosts"] = actualCostsAddTDS.HotelCosts;

            hotelCosts = actualCostsAddTDS.HotelCosts;
        }
        protected void AddHotelCostsNewEmptyFix(GridView grdHotelCostsByClientProject)
        {
            if (grdHotelCostsByClientProject.Rows.Count == 0)
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);
                ActualCostsAddTDS.HotelCostsDataTable dt = new ActualCostsAddTDS.HotelCostsDataTable();
                dt.AddHotelCostsRow(-1, -1, DateTime.Now, -1, -1, "", false, companyId, false, "", 0, "", "", 1);
                Session["hotelCostsByClientProjectDummy"] = dt;

                grdHotelCostsByClientProject.DataBind();
            }

            // normally executes at all postbacks
            if (grdHotelCostsByClientProject.Rows.Count == 1)
            {
                ActualCostsAddTDS.HotelCostsDataTable dt = (ActualCostsAddTDS.HotelCostsDataTable)Session["hotelCostsByClientProjectDummy"];
                if (dt != null)
                {
                    grdHotelCostsByClientProject.Rows[0].Visible = false;
                    grdHotelCostsByClientProject.Rows[0].Controls.Clear();
                }
            }
        }
        private void grdHotelCostsByClientProjectDetailAdd()
        {
            if (FooterValidateHotelByClientProject())
            {
                Page.Validate("DataNewHotelByClientProject");
                if (Page.IsValid)
                {
                    int companyId = Int32.Parse(hdfCompanyId.Value);
                    DateTime date = (DateTime)((RadDatePicker)grdHotelCostsByClientProject.FooterRow.FindControl("tkrdpDateFooterHotelByClientProject")).SelectedDate;

                    int hotelId = Int32.Parse(((DropDownList)grdHotelCostsByClientProject.FooterRow.FindControl("ddlHotelFooterHotelByClientProject")).Text);
                    string name = ((DropDownList)grdHotelCostsByClientProject.FooterRow.FindControl("ddlHotelFooterHotelByClientProject")).SelectedItem.Text;

                    int clientId = Int32.Parse(((DropDownList)grdHotelCostsByClientProject.FooterRow.FindControl("ddlClientFooterHotelByClientProject")).SelectedValue);
                    string client = ((DropDownList)grdHotelCostsByClientProject.FooterRow.FindControl("ddlClientFooterHotelByClientProject")).SelectedItem.Text;

                    int projectId = Int32.Parse(((DropDownList)grdHotelCostsByClientProject.FooterRow.FindControl("ddlProjectFooterHotelByClientProject")).SelectedValue);
                    string project = ((DropDownList)grdHotelCostsByClientProject.FooterRow.FindControl("ddlProjectFooterHotelByClientProject")).SelectedItem.Text;

                    decimal rate = decimal.Round(decimal.Parse(((TextBox)grdHotelCostsByClientProject.FooterRow.FindControl("tbxRateFooterHotelByClientProject")).Text), 2);
                    string comment = ((TextBox)grdHotelCostsByClientProject.FooterRow.FindControl("tbxCommentFooterHotelByClientProject")).Text;
                    bool deleted = false;
                    bool inDatabase = false;
                    decimal rateCad = 0;
                    decimal rateUsd = 0;
                    ProjectGateway projectGateway = new ProjectGateway();
                    projectGateway.LoadByProjectId(projectId);

                    if (projectGateway.GetCountryID(projectId) == 1) //Canada
                    {
                        rateCad = rate;
                        rateUsd = rate;
                    }
                    else
                    {
                        rateCad = rate;
                        rateUsd = rate;
                    }

                    // Insert Data
                    ActualCostsAddHotelCosts actualCostsAddHotelCosts = new ActualCostsAddHotelCosts(actualCostsAddTDS);
                    actualCostsAddHotelCosts.Insert(projectId, hotelId, date, rateCad, rateUsd, comment, deleted, companyId, inDatabase, name, client, project, clientId);

                    // Store dataset
                    Session.Remove("hotelCostsByClientProjectDummy");

                    Session["actualCostsAddTDS"] = actualCostsAddTDS;
                    Session["hotelCosts"] = actualCostsAddTDS.HotelCosts;

                    hotelCosts = actualCostsAddTDS.HotelCosts;

                    grdHotelCostsByClientProject.DataBind();
                    grdHotelCostsByClientProject.PageIndex = grdHotelCostsByClientProject.PageCount - 1;
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        //  STEP4 - HOTEL COST BY CLIENT AND PROJECT - PUBLIC METHODS
        //
        public ActualCostsAddTDS.HotelCostsDataTable GetHotelDetailHotelByClientProject()
        {
            hotelCosts = (ActualCostsAddTDS.HotelCostsDataTable)Session["hotelCostsByClientProjectDummy"];
            if (hotelCosts == null)
            {
                hotelCosts = ((ActualCostsAddTDS.HotelCostsDataTable)Session["hotelCosts"]);
            }

            return hotelCosts;
        }