Ejemplo n.º 1
0
      public void setStaff_idAndBasis(int a)  //查询员工表和部门表
      {
          string sql  = "SELECT staff_info.id ,staff_info.name,basis FROM staff_info,department_info WHERE staff_info.department_id=department_info.id";
          string sql1 = "SELECT staff_info.id ,staff_info.name,basis FROM staff_info,department_info WHERE staff_info.department_id=department_info.id and  staff_info.id=@id";
          Dictionary <string, Object> dic = new Dictionary <string, Object>();

          dic.Add("@id", wa.getStaff_id());
          ArrayList al = new ArrayList();

          if (a == 0)
          {
              al = sqlHelper.SelectInfo(sql, dic);
              if (al != null && al.Count > 0)  //判断是有该数据
              {
                  foreach (Object[] obj in al)
                  {     //得到几行数据就能产生多少个对象
                      comboBox2.Items.Add(new ComboxItem((string)obj[1], (int)obj[0]));
                      list.Add(obj[2]);
                  }
              }
              else
              {
                  MessageBox.Show("先添加部门 ", "提示");
              }
          }
          else if (a == 1)
          {
              al = sqlHelper.SelectInfo(sql1, dic);
              if (al != null && al.Count > 0)  //判断是有该数据
              {
                  foreach (Object[] obj in al)
                  {     //得到几行数据就能产生多少个对象
                      textBox5.Text = (string)obj[1];
                      textBox1.Text = obj[2].ToString();
                  }
              }
              else
              {
                  MessageBox.Show("先添加员工 ", "提示");
              }
          }
      }