private void butView_Click(object sender, EventArgs e) { if (this.Tag.Equals(0))//如果是教师浏览模式 { int select_n = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) //循环遍历DataGridView控件中的每一行 { if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时 { //当该行处于选定状态时 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true) { select_n++; if (select_n < 2) { DataClass.Experiment.Experiment_ID_forTeahcer = dataGridView1.Rows[i].Cells[1].Value.ToString(); F_NewExperiment New = new F_NewExperiment(); New.MdiParent = this.MdiParent; New.WindowState = FormWindowState.Maximized; New.Text = "显示实验"; New.Tag = 1;//设置新窗体的tag值为1表示教师浏览模式 New.Show(); } else { MessageBox.Show("多选显示将只显示勾选的第一个", "提示"); break; } } } } } else { if (this.Tag.Equals(1))//如果是学生浏览模式 { int select_n = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) //循环遍历DataGridView控件中的每一行 { if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时 { //当该行处于选定状态时 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true) { select_n++; if (select_n < 2) { DataClass.Experiment.Experiment_ID_forStudent = dataGridView1.Rows[i].Cells[1].Value.ToString(); F_NewExperiment New = new F_NewExperiment(); New.MdiParent = this.MdiParent; New.WindowState = FormWindowState.Maximized; New.Text = "显示实验"; New.Tag = 3;//设置新窗体的tag值为3表示学生浏览模式 New.Show(); } else { MessageBox.Show("多选显示将只显示勾选的第一个", "提示"); break; } } } } } } }
private void butAmend_Click(object sender, EventArgs e) { int select_n = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) //循环遍历DataGridView控件中的每一行 { if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时 { //当该行处于选定状态时 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true) { select_n++; if (select_n < 2) { DataClass.Experiment.Experiment_ID_forTeahcer = dataGridView1.Rows[i].Cells[1].Value.ToString(); F_NewExperiment New = new F_NewExperiment(); New.MdiParent = this.MdiParent; New.WindowState = FormWindowState.Maximized; New.Text = "修改实验"; New.Tag = 2;//设置为教师修改模式 New.Show(); } else { MessageBox.Show("多选修改时将只打开您勾选的第一个实验", "提示"); } } } } }
private void butExperimentView_Click(object sender, EventArgs e) { //第一种方法全局变量法非常麻烦 //第种方法出错,说集合已改变无法遍历 /*foreach (Form f in Application.OpenForms) { if (f.Text == "查看实验详情") { f.Activate();//根据你要找的窗体的name匹配,假如已经打开刚激活它 } else { F_NewExperiment NE = new F_NewExperiment(); NE.Tag = 4;//学生观察实验内容模式 NE.Text = "查看实验详情"; NE.Show(); } }*/ //第三种方法,将此窗体设置为私有变量 //如果在申明时初始化则关闭后无法再打开,如果在点击是初始化则还是可以重复打开 //第四种办法 设置单独的bool型系统变量存放该窗体是否打开,虽然麻烦,但是高效 if (DataClass.MyMeans.IfExperimentView == false) { F_NewExperiment New = new F_NewExperiment(); New.Tag = 4;//学生在进行实验时观察实验内容模式 New.Text = "查看实验详情"; New.Show(); DataClass.MyMeans.IfExperimentView = true; } }
private void butView_Click(object sender, EventArgs e) { int select_n = 0; if (radioButtonESearch.Checked == true && (this.Tag.Equals(0) || this.Tag.Equals(1)))//教师浏览实验 { for (int i = 0; i < dataGridView1.Rows.Count; i++) //循环遍历DataGridView控件中的每一行 { if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时 { //当该行处于选定状态时 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true) { select_n++; if (select_n < 2) { DataClass.Experiment.Experiment_ID_forTeahcer = dataGridView1.Rows[i].Cells[1].Value.ToString(); F_NewExperiment New = new F_NewExperiment(); New.MdiParent = this.MdiParent; New.WindowState = FormWindowState.Maximized; New.Text = "显示实验"; New.Tag = 1;//设置新窗体的tag值为1表示教师浏览实验模式 New.Show(); } else { MessageBox.Show("多选查看时将只打开您勾选的第一个实验", "提示"); break; } } } } } else { if (radioButtonRSearch.Checked == true && (this.Tag.Equals(0) || this.Tag.Equals(1)))//教师浏览实验报告模式 { select_n = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) //循环遍历DataGridView控件中的每一行 { if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时 { //当该行处于选定状态时 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true) { select_n++; if (select_n < 2) { DataClass.Report.Report_ID_forTeacher = dataGridView1.Rows[i].Cells[1].Value.ToString(); DataClass.Experiment.Experiment_ID_forTeahcer = dataGridView1.Rows[i].Cells[2].Value.ToString(); DataClass.Student.Student_ID = dataGridView1.Rows[i].Cells[3].Value.ToString(); F_DoExperiment New = new F_DoExperiment(); New.MdiParent = this.MdiParent; New.WindowState = FormWindowState.Maximized; New.Text = "显示实验报告"; New.Tag = 3;//设置新窗体的tag值为3表示教师浏览实验报告模式 New.Show(); } else { MessageBox.Show("多选查看时将只打开您勾选的第一个实验", "提示"); break; } } } } } else { if (radioButtonESearch.Checked == true && (this.Tag.Equals(2) || this.Tag.Equals(3)))//学生浏览实验模式 { select_n = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) //循环遍历DataGridView控件中的每一行 { if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时 { //当该行处于选定状态时 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true) { select_n++; if (select_n < 2) { DataClass.Experiment.Experiment_ID_forStudent = dataGridView1.Rows[i].Cells[1].Value.ToString(); F_NewExperiment New = new F_NewExperiment(); New.MdiParent = this.MdiParent; New.WindowState = FormWindowState.Maximized; New.Text = "显示实验"; New.Tag = 4;//设置新窗体的tag值为4表示学生浏览实验模式 New.Show(); } else { MessageBox.Show("多选查看时将只打开您勾选的第一个实验", "提示"); break; } } } } } else { if (radioButtonRSearch.Checked == true && (this.Tag.Equals(2) || this.Tag.Equals(3)))//学生浏览实验报告模式 { select_n = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) //循环遍历DataGridView控件中的每一行 { if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时 { //当该行处于选定状态时 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true) { select_n++; if (select_n < 2) { DataClass.Report.Report_ID_forStudent = dataGridView1.Rows[i].Cells[1].Value.ToString(); DataClass.Experiment.Experiment_ID_forStudent = dataGridView1.Rows[i].Cells[2].Value.ToString(); F_DoExperiment New = new F_DoExperiment(); New.MdiParent = this.MdiParent; New.WindowState = FormWindowState.Maximized; New.Text = "显示实验报告"; New.Tag = 1;//设置新窗体的tag值为1表示学生浏览实验报告模式 New.Show(); } else { MessageBox.Show("多选查看时将只打开您勾选的第一个实验", "提示"); break; } } } } } } } } }
private void butDoExperiment_Click(object sender, EventArgs e) { int select_n = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) //循环遍历DataGridView控件中的每一行 { if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时 { //当该行处于选定状态时 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true) { select_n++; if (select_n < 2) { DataClass.Experiment.Experiment_ID_forStudent = dataGridView1.Rows[i].Cells[1].Value.ToString(); F_NewExperiment Do = new F_NewExperiment(); Do.MdiParent = this.MdiParent; Do.WindowState = FormWindowState.Maximized; Do.Tag = 3;//设置为学生做实验模式 Do.Text = "进行实验"; Do.Show(); } else { MessageBox.Show("多选批改时将只打开您勾选的第一个实验", "提示"); break; } } } } }
private void 新建实验ToolStripMenuItem_Click(object sender, EventArgs e) { if (checkchildfrm("F_NewExperiment") == false) { F_NewExperiment F_ER = new F_NewExperiment(); F_ER.MdiParent = this; F_ER.WindowState = FormWindowState.Maximized; F_ER.Text = "新建实验"; F_ER.Tag = 0;//设置窗体的tag值为0代表新建模式 F_ER.Show(); } }