protected void btnSaveAssist_Click(object sender, EventArgs e) { chsi.dat.CHSIEntities db = new chsi.dat.CHSIEntities(); int _assistId = 0; int _appId = 0; if (!String.IsNullOrEmpty(Request.QueryString["assistId"])) { string assistId = Request.QueryString["assistId"]; int.TryParse(assistId, out _assistId); } if (!String.IsNullOrEmpty(Request.QueryString["appId"])) { string appId = Request.QueryString["appId"]; int.TryParse(appId, out _appId); } if (_assistId == 0) { chsi.dat.acaAssists newAssist = new acaAssists(); newAssist.Notes = txtNotes.Text; newAssist.AssistDate = Convert.ToDateTime(txtDateOfEncounter.Text); newAssist.PrimaryApplicantId = _appId; newAssist.RegionId = Convert.ToInt32(ddlRegion.SelectedValue); newAssist.SiteId = Convert.ToInt32(ddlSite.SelectedValue); newAssist.AssistTypeId = Convert.ToInt32(ddlAssistType.SelectedValue); newAssist.RepresentativeId = Convert.ToInt32(ddlPSR.SelectedValue); if (ddlAssistType.SelectedValue == "7") newAssist.isSubmission = true; else newAssist.isSubmission = false; if (ddlAssistType.SelectedValue == "9") newAssist.isEnrolled = true; else newAssist.isEnrolled = false; db.acaAssists.AddObject(newAssist); db.SaveChanges(); } else { acaAssists assist = (from a in db.acaAssists where a.AssistId == _assistId select a).FirstOrDefault(); assist.Notes = txtNotes.Text; assist.AssistDate = Convert.ToDateTime(txtDateOfEncounter.Text); assist.RegionId = Convert.ToInt32(ddlRegion.SelectedValue); assist.SiteId = Convert.ToInt32(ddlSite.SelectedValue); assist.AssistTypeId = Convert.ToInt32(ddlAssistType.SelectedValue); assist.RepresentativeId = Convert.ToInt32(ddlPSR.SelectedValue); if (ddlAssistType.SelectedValue == "7") assist.isSubmission = true; else assist.isSubmission = false; if (ddlAssistType.SelectedValue == "9") assist.isEnrolled = true; else assist.isEnrolled = false; db.SaveChanges(); } foreach (RepeaterItem item in rptrFamily.Items) { HiddenField applicantId = (HiddenField)item.FindControl("hidApplicantId"); CheckBox submission = (CheckBox)item.FindControl("cbxSubmission"); CheckBox enrolled = (CheckBox)item.FindControl("cbxEnrolled"); CheckBox providerSelected = (CheckBox)item.FindControl("cbxProviderSelected"); DropDownList payer = (DropDownList)item.FindControl("ddlPayers"); DropDownList types = (DropDownList)item.FindControl("ddlTypes"); DropDownList tiers = (DropDownList)item.FindControl("ddlTiers"); DropDownList subTiers = (DropDownList)item.FindControl("ddlSubTiers"); int appId = Convert.ToInt32(applicantId.Value); //Save Applicant acaApplicants app = (from a in db.acaApplicants where a.ApplicantId == appId select a).FirstOrDefault(); app.IsEnrolled = enrolled.Checked; app.IsSubmission = submission.Checked; app.SelectedCHSIProvider = providerSelected.Checked; db.SaveChanges(); //Save health plan acaHealthPlans hp = (from h in db.acaHealthPlans where h.ApplicantId == appId select h).FirstOrDefault(); if (payer.SelectedIndex > 0) hp.PayerId = Convert.ToInt32(payer.SelectedValue); else hp.PayerId = null; if (types.SelectedIndex > 0) hp.PlanTypeId = Convert.ToInt32(types.SelectedValue); else hp.PlanTypeId = null; if (tiers.SelectedIndex > 0) hp.PlanTierId = Convert.ToInt32(tiers.SelectedValue); else hp.PlanTierId = null; if (subTiers.SelectedIndex > 0) hp.PlanSubTierId = Convert.ToInt32(subTiers.SelectedValue); else hp.PlanSubTierId = null; db.SaveChanges(); } //total assists for each assist record int totalAssistCount = db.acaAssists.Where(a => a.PrimaryApplicantId == _appId).Count(); int totalEnrolled = db.acaAssists.Where(a => a.AssistTypeId == 9 && a.PrimaryApplicantId == _appId).Count(); int totalSubmitted = db.acaAssists.Where(a => a.AssistTypeId == 7 && a.PrimaryApplicantId == _appId).Count(); int familyCount = db.acaApplicants.Where(a => a.PrimaryApplicantId == _appId || a.ApplicantId == _appId).Count(); var some = db.acaAssists.Where(a => a.PrimaryApplicantId == _appId).ToList(); some.ForEach(a => a.NumberAssisted = (totalAssistCount * familyCount)); some.ForEach(a => a.NumberEnrolled = (totalEnrolled)); some.ForEach(a => a.NumberSubmitted = (totalSubmitted)); db.SaveChanges(); Response.Redirect(string.Format("/aca/assists?appId={0}", _appId)); }
/// <summary> /// Deprecated Method for adding a new object to the acaAssists EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToacaAssists(acaAssists acaAssists) { base.AddObject("acaAssists", acaAssists); }
protected void btnSaveAssist_Click(object sender, EventArgs e) { chsi.dat.CHSIEntities db = new chsi.dat.CHSIEntities(); int _assistId = 0; int _appId = 0; _submissionId = int.Parse(ddlAssistType.Items.FindByText("Submitting application").Value); _enrolledId = int.Parse(ddlAssistType.Items.FindByText("Enrollment Confirmation, payment submitted").Value); if (!String.IsNullOrEmpty(Request.QueryString["assistId"])) { string assistId = Request.QueryString["assistId"]; int.TryParse(assistId, out _assistId); } if (!String.IsNullOrEmpty(Request.QueryString["appId"])) { string appId = Request.QueryString["appId"]; int.TryParse(appId, out _appId); } chsi.dat.acaAssists assist = new acaAssists(); if (_assistId > 0) { assist = (from a in db.acaAssists where a.AssistId == _assistId select a).FirstOrDefault(); } assist.Notes = txtNotes.Text; assist.AssistDate = Convert.ToDateTime(txtDateOfEncounter.Text); assist.PrimaryApplicantId = _appId; assist.RegionId = Convert.ToInt32(ddlRegion.SelectedValue); assist.SiteId = Convert.ToInt32(ddlSite.SelectedValue); assist.AssistTypeId = Convert.ToInt32(ddlAssistType.SelectedValue); assist.RepresentativeId = Convert.ToInt32(ddlPSR.SelectedValue); assist.isSubmission = (int.Parse(ddlAssistType.SelectedValue) == _submissionId); assist.isEnrolled = (int.Parse(ddlAssistType.SelectedValue) == _enrolledId); int familyCount = db.acaApplicants.Where(a => a.PrimaryApplicantId == _appId || a.ApplicantId == _appId).Count(); assist.NumberAssisted = familyCount; if (assist.isSubmission ) { //get previous totals int prevSubmitted = 0; int.TryParse(db.acaAssists.Where(a => a.AssistTypeId == _submissionId && a.PrimaryApplicantId == _appId).ToList().Select(a => a.NumberAssisted).Sum().ToString(), out prevSubmitted); int totalSubmitted = GetCount("cbxSubmission"); assist.NumberAssisted = Math.Abs(totalSubmitted - prevSubmitted); } if (assist.isEnrolled) { //get previous totals int prevEnrolled = 0; int.TryParse(db.acaAssists.Where(a => a.AssistTypeId == _enrolledId && a.PrimaryApplicantId == _appId).ToList().Select(a => a.NumberAssisted).Sum().ToString(), out prevEnrolled); int totalEnrolled = GetCount("cbxEnrolled"); assist.NumberAssisted = Math.Abs(totalEnrolled - prevEnrolled); } if (_assistId == 0) db.acaAssists.AddObject(assist); //only update health plans if this is an enrollment or submission if (assist.isEnrolled || assist.isSubmission) UpdateHealthPlans(); db.SaveChanges(); Response.Redirect(string.Format("/aca/assists?appId={0}", _appId)); }
/// <summary> /// Create a new acaAssists object. /// </summary> /// <param name="assistId">Initial value of the AssistId property.</param> /// <param name="representativeId">Initial value of the RepresentativeId property.</param> /// <param name="siteId">Initial value of the SiteId property.</param> /// <param name="assistTypeId">Initial value of the AssistTypeId property.</param> /// <param name="regionId">Initial value of the RegionId property.</param> /// <param name="assistDate">Initial value of the AssistDate property.</param> /// <param name="primaryApplicantId">Initial value of the PrimaryApplicantId property.</param> /// <param name="isSubmission">Initial value of the isSubmission property.</param> /// <param name="isEnrolled">Initial value of the isEnrolled property.</param> public static acaAssists CreateacaAssists(global::System.Int32 assistId, global::System.Int32 representativeId, global::System.Int32 siteId, global::System.Int32 assistTypeId, global::System.Int32 regionId, global::System.DateTime assistDate, global::System.Int32 primaryApplicantId, global::System.Boolean isSubmission, global::System.Boolean isEnrolled) { acaAssists acaAssists = new acaAssists(); acaAssists.AssistId = assistId; acaAssists.RepresentativeId = representativeId; acaAssists.SiteId = siteId; acaAssists.AssistTypeId = assistTypeId; acaAssists.RegionId = regionId; acaAssists.AssistDate = assistDate; acaAssists.PrimaryApplicantId = primaryApplicantId; acaAssists.isSubmission = isSubmission; acaAssists.isEnrolled = isEnrolled; return acaAssists; }