private void dgvReader_CellClick(object sender, DataGridViewCellEventArgs e) { if (this.dgvReader.SelectedRows.Count > 0) { if (this.dgvReader.SelectedRows[0].Cells[1].Value != null) { string sqltext3; long WORKERID = Convert.ToInt64(this.dgvReader.SelectedRows[0].Cells[2].Value); DataSet ds = new DataSet(); sqltext3 = string.Format("SELECT flaglist.FLAG,flaglist.FLAGID,rfesp.FLAG,rfesp.RFIDNUM,rfesp.WORKERID,rfesp.WORKERNAME,rfesp.SEX FROM rfesp INNER JOIN flaglist ON rfesp.FLAG = flaglist.FLAGID WHERE rfesp.WORKERID ={0}", WORKERID); ds = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, sqltext3, null); string workid = ds.Tables[0].Rows[0]["WORKERID"].ToString(); string rfidnumber = ds.Tables[0].Rows[0]["RFIDNUM"].ToString(); string workname = ds.Tables[0].Rows[0]["WORKERNAME"].ToString(); string sex = ds.Tables[0].Rows[0]["SEX"].ToString(); string flag = ds.Tables[0].Rows[0]["FLAG"].ToString(); // 显示窗体 Frn_person person = new Frn_person(); person.id = Convert.ToString(workid); person.rfid = Convert.ToString(rfidnumber); person.name = workname; person.xingbie = sex; person.flg = flag; person.Show(); } } }
//查找按钮 private void toolStripButton1_Click(object sender, EventArgs e) { string sqltext4; long studentnum; studentnum = long.Parse(WORKERIDtext.Text); DataSet ds = new DataSet(); sqltext4 = string.Format("SELECT flaglist.FLAG,rfesp.RFIDNUM,rfesp.WORKERID,rfesp.WORKERNAME,rfesp.SEX FROM rfesp INNER JOIN flaglist ON rfesp.FLAG = flaglist.FLAGID WHERE rfesp.WORKERID = {0}", studentnum); ds = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, sqltext4, null); string workid = ds.Tables[0].Rows[0]["WORKERID"].ToString(); string rfidnumber = ds.Tables[0].Rows[0]["RFIDNUM"].ToString(); string workname = ds.Tables[0].Rows[0]["WORKERNAME"].ToString(); string sex = ds.Tables[0].Rows[0]["SEX"].ToString(); string flag = ds.Tables[0].Rows[0]["FLAG"].ToString(); // 显示窗体 Frn_person person = new Frn_person(); person.id = Convert.ToString(workid); person.rfid = Convert.ToString(rfidnumber); person.name = workname; person.xingbie = sex; person.flg = flag; person.Show(); //清空 WORKERIDtext.Text = ""; }