




已阅读5页,还剩23页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
About.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Reflection;namespace public partial class About : Formpublic About()InitializeComponent();private void button1_Click(object sender, EventArgs e)this.Close();private void About_Load(object sender, EventArgs e)AddCourse.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace public partial class AddCourse : Formpublic AddCourse()InitializeComponent();private void btnExit_Click(object sender, EventArgs e)this.Close();private void btnAddCourse_Click(object sender, EventArgs e)string myConnectionString = Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq;MySqlConnection mycn = new MySqlConnection(myConnectionString);mycn.Open();string sql;Course course = new Course();course.Cno = txtCno.Text;course.Cname = txtCname.Text;trysql = select count(*) from course where cno= + txtCno.Text + ;MySqlCommand mycm = new MySqlCommand(sql, mycn);MySqlDataReader msdr = mycm.ExecuteReader();msdr.Read();int stuCount = msdr.GetInt32(count(*);msdr.Close();if (stuCount = 0 & txtCname.Text != & txtCno.Text != )sql = insert into course(cno,cname)values( + course.Cno + , + course.Cname + );MySqlCommand mycm1 = new MySqlCommand(sql, mycn);trymycm1.ExecuteNonQuery();catch (Exception exception)MessageBox.Show(exception.Message);return;finallymycn.Close();MessageBox.Show();else if (stuCount = 1 & txtCno.Text != & txtCname.Text != )/MessageBox.Show();else/MessageBox.Show();msdr.Close();mycn.Close();catch (Exception a)Console.WriteLine(a.ToString();finallytxtCno.Text = ;txtCname.Text = ;private void AddCourse_Load(object sender, EventArgs e)AddStudent.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;using System.IO;namespace public partial class AddStudent : Formpublic AddStudent()InitializeComponent();private void AddStudent_Load(object sender, EventArgs e)private void btnCancel_Click(object sender, EventArgs e)this.Close();private void btnAddStudent_Click(object sender, EventArgs e)string myConnectionString = Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq;MySqlConnection mycn = new MySqlConnection(myConnectionString);mycn.Open();string sql;/int stuNum = Select count(id) fromStudent stu = new Student();stu.Sno = txtSno.Text;stu.Sname = txtName.Text;stu.Age = txtAge.Text;stu.ClassName = txtClassName.Text;stu.Password = txtPassword.Text;stu.Id = txtId.Text;if (rbStuGirl.Checked) stu.Sex = ?;else if (rbStuBoy.Checked) stu.Sex = D;/if (rbStuGirl.Checked) stu.Sex = girl;/else if (rbStuBoy.Checked) stu.Sex = boy;trysql = select count(*) from student where sno= + txtSno.Text + ;MySqlCommand mycm = new MySqlCommand(sql, mycn);MySqlDataReader msdr = mycm.ExecuteReader();msdr.Read();int stuCount = msdr.GetInt32(count(*);msdr.Close();if (stuCount = 0 & txtSno.Text != & txtName.Text != & txtAge.Text != & txtClassName.Text != & txtPassword.Text != & txtId.Text != )sql = insert into student(sno, sname,sex,age,classname,password,id)values( + stu.Sno + , + stu.Sname + , + stu.Sex + , + stu.Age + , + stu.ClassName + , + stu.Password + , + stu.Id + );Console.WriteLine(sql);MySqlCommand mycm1 = new MySqlCommand(sql, mycn);trymycm1.ExecuteNonQuery(); catch (Exception exception)MessageBox.Show(exception.Message);return;finallymsdr.Close();mycn.Close();MessageBox.Show(?|?);else if (stuCount = 1 & txtSno.Text != & txtName.Text != & txtAge.Text != & txtClassName.Text != & txtPassword.Text != & txtId.Text != )/MessageBox.Show();else/MessageBox.Show();msdr.Close();mycn.Close();catch (Exception a)Console.WriteLine(a.ToString();finallytxtSno.Text = ;txtName.Text = ;txtAge.Text = ;txtClassName.Text = ;txtPassword.Text = ;txtId.Text = ;AdminWindou.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace public partial class AdminWindow : Formpublic AdminWindow()InitializeComponent();private void AdminWindow_Load(object sender, EventArgs e)private void ToolStripMenuItem2_Click(object sender, EventArgs e)new SearchStudent().ShowDialog();private void ToolStripMenuItem3_Click(object sender, EventArgs e)new AddStudent().ShowDialog();private void ToolStripMenuItem3_Click(object sender, EventArgs e)new UpdateStudent().ShowDialog();private void ToolStripMenuItem3_Click(object sender, EventArgs e)new DeleteStudent().ShowDialog();private void ToolStripMenuItem2_Click(object sender, EventArgs e)new SearchCourse().ShowDialog();private void ToolStripMenuItem3_Click(object sender, EventArgs e)new AddCourse().ShowDialog();private void ToolStripMenuItem3_Click(object sender, EventArgs e)new UpdateCourse().ShowDialog();private void ToolStripMenuItem3_Click(object sender, EventArgs e)new DeleteCourse().ShowDialog();private void ToolStripMenuItem2_Click(object sender, EventArgs e)new About().ShowDialog();private void ToolStripMenuItem2_Click(object sender, EventArgs e)Application.Exit();private void ToolStripMenuItem1_Click(object sender, EventArgs e)new CourseRank().ShowDialog();private void ToolStripMenuItem2_Click(object sender, EventArgs e)new ScoreSearch().ShowDialog();private void ToolStripMenuItem2_Click(object sender, EventArgs e)new ClassAvg().ShowDialog();private void ToolStripMenuItem2_Click(object sender, EventArgs e)new CourseAvg().ShowDialog();ClassAvg.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace public partial class ClassAvg : Formpublic ClassAvg()InitializeComponent();private void ClassAvg_Load(object sender, EventArgs e)private void btnsearch_Click(object sender, EventArgs e)string bjmc = txtbjmc.Text;using (MySqlConnection conn = new MySqlConnection(Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq)conn.Open();using (MySqlCommand cmd = conn.CreateCommand()cmd.CommandText = select avg(score) from scoreinfiwhere classname=bjmc;cmd.Parameters.Add(new MySqlParameter(bjmc,bjmc);string bjavg=Convert.ToString(cmd.ExecuteScalar();txtbjavg.Text = bjavg;private void btncancle_Click(object sender, EventArgs e)this.Close();CourseAvg.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace public partial class CourseAvg : Formpublic CourseAvg()InitializeComponent();private void btnquery_Click(object sender, EventArgs e)string courseid = txtcourseid.Text;string coursename = txtcoursename.Text;using (MySqlConnection conn = new MySqlConnection(Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq)conn.Open();using (MySqlCommand cmd = conn.CreateCommand()cmd.CommandText = select avg(score) as avg from scoreinfiwhere cname=coursename;cmd.Parameters.Add(new MySqlParameter(coursename,coursename);/* DataSet dataset = new DataSet();MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);adapter.Fill(dataset);DataTable table = dataset.Tables0;for(int i=0;i= 1 & txtCno.Text != )msdr.Close();sql = delete from course where cno= + txtCno.Text + ;MySqlCommand mycm1 = new MySqlCommand(sql, mycn);trymycm1.ExecuteNonQuery();catch (Exception exception)MessageBox.Show(exception.Message);return;finallymycn.Close();MessageBox.Show();else if (stuCount = 0 & txtCno.Text != )MessageBox.Show();msdr.Close();mycn.Close();elseMessageBox.Show();msdr.Close();mycn.Close();catch (Exception a)Console.WriteLine(a.ToString();finallytxtCno.Text = ;private void DeleteCourse_Load(object sender, EventArgs e)DeleteStudent.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace public partial class DeleteStudent : Formpublic DeleteStudent()InitializeComponent();private void btnExit_Click(object sender, EventArgs e)this.Close();private void btnDelete_Click(object sender, EventArgs e)string myConnectionString = Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq;MySqlConnection mycn = new MySqlConnection(myConnectionString);mycn.Open();string sql;trysql = select count(*) from student where sno= + txtSno1.Text + ;MySqlCommand mycm = new MySqlCommand(sql, mycn);MySqlDataReader msdr = mycm.ExecuteReader();msdr.Read();int stuCount = msdr.GetInt32(count(*);if (stuCount =1 & txtSno1.Text != )msdr.Close();sql = delete from student where sno= + txtSno1.Text + ;MySqlCommand mycm1 = new MySqlCommand(sql, mycn);trymycm1.ExecuteNonQuery(); catch (Exception exception)MessageBox.Show(exception.Message);return;finallymycn.Close();MessageBox.Show();else if(stuCount=0 &txtSno1.Text!=)MessageBox.Show();msdr.Close();mycn.Close();elseMessageBox.Show();msdr.Close();mycn.Close(); catch (Exception a)Console.WriteLine(a.ToString();finallytxtSno1.Text = ;private void DeleteStudent_Load(object sender, EventArgs e)Login.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace public partial class Login : Formpublic Login()InitializeComponent();private void Login_Load(object sender, EventArgs e)/ new AdminWindow();private void btexit_Click(object sender, EventArgs e)Application.Exit();private void btlogin_Click(object sender, EventArgs e)if (txtSno.Text != & txtPassword.Text != )string sno = this.txtSno.Text;string pass = this.txtPassword.Text;string myConnectionString = Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq;MySqlConnection mycn = new MySqlConnection(myConnectionString);mycn.Open();string sql = select * from userinfo where sno= + sno + ;MySqlCommand mycm = new MySqlCommand(sql, mycn);MySqlDataReader msdr = mycm.ExecuteReader();while (msdr.Read()if (msdr0.ToString() = sno & msdr1.ToString() = pass)if (rbManager.Checked & msdr2.ToString() = 1)/new AdminWindow().ShowDialog();/this.Close();AdminWindow addForm=new AdminWindow();addForm.ShowDialog(this );/ this.Visible = false;else if (rbStudent.Checked & msdr2.ToString() = 2)/this.Close();/ AdminWindow addForm = new AdminWindow();/ addForm.ShowDialog(addForm);new ScoreSearch().ShowDialog();elseMessageBox.Show();txtSno.Text = ;txtPassword.Text = ;msdr.Close();mycn.Close();elseMessageBox.Show();private void label3_Click(object sender, EventArgs e)Scoresearch.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace public partial class ScoreSearch : Formpublic ScoreSearch()InitializeComponent();private void button1_Click(object sender, EventArgs e)string connString = Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq;MySqlConnection connection = new MySqlConnection(connString);string sql = select * from scoreinfi where sno= + textBox1.Text + ;Console.WriteLine(sql);connection.Open();MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sql, connection);DataSet dataSet = new DataSet( );dataAdapter.Fill(dataSet);/dataGridView1.Columns0.DataPropertyName = sno;/dataGridView1.Columns1.DataPropertyName = sname;/dataGridView1.Columns2.DataPropertyName = classname;/dataGridView1.Columns3.DataPropertyName = cname;/ dataGridView1.Columns4.DataPropertyName = score;dataGridView1.DataSource = dataSet.Tables0;connection.Close();private void button3_Click(object sender, EventArgs e)this.Close();private void button4_Click(object sender, EventArgs e)Application.Exit();private void cxssForm2_Load(object sender, EventArgs e)/this.scorestuTableAdapter.Fill(this.kechengshejiDataSet.scorestu);/* private void button2_Click(object sender, EventArgs e)if (comboBox2.Text = )xcpjgsForm2 frm = new xcpjgsForm2();frm.ShowDialog();elsexcbjgcForm2 frm = new xcbjgcForm2();frm.ShowDialog();*/searchCourse.csus
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论