public void selectAllIsId(int id) { string sql1 = "select * from wage_info where id=@id "; Dictionary <string, Object> dic = new Dictionary <string, Object>(); dic.Add("@id", wa.getId()); ArrayList al = new ArrayList(); al = sqlHelper.SelectInfo(sql1, dic); if (al != null && al.Count > 0) //判断是有该数据 { foreach (Object[] obj in al) { //得到几行数据就能产生多少个对象 wa.setId((int)obj[0]); wa.setStaff_id((int)obj[1]); wa.setBasis((int)obj[2]); wa.setAttendance((int)obj[3]); wa.setPeformance((int)obj[4]); wa.setOther((int)obj[5]); wa.setReason((string)obj[6]); wa.setTotal((int)obj[7]); wa.setTime((DateTime)obj[8]); } comboBox1.Text = Convert.ToString(wa.getId()); textBox2.Text = Convert.ToString(wa.getAttendance()); textBox3.Text = Convert.ToString(wa.getPeformance()); textBox4.Text = Convert.ToString(wa.getOther()); textBox6.Text = Convert.ToString(wa.getReason()); label10.Text = Convert.ToString(wa.getTotal()); label9.Text = wa.getTime(); foreach (ComboxItem c in comboBox2.Items) { if (c.Values == st.getDepartment_id()) { comboBox2.Text = c.Text; break; } } if (sql2 == null) { sql2 = "select id from wage_info "; al = sqlHelper.SelectInfo(sql2, dic); if (al != null && al.Count > 0) { foreach (Object[] obj in al) { //得到几行数据就能产生多少个对象 comboBox1.Items.Add((int)obj[0]); } } else { MessageBox.Show("没有数据,请添加!", "提示"); } } } else { MessageBox.Show("该员工可能已被删除!", "提示"); gl.myclos(); sql2 = null; comboBox1.Items.Clear(); comboBox2.Items.Clear(); } }