c#大作业教师页面的书写
using 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 WindowsFormsApp1 { public partial class teacher : Form { public teacher() { InitializeComponent(); // 显示控件 panel1.Visible = false; panel2.Visible = false; panel3.Visible = false; // 隐藏其他控件 // label2.Visible = false; } private void teacher_Load(object sender, EventArgs e) { // 创建一个DataTable并添加列定义 DataTable dataTable = new DataTable(); dataTable.Columns.Add("ID", typeof(int)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Time", typeof(string)); dataTable.Columns.Add("note", typeof(string)); dataTable.Columns.Add("class", typeof(string)); dataTable.Columns.Add("date", typeof(string)); DataRow row1 = dataTable.NewRow(); row1["ID"] = 1; row1["Name"] = "Math 101"; row1["Time"] = "9:00 AM"; row1["note"] = "准时上课"; row1["class"] = "一班"; row1["date"] = "2023.11.7"; dataTable.Rows.Add(row1); DataRow row2 = dataTable.NewRow(); row2["ID"] = 2; row2["Name"] = "History 201"; row2["Time"] = "11:00 AM"; row2["note"] = "准时上课"; row2["class"] = "一班"; row2["date"] = "2023.11.7"; dataTable.Rows.Add(row2); DataRow row3 = dataTable.NewRow(); row3["ID"] = 3; row3["Name"] = "Science 301"; row3["Time"] = "2:00 PM"; row3["note"] = "准时上课"; row3["class"] = "一班"; row3["date"] = "2023.11.7"; dataTable.Rows.Add(row3); DataRow row4 = dataTable.NewRow(); row4["ID"] = 4; row4["Name"] = "English 101"; row4["Time"] = "4:00 PM"; row4["note"] = "准时上课"; row4["class"] = "一班"; row4["date"] = "2023.11.7"; dataTable.Rows.Add(row4); DataRow row5 = dataTable.NewRow(); row5["ID"] = 5; row5["Name"] = "Art 101"; row5["Time"] = "6:00 PM"; row5["note"] = "准时上课"; row5["class"] = "一班"; row5["date"] = "2023.11.7"; dataTable.Rows.Add(row5); DataRow row6 = dataTable.NewRow(); row6["ID"] = 6; row6["Name"] = "Art2 101"; row6["Time"] = "6:00 PM"; row6["note"] = "准时上课"; row6["class"] = "二班"; row6["date"] = "2023.11.7"; dataTable.Rows.Add(row6); DataRow row7 = dataTable.NewRow(); row7["ID"] = 7; row7["Name"] = "Sport 101"; row7["Time"] = "6:00 PM"; row7["note"] = "准时上课"; row7["class"] = "二班"; row7["date"] = "2023.11.7"; dataTable.Rows.Add(row7); // 找到DataGridView控件(假设名称为 dataGridView1)并将数据绑定到它 dataGridView1.DataSource = dataTable; DataTable studentGradesDataTable = new DataTable(); studentGradesDataTable.Columns.Add("StudentID", typeof(int)); studentGradesDataTable.Columns.Add("StudentName", typeof(string)); studentGradesDataTable.Columns.Add("Grade-学生成绩", typeof(double)); studentGradesDataTable.Columns.Add("绩点", typeof(double)); DataRow row11= studentGradesDataTable.NewRow(); row11["StudentID"] = 1; row11["StudentName"] = "wdadw"; row11["Grade-学生成绩"] = 99.9; row11["绩点"] = 3.9; studentGradesDataTable.Rows.Add(row11); DataRow row12 = studentGradesDataTable.NewRow(); row12["StudentID"] = 2; row12["StudentName"] = "饿啊分"; row12["Grade-学生成绩"] = 99.9; row12["绩点"] = 3.9; studentGradesDataTable.Rows.Add(row12); DataRow row13 = studentGradesDataTable.NewRow(); row13["StudentID"] = 3; row13["StudentName"] = "w达瓦"; row13["Grade-学生成绩"] = 99.9; row13["绩点"] = 3.9; studentGradesDataTable.Rows.Add(row13); DataRow row14 = studentGradesDataTable.NewRow(); row14["StudentID"] = 4; row14["StudentName"] = "的哇额分"; row14["Grade-学生成绩"] = 99.9; row14["绩点"] = 3.9; studentGradesDataTable.Rows.Add(row14); DataRow row15 = studentGradesDataTable.NewRow(); row15["StudentID"] = 5; row15["StudentName"] = "wdadw"; row15["Grade-学生成绩"] = 99.9; row15["绩点"] = 3.9; studentGradesDataTable.Rows.Add(row15); DataRow row16 = studentGradesDataTable.NewRow(); row16["StudentID"] = 6; row16["StudentName"] = "wdadw"; row16["Grade-学生成绩"] = 99.9; row16["绩点"] = 3.9; studentGradesDataTable.Rows.Add(row16); DataRow row17 = studentGradesDataTable.NewRow(); row17["StudentID"] = 7; row17["StudentName"] = "wdadw"; row17["Grade-学生成绩"] = 99.9; row17["绩点"] = 3.9; studentGradesDataTable.Rows.Add(row17); dataGridView2.DataSource = studentGradesDataTable; } private void toolStripMenuItem1_Click(object sender, EventArgs e) { } private void panel1_Paint(object sender, PaintEventArgs e) { } private void 登记学生信息ToolStripMenuItem_Click(object sender, EventArgs e) { panel1.Visible = false; panel2.Visible = false; panel3.Visible = true; } private void 月历课表查询ToolStripMenuItem_Click(object sender, EventArgs e) { // 显示控件 panel1.Visible = true; panel2.Visible = false; panel3.Visible = false; } private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) { } private void button1_Click(object sender, EventArgs e) { } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void toolStripStatusLabel1_Click(object sender, EventArgs e) { } private void label1_Click(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void 查询学生成绩ToolStripMenuItem_Click(object sender, EventArgs e) { panel2.Visible = true; panel3.Visible = false; } private void pictureBox1_Click(object sender, EventArgs e) { } private void 退出登录ToolStripMenuItem_Click(object sender, EventArgs e) { this.Close(); } } }