private void BindCountyRentsGrid()
        {
            dvNewCountyUnitRent.Visible = false;

            try
            {
                DataTable dt = FederalRentalAffordabilityData.GetCountyRentsList(cbActiveOnly.Checked);

                if (dt.Rows.Count > 0)
                {
                    dvCountyRentsGrid.Visible = true;
                    gvCountyRents.DataSource  = dt;
                    gvCountyRents.DataBind();
                }
                else
                {
                    dvCountyRentsGrid.Visible = false;
                    gvCountyRents.DataSource  = null;
                    gvCountyRents.DataBind();
                }
            }
            catch (Exception ex)
            {
                LogError(Pagename, "BindCountyRentsGrid", "", ex.Message);
            }
        }
        protected void btnAddUnitRent_Click(object sender, EventArgs e)
        {
            if (ddlUnitType.SelectedIndex == 0)
            {
                LogMessage("Select Unit Type");
                ddlUnitType.Focus();
                return;
            }

            if (txtLowRent.Text.Trim() == "")
            {
                LogMessage("Enter Low Rent");
                txtLowRent.Focus();
                return;
            }

            if (txtHighRent.Text.Trim() == "")
            {
                LogMessage("Enter High Rent");
                txtHighRent.Focus();
                return;
            }

            FederalRentalAffordabilityData.AddCountyUnitRent(DataUtils.GetInt(hfCountyRentId.Value), DataUtils.GetInt(ddlUnitType.SelectedValue.ToString()),
                                                             DataUtils.GetDecimal(txtHighRent.Text), DataUtils.GetDecimal(txtLowRent.Text));
            ClearCountyUnitRentForm();
            BindCountyUnitRentGrid();
            LogMessage("County Unit Rent Added Successfully");
        }
        protected void btnAddCountyRent_Click(object sender, EventArgs e)
        {
            if (ddlFedProgram.SelectedIndex == 0)
            {
                LogMessage("Select Fed Program");
                ddlFedProgram.Focus();
                return;
            }
            if (ddlCounty.SelectedIndex == 0)
            {
                LogMessage("Select County");
                ddlCounty.Focus();
                return;
            }
            if (txtStartDate.Text.Trim() == "")
            {
                LogMessage("Enter Start Date");
                txtStartDate.Focus();
                return;
            }
            else
            {
                if (!DataUtils.IsDateTime(txtStartDate.Text.Trim()))
                {
                    LogMessage("Enter Valid Start Date");
                    txtStartDate.Focus();
                    return;
                }
            }

            if (txtEndDate.Text.Trim() == "")
            {
                LogMessage("Enter End Date");
                txtEndDate.Focus();
                return;
            }
            else
            {
                if (!DataUtils.IsDateTime(txtEndDate.Text.Trim()))
                {
                    LogMessage("Enter Valid End Date");
                    txtEndDate.Focus();
                    return;
                }
            }

            FederalRentalAffordabilityData.AddCountyRent(DataUtils.GetInt(ddlFedProgram.SelectedValue.ToString()), DataUtils.GetInt(ddlCounty.SelectedValue.ToString()),
                                                         DataUtils.GetDate(txtStartDate.Text), DataUtils.GetDate(txtEndDate.Text));
            ClearCountyRentForm();
            BindGrids();
            LogMessage("County Rent Added Successfully");
        }
        protected void gvCountyUnitRent_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int rowIndex = e.RowIndex;

            int CountyUnitRentID = DataUtils.GetInt(((Label)gvCountyUnitRent.Rows[rowIndex].FindControl("lblCountyUnitRentID")).Text);
            //int UnitType = DataUtils.GetInt(((DropDownList)gvCountyUnitRent.Rows[rowIndex].FindControl("ddlUnitType")).SelectedValue.ToString());
            decimal LowRent     = DataUtils.GetDecimal(((TextBox)gvCountyUnitRent.Rows[rowIndex].FindControl("txtLowRent")).Text);
            decimal HighRent    = DataUtils.GetDecimal(((TextBox)gvCountyUnitRent.Rows[rowIndex].FindControl("txtHighRent")).Text);
            bool    RowIsActive = Convert.ToBoolean(((CheckBox)gvCountyUnitRent.Rows[rowIndex].FindControl("chkActive")).Checked);;

            FederalRentalAffordabilityData.UpdateCountyUnitRent(CountyUnitRentID, HighRent, LowRent, RowIsActive);

            gvCountyUnitRent.EditIndex = -1;

            BindCountyUnitRentGrid();

            LogMessage("County Unit Rent Updated successfully");
        }
        protected void gvCountyRents_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int rowIndex = e.RowIndex;

            int      CountyRentId = DataUtils.GetInt(((Label)gvCountyRents.Rows[rowIndex].FindControl("lblCountyRentId")).Text);
            int      FedProgram   = DataUtils.GetInt(((DropDownList)gvCountyRents.Rows[rowIndex].FindControl("ddlFedProgram")).SelectedValue.ToString());
            int      County       = DataUtils.GetInt(((DropDownList)gvCountyRents.Rows[rowIndex].FindControl("ddlCounty")).SelectedValue.ToString());
            DateTime StartDate    = DataUtils.GetDate(((TextBox)gvCountyRents.Rows[rowIndex].FindControl("txtStartDate")).Text);
            DateTime EndDate      = DataUtils.GetDate(((TextBox)gvCountyRents.Rows[rowIndex].FindControl("txtEndDate")).Text);
            bool     RowIsActive  = Convert.ToBoolean(((CheckBox)gvCountyRents.Rows[rowIndex].FindControl("chkActive")).Checked);;

            FederalRentalAffordabilityData.UpdateCountyRent(CountyRentId, FedProgram, County, StartDate, EndDate, RowIsActive);

            gvCountyRents.EditIndex = -1;

            BindCountyRentsGrid();

            LogMessage("County Rent Updated successfully");
        }