//实现右键删除选中选择题的功能 private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { int MMid = Convert.ToInt32(dataGridView1.SelectedCells[0].Value); //获取选择试题的ID值 string sql = "delete from TestInfo where ID=" + MMid + ""; //声明SQL语句用于删除 DataClass.OperaData(sql); //调用DeleteData方法 Admin_Load(sender, e); //刷新当前窗体 }
//实现右键删除考生信息的功能 private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { string MMid = dataGridView1.SelectedCells[0].Value.ToString(); //获取考生姓名 OleDbConnection con = DataClass.DBCon(); con.Open(); OleDbCommand com = new OleDbCommand("delete * from ExamResult where userName='******'", con); com.ExecuteNonQuery(); //如果该考生有成绩记录,则一起删除 con.Close(); string sql = "delete * from UserInfo where userName='******' "; //声明SQL语句用于删除 DataClass.OperaData(sql); //调用DeleteData方法 StuManage_Load(sender, e); //刷新当前窗体 }
//提交按钮 private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("请输入旧密码!"); } if (textBox1.Text.Trim() != ComVal.userPwd) { MessageBox.Show("密码错误!"); } if (textBox1.Text.Trim() == ComVal.userPwd) { string strAlt = "update UserInfo set userPwd='" + textBox2.Text + "' where userAcc='" + ComVal.userAcc + "'"; DataClass.OperaData(strAlt); ComVal.userPwd = textBox2.Text; this.Close(); } }
//”提交“按钮 private void button1_Click(object sender, EventArgs e) { int isTe; if (textBox1.Text == "" || textBox2.Text == "" || comboBox2.Text == "" || comboBox1.Text == "") { MessageBox.Show("请输入完整信息!"); } else { if (comboBox2.Text == "已参加过考试") { isTe = 1; } else { isTe = 0; } if (ComVal.StuNA == "") { //s说明是添加的操作 string sql = "insert into UserInfo(userIde,userName,userAcc,userPwd,isTest,userSex,picPath) values(0,'" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "'," + isTe + ",'" + comboBox1.Text + "','" + ComVal.PicPath + "')"; DataClass.OperaData(sql); } else { //说明这是修改的操作 //修改成功后,释放ComVal中存放的相关数据,方便再次操作 ComVal.StuNA = ""; string sql = "update UserInfo set userAcc='" + textBox2.Text + "',userPwd='" + textBox3.Text + "',isTest=" + isTe + ",userSex='" + comboBox1.Text + "',picPath='" + ComVal.PicPath + "' where userName='******'"; DataClass.OperaData(sql); } StuManage stum = new StuManage(); Admin.stum.Show(); //打开之前隐藏的”学生管理“窗体 Admin.stum.StuManage_Load(sender, e); //刷新 this.Close(); } }
//提交按钮 private void button1_Click(object sender, EventArgs e) { if (coP.Text == "" || coPR.Text == "" || coX.Text == "" || coXR.Text == "") { MessageBox.Show("请输入完整信息!"); } else { if (int.Parse(coXR.Text) + int.Parse(coPR.Text) != 100) { MessageBox.Show("请输入正确信息!"); } else { string sql = "update ExamSet set selRate='" + coXR.Text + "',selPre='" + coX.Text + "',judRate='" + coPR.Text + "',judPre='" + coP.Text + "',ExamTime='" + texT.Text.Trim() + "'"; DataClass.OperaData(sql); this.Close(); //关闭本窗体 Form1.ad.Admin_Load(sender, e); //刷新 } } }
//提交按钮 private void button1_Click(object sender, EventArgs e) { //判断信息是否输入完整 if (textR.Text.Trim() == "" || textD.Text.Trim() == "" || textA.Text.Trim() == "" || textB.Text.Trim() == "" || textC.Text.Trim() == "" || textTi.Text.Trim() == "") { MessageBox.Show("请将信息填写完整!"); } else { //如果信息输入完整 if (ComVal.TeID == 0) { //说明是增加题目的操作 string sql = "insert into TestInfo(TestType,question,rightKey,A,B,C,D) values(0,'" + textTi.Text.Trim() + "','" + textR.Text.Trim().ToUpper() + "','" + textA.Text.Trim() + "','" + textB.Text.Trim() + "','" + textC.Text.Trim() + "','" + textD.Text.Trim() + "')"; DataClass.OperaData(sql); } else { //说明是修改的操作 string sql = "update TestInfo set question='" + textTi.Text + "',rightKey='" + textR.Text + "',A='" + textA.Text + "',B='" + textB.Text + "',C='" + textC.Text + "',D='" + textD.Text + "' where ID=" + ComVal.TeID + ""; DataClass.OperaData(sql); ComVal.TeID = 0;//修改之后释放ComVal.TeID,方便再次操作 } //清空 textA.Clear(); textB.Clear(); textC.Clear(); textD.Clear(); textR.Clear(); textTi.Clear(); Form1.ad.Show(); //打开隐藏的管理员窗口 Form1.ad.Admin_Load(sender, e); //刷新 this.Close(); } }
//提交按钮 private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || comboBox1.Text == "") { MessageBox.Show("请输入完整信息!"); } else { if (comboBox1.Text == "正确") { j = 1; } else { j = 0; } if (ComVal.TeID == 0) { //说明是增加题目的操作 string sql = "insert into TestInfo(TestType,question,rightKey) values(1,'" + textBox1.Text + "','" + j + "')"; DataClass.OperaData(sql); } else { //说明是修改的操作 string sql = "update TestInfo set question='" + textBox1.Text + "',rightKey='" + j + "' where ID=" + ComVal.TeID + ""; DataClass.OperaData(sql); ComVal.TeID = 0;//修改之后释放ComVal.TeID,方便再次操作 } textBox1.Clear(); Form1.ad.Show(); //打开隐藏的管理员窗口 Form1.ad.Admin_Load(sender, e); //刷新 this.Close(); } }