//绑定 private void button3_Click(object sender, EventArgs e) { try { if (dataGridView3.SelectedRows.Count > 0) { DataSet1.PadReaderDataRow ReaderRow = (dataGridView3.SelectedRows[0].DataBoundItem as DataRowView).Row as DataSet1.PadReaderDataRow; Int32 index = dataGridView3.SelectedRows[0].Index;//选中的第一条索引 if (BarCode.Length > 1 && DS.isBarCodeExist(BarCode) == 0) { if (SeqKind == 1) { if (DS.SaveBundInfo(ReaderRow.guid, BarCode, ReaderRow.ST_KIND) == true) { // MessageBox.Show(" 绑定成功"); lbMsg.Text = "绑定成功"; lbMsg.ForeColor = Color.Green; label5.Visible = false; DS.GetPadReaderData(-1); dataGridView3.ClearSelection(); dataGridView3.Rows[index].Selected = true; } } else if (SeqKind == 4) { if (DS.SaveBundInfo(ReaderRow.guid, BarCode, ReaderRow.ST_KIND) && DS.SetDateTime(BarCode)) { // MessageBox.Show(" 绑定成功"); lbMsg.Text = "绑定成功"; lbMsg.ForeColor = Color.Green; label5.Visible = false; DS.GetPadReaderData(Convert.ToInt32(lid)); dataGridView3.ClearSelection(); dataGridView3.Rows[index].Selected = true; } } } else { lbMsg.Text = "条码无效或条码重复"; lbMsg.ForeColor = Color.Red; } } else { // MessageBox.Show("请选择要绑定的芯"); lbMsg.Text = "请选择要绑定的芯!!"; lbMsg.ForeColor = Color.Red; } } catch (Exception ex) { MessageBox.Show("绑定ERROR:" + ex.ToString()); } //break; }