/// <summary> /// Binds data to the grid. /// </summary> /// <returns></returns> private DataTable BindGridData() { DataTable FoundReports = null; string StateFipCode = LookupBLL.GetStateFipsCodeByShortName(ddlStates.SelectedValue); if (cmbYear.SelectedIndex == 0) { FoundReports = Logic.GetResourceReportByStateFipCode(StateFipCode, -1); } else { FoundReports = Logic.GetResourceReportByStateFipCode(StateFipCode, int.Parse(cmbYear.SelectedItem.Text)); } if (FoundReports.Rows.Count > 0) { lblRecordCount.Text = "Most recent 100 RR Forms"; lblRecordCount.Visible = true; } else { lblRecordCount.Text = string.Empty; lblRecordCount.Visible = false; } dataSourceViewResourceReports.DataSource = FoundReports; dataSourceViewResourceReports.DataBind(); grdReports.DataSource = FoundReports; grdReports.DataBind(); return(FoundReports); }
/// <summary> /// Called when page is loaded. /// </summary> protected void OnViewLoaded() { TextBox ctrlName = (TextBox)formViewResourceReport.FindControl("txtPersonCompletingReport"); ctrlName.Text = prof.FirstName + " " + prof.LastName; TextBox ctrlPhone = (TextBox)formViewResourceReport.FindControl("txtTelephone"); ctrlPhone.Text = prof.PrimaryPhone; TextBox ctrlStateCode = (TextBox)formViewResourceReport.FindControl("txtStateCode"); AgencyBLL StatesInfo = new AgencyBLL(); IEnumerable StateValues = StatesInfo.GetStates(); foreach (System.Collections.Generic.KeyValuePair <string, string> StateValueFound in StateValues) { if (StateValueFound.Value == Session["RR_SELECTED_STATE"].ToString()) { ctrlStateCode.Text = StateValueFound.Key; break; } } ctrlStateCode.Text = LookupBLL.GetStateFipsCodeByShortName(ctrlStateCode.Text); ctrlStateCode.Enabled = false; ctrlPhone.Enabled = false; }
protected void btnNew_Click(object sender, EventArgs e) { DataTable FoundExistingReport = null; ResourceReportBLL rpt = new ResourceReportBLL(); //If this is a state admin get the state they are admin for //and use it. if (AccountInfo.IsStateAdmin) { if (cmbYear.SelectedIndex == 0) { msgFeedBack.Text = "You must select a year to create a resource report"; msgFeedBack.Visible = true; return; } FoundExistingReport = rpt.GetResourceReportByStateFipCode(AccountInfo.StateFIPS, int.Parse(cmbYear.SelectedItem.Text)); } else { //Store the selected state in a session so the Add Resource Report Form knows //The state that should be pre-selected. if (ddlStates.SelectedIndex == 0 || cmbYear.SelectedIndex == 0) { msgFeedBack.Text = "You must select a state and year to create a resource report"; msgFeedBack.Visible = true; return; } FoundExistingReport = rpt.GetResourceReportByStateFipCode(LookupBLL.GetStateFipsCodeByShortName(ddlStates.SelectedValue), int.Parse(cmbYear.SelectedItem.Text)); } if (FoundExistingReport.Rows.Count > 0) { msgFeedBack.Text = "Report already created for selected state and year."; msgFeedBack.Visible = true; return; } Session.Add("RR_SELECTED_STATE", ddlStates.SelectedItem.Text); Session.Add("RR_SELECTED_YEAR", cmbYear.SelectedItem.Text); RouteController.RouteTo(RouteController.ResourceReportAdd(0)); }