/// <summary> /// Deletes a "Biostatistician" (QHS Faculty/Staff) row with percentage/fee/year/note information. /// </summary> /// <param name="grantBiostatId">Given Biostat (QHS Faculty/Staff) ID.</param> internal void DeleteGrantBiostatById(int grantBiostatId) { using (ProjectTrackerContainer db = new ProjectTrackerContainer()) { GrantBiostat gb = db.GrantBiostats.FirstOrDefault(i => i.Id == grantBiostatId); if (gb != null) { db.GrantBiostats.Remove(gb); db.SaveChanges(); } } }
/// <summary> /// Obtains list of Biostatisticians (QHS faculty/staff) corresponding to the grant based on the /// grant ID specified. /// </summary> /// <param name="grantId">Referred Grant ID.</param> /// <returns>List of Biostatisticians (QHS faculty/staff) corresponding to grant.</returns> private List <GrantBiostat> GetGrantBiostat(int grantId) { List <GrantBiostat> lstBiostat = new List <GrantBiostat>(); foreach (GridViewRow row in GridViewBiostat.Rows) { if (row.RowType == DataControlRowType.DataRow) { DropDownList ddl = row.FindControl("ddlBiostats") as DropDownList; Label lblId = row.FindControl("lblId") as Label; TextBox txtPct = row.FindControl("TextBoxPct") as TextBox; TextBox txtFee = row.FindControl("TextBoxFee") as TextBox; TextBox txtNote = row.FindControl("TextBoxNote") as TextBox; TextBox txtYear = row.FindControl("TextBoxYear") as TextBox; int biostatId = 0; int output = 0; decimal outPct = 0.0m; if (ddl != null && txtPct != null && txtFee != null && txtNote != null) { Int32.TryParse(ddl.SelectedValue, out biostatId); if (biostatId != 0) { GrantBiostat biostat = new GrantBiostat() { Id = int.TryParse(lblId.Text, out output) ? output : -1, GrantId = grantId, BiostatId = biostatId, Pct = decimal.TryParse(txtPct.Text, out outPct) ? outPct : default(decimal?), Fee = int.TryParse(txtFee.Text, out output) ? output : default(int?), Year = txtYear.Text, Note = txtNote.Text, Creator = Creator, CreateDate = DateTime.Now }; lstBiostat.Add(biostat); } } } } return(lstBiostat); }