Exemplo n.º 1
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            Landed load = new Landed();

            load.Owner = this;
            load.Show();

            //动态生成按钮
            for (int i = 0; i < 20; i++)
            {
                btn[i]           = new Button();
                btn[i].Width     = 75;
                btn[i].Height    = 30;
                btn[i].Top       = 30 * (i / 10) + 400;
                btn[i].Left      = 75 * (i % 10) + 22;
                btn[i].Text      = "第" + (i + 1) + "题";
                btn[i].Tag       = i.ToString();
                btn[i].Click    += btn_Click;
                btn[i].BackColor = Color.Red;
                this.Controls.Add(btn[i]);
            }

            //获取题目
            dt = SQLTools.getDT();
            //默认加载第一题(第一个按钮)
            btn_Click(btn[0], e);
            //题目装载
            for (int i = 0; i < 20; i++)
            {
                DataRow dr = data.NewRow();
                dr["ID"] = dt.Rows[i][0];
                data.Rows.Add(dr);
            }
        }
Exemplo n.º 2
0
 //点击附加查询
 private void button6_Click(object sender, EventArgs e)
 {
     //单选框是否被选中
     if (radioButton1.Checked)
     {
         DataTable dt = SQLTools.findData("' or 1=1;--");
         addGrid(dt);
     }
     else if (checkBox1.Checked && checkBox2.Checked)
     {
         DataTable dt = SQLTools.getDT(comboBox3.SelectedItem.ToString(), comboBox2.SelectedItem.ToString());
         addGrid(dt);
     }
     else if (checkBox2.Checked) //只有专业被选中
     {
         DataTable dt = SQLTools.getDT(comboBox3.SelectedItem.ToString(), "");
         addGrid(dt);
     }
     else //系部被选中
     {
         DataTable dt = SQLTools.getDT("", comboBox2.SelectedItem.ToString());
         addGrid(dt);
     }
 }