BACKGROUND: I've been working on an asp.net website (barebones fake Client Management System) with C# code behind file and am building basic forms to insert new data and update existing data in a SQL database.
I have a table (PatientMedicalHistory) that contains 30+ checkboxes (not in a list) which are used to determine what "ailments" a patient indicated they had when we first create the new patient record via stored procedure. The data is stored as a combination primary key (PatientId int + AilmentId int) to avoid duplication. The potential Ailments are stored in another table (Ailments) that holds multiple combinations of AilmentId int and AilmentDescription varchar(50)
I probably should have used a different schema (bit columns for each ailment in 1 combined table) for this table but doing it this way leaves room for adding new "ailments" in the future.
PROBLEM: When using sqlcommand to pull a set of patient records from the PatientMedicalHistroy table based on PatientId I want to iterate through the list of currently selected records and check each corresponding checkbox accordingly.
CODE:
pIdstring = ("SELECT ailmentId FROM dbo.PatientMedicalHistory WHERE PatientId = " + pId.ToString());
cmd = new SqlCommand(pIdstring);
DataTable dt = new DataTable();
cmd.Connection = conn;
using (conn)
{
using (cmd)
{
conn.Open();
using (SqlDataReader drCbox = cmd.ExecuteReader())
{
dt.Load(drCbox);
//Need to check all checkboxes that are contained in this datatable.
}
}
}
}
HTML:
<fieldset class="auto-style93" style="background-image: url('Pictures/Bg_WhiteGrayGradient_Tall.jpg'); background-position: center; border-style: inset; border-width: medium">
<legend id="MedHistoryLegend" style="background-image: url('Pictures/Bg_WhiteGrayGradient_Tall.jpg'); border-style: inset; border-width: medium; font-family: 'Arial Black';">
<span class="auto-style194">MEDICAL HISTORY</span><asp:Button ID="EditHistory" runat="server" BackColor="White" BorderStyle="None" BorderWidth="0px" CssClass="auto-style189" Height="16px" Text="Edit" ToolTip="Edit Personal Information" OnClick="EditHistory_Click" />
</legend>
<table class="auto-style84" border="3">
<tr><td class="auto-style85">
<asp:CheckBox ID="AnemiaCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: Arial, Helvetica, sans-serif">Anemia</td>
<td class="auto-style39">
<asp:CheckBox ID="EmphysemaCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">Emphysema</td>
<td class="auto-style39">
<asp:CheckBox ID="HypoglycemiaCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">Hypoglycemia</td>
<td class="auto-style39">
<asp:CheckBox ID="ShinglesCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Shingles</td>
<td class="auto-style76">
<asp:CheckBox ID="UTICbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Urinary Tract Infection</td>
</tr>
<tr><td class="auto-style86">
<asp:CheckBox ID="ArthritisCbox" runat="server" Text=" " />
</td>
<td class="auto-style35" style="font-family: Arial, Helvetica, sans-serif">Arthritis</td>
<td class="auto-style31">
<asp:CheckBox ID="EpilepsyCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">Epilepsy or Seizures</td>
<td class="auto-style39">
<asp:CheckBox ID="IrregularHBCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">Irregular Heartbeat</td>
<td class="auto-style39">
<asp:CheckBox ID="SickleCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Sickle Cell Disease</td>
<td class="auto-style76">
<asp:CheckBox ID="JaundiceCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Yellow Jaundice</td>
</tr>
<tr><td class="auto-style86">
<asp:CheckBox ID="AsthmaCbox" runat="server" Text=" " />
</td>
<td class="auto-style35" style="font-family: Arial, Helvetica, sans-serif">Asthma</td>
<td class="auto-style31">
<asp:CheckBox ID="GlaucomaCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">Glaucoma</td>
<td class="auto-style39">
<asp:CheckBox ID="KidneyCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Kidney Problems</td>
<td class="auto-style76">
<asp:CheckBox ID="SinusCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Sinus Trouble</td>
<td class="auto-style76">
</td>
</tr>
<tr><td class="auto-style85">
<asp:CheckBox ID="CancerCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: Arial, Helvetica, sans-serif">Cancer</td>
<td class="auto-style39">
<asp:CheckBox ID="HeartAtkCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">Heart Attack</td>
<td class="auto-style39">
<asp:CheckBox ID="LeukemiaCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Leukemia</td>
<td class="auto-style76">
<asp:CheckBox ID="SpinaBifidaCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Spina Bifida</td>
<td class="auto-style76">
</td>
</tr>
<tr><td class="auto-style87">
<asp:CheckBox ID="ColdSoreCbox" runat="server" Text=" " />
</td>
<td class="auto-style36" style="font-family: Arial, Helvetica, sans-serif">Cold Sores/Fever Blisters</td>
<td class="auto-style33">
<asp:CheckBox ID="HeartMurmurCbox" runat="server" Text=" " />
</td>
<td class="auto-style62" style="font-family: arial, Helvetica, sans-serif">Heart Murmur</td>
<td class="auto-style65">
<asp:CheckBox ID="LiverCbox" runat="server" Text=" " />
</td>
<td class="auto-style30" style="font-family: arial, Helvetica, sans-serif">Liver Disease</td>
<td class="auto-style74">
<asp:CheckBox ID="StomachCbox" runat="server" Text=" " />
</td>
<td class="auto-style64" style="font-family: arial, Helvetica, sans-serif">Stomach/Intestinal Disease</td>
<td class="auto-style77">
</td>
</tr>
<tr><td class="auto-style88">
<asp:CheckBox ID="HeartDisorderCbox" runat="server" Text=" " />
</td>
<td class="auto-style122" style="font-family: Arial, Helvetica, sans-serif">Congenital Heart Disorder</td>
<td class="auto-style90">
<asp:CheckBox ID="HeartDiseaseCbox" runat="server" Text=" " />
</td>
<td class="auto-style122" style="font-family: arial, Helvetica, sans-serif">Heart Disease</td>
<td class="auto-style90">
<asp:CheckBox ID="JawPainCbox" runat="server" Text=" " />
</td>
<td class="auto-style124" style="font-family: arial, Helvetica, sans-serif">Pain in Jaw Joints</td>
<td class="auto-style92">
<asp:CheckBox ID="StrokeCbox" runat="server" Text=" " />
</td>
<td class="auto-style124" style="font-family: arial, Helvetica, sans-serif">Stroke</td>
<td class="auto-style92">
</td>
</tr>
<tr><td class="auto-style85">
<asp:CheckBox ID="DiabetesCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: Arial, Helvetica, sans-serif">Diabetes</td>
<td class="auto-style39">
<asp:CheckBox ID="HepACbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">Hepatitis A</td>
<td class="auto-style39">
<asp:CheckBox ID="ParathyroidCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Parathyroid Disease</td>
<td class="auto-style76">
<asp:CheckBox ID="ThyroidCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Thyroid Disease</td>
<td class="auto-style76">
</td>
</tr>
<tr><td class="auto-style85">
<asp:CheckBox ID="DigestiveCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: Arial, Helvetica, sans-serif">Digestive Disorders</td>
<td class="auto-style39">
<asp:CheckBox ID="HepBorCCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">Hepatitis B or C</td>
<td class="auto-style39">
<asp:CheckBox ID="PsychCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Psychiatric Care</td>
<td class="auto-style76">
<asp:CheckBox ID="TumorCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Tumors or Growths</td>
<td class="auto-style76">
</td>
</tr>
<tr><td class="auto-style85">
<asp:CheckBox ID="DrugCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: Arial, Helvetica, sans-serif">Drug Addiction</td>
<td class="auto-style39">
<asp:CheckBox ID="HBPCbox" runat="server" Text=" " />
</td>
<td class="auto-style121" style="font-family: arial, Helvetica, sans-serif">High Blood Pressure</td>
<td class="auto-style39">
<asp:CheckBox ID="RheumatismCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Rheumatism</td>
<td class="auto-style76">
<asp:CheckBox ID="UlcerCbox" runat="server" Text=" " />
</td>
<td class="auto-style123" style="font-family: arial, Helvetica, sans-serif">Ulcers</td>
<td class="auto-style76">
</td>
</tr>
</table>
</fieldset>
Aucun commentaire:
Enregistrer un commentaire