0
我有兩個函數具有返回裝運區域的查詢。一個返回一個飛行員認證區域和A點和B點之間的其他返回區域。我想比較它們並選擇匹配區域的複選框。這是我的。Copare功能和在複選框列表中選擇相同項目的項目
private void getAreaText(string PilotID)
{
SqlConnection sqlCN;
SqlCommand sqlCOM;
SqlDataReader sqlDR;
DateTime dato;
string strCOM = ConfigurationManager.AppSettings["database"];
sqlCN = new SqlConnection(strCOM);
try
{
sqlCN.Open();
sqlCOM = new SqlCommand("select f_AreaText, f_DateOfIssue from v_GetAreaText where f_PilotID='" + PilotID + "'", sqlCN);
sqlDR = sqlCOM.ExecuteReader();
CheckBoxList1.Items.Clear();
while (sqlDR.Read())
{
dato = sqlDR.GetDateTime(1);
dato = dato.AddYears(1);
if (DateTime.Now < dato)
CheckBoxList1.Items.Add(sqlDR.GetString(0));
if (CheckBoxList1.Items.Contains(findAreas(Session["PilotID"].ToString)))
{
CheckBoxList1.Items[i].Selected = true;
}
}
sqlDR.Close();
}
catch (DataException ex)
{
Response.Write(ex.ToString());
}
finally
{
sqlCN.Close();
sqlDR = null;
sqlCOM = null;
sqlCN = null;
}
return;
}
protected void findAreas(string PilotID)
{
SqlConnection sqlCN;
SqlCommand sqlCOM;
SqlDataReader sqlDR;
string strCOM = ConfigurationManager.AppSettings["database"];
sqlCN = new SqlConnection(strCOM);
try
{
sqlCN.Open();
sqlCOM = new SqlCommand("select DISTINCT f_AreaText from v_FindAreas where f_PilotID='" + PilotID + "'and f_SailedFrom='" + getLMFromList(FromList) + "'and f_SailedTo='" + getLMFromList(ToList) + "'", sqlCN);
sqlDR = sqlCOM.ExecuteReader();
CheckBoxList1.Items.Clear();
while (sqlDR.Read())
{
CheckBoxList1.Items.Add(sqlDR.GetString(0));
}
sqlDR.Close();
}
catch (DataException ex)
{
Response.Write(ex.ToString());
}
finally
{
sqlCN.Close();
sqlDR = null;
sqlCOM = null;
sqlCN = null;
}
return;
}
您有問題要問? – acfrancis
我想弄清楚如何選擇從兩個函數返回的值相同的複選框。 –
什麼不行? – acfrancis