/// <summary> /// 搜索 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Search_Click(object sender, EventArgs e) { string content = tb_SearchContent.Text.Trim(); if (content.Length > 0) { try { _isAddRow = true; if (Tab3_Form.SubList != null && Tab3_Form.SubList.Count > 0) { //移除旧的搜索副卡内容 for (int i = dgv_ViceCardList.RowCount - 1; i >= Tab3_Form.SubList.Count; i--) { dgv_ViceCardList.Rows.RemoveAt(i); } } else { dgv_ViceCardList.Rows.Clear(); } //获取搜索的副卡 DataTable dt = Dal_AssociateCard.GetViceCard(content); if (dt.Rows.Count > 0) { //将副卡显示在列表中 for (int i = 0; i < dt.Rows.Count; i++) { object vicecardnumber = dt.Rows[i]["ViceCardNumber"]; if (Tab3_Form.SubList != null && Tab3_Form.SubList.Count > 0) { if (Tab3_Form.SubList.ContainsKey(vicecardnumber.ToString())) { continue; } } //验证当前副卡是否已经存在捆绑列表中 bool check = GetViceCardExists(vicecardnumber.ToString()); dgv_ViceCardList.Rows.Add(new object[] { check, vicecardnumber, string.Empty }); } } } catch (Exception ex) { CustomExceptionHandler.GetExceptionMessage(ex); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { _isAddRow = false; } } }