学生选课系统代码

更新时间:2023-11-10 22:24:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

登陆界面:

vusing System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient;

namespace MySchool {

public partial class Login : Form {

public Login() {

InitializeComponent(); }

private void Login_Load(object sender, EventArgs e) {

}

private void btnYes_Click(object sender, EventArgs e) {

string userName = txtName.Text; string passward = txtPwd.Text;

string connString = @\Security=True\

SqlConnection connection = new SqlConnection(connString);

try {

//打开数据库

connection.Open(); //创建Command对象

SqlCommand command = new SqlCommand(sql, connection);

int num = (int)command.ExecuteScalar(); if(num > 0) {

//如果有匹配的行,则表明用户名和密码正确

MessageBox.Show(\欢迎进入学生选课系统系统!\登陆成功\ //创建主窗体对象

MainFrm mainForm = new MainFrm(); //显示主窗体

mainForm.Show(); //隐藏登录窗体 this.Visible = false; } else {

MessageBox.Show(\您输入的用户名或密码错误!\登陆失败\MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }

}

catch (Exception ex) {

MessageBox.Show(ex.Message, \登陆失败\MessageBoxIcon.Exclamation); }

finally {

connection.Close(); }

}

private void btnNo_Click(object sender, EventArgs e) {

txtName.Clear(); txtPwd.Clear(); txtName.Focus(); }

private void lblMain_Click(object sender, EventArgs e) {

} } }

Course:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;

using System.Windows.Forms;

namespace MySchool {

public partial class CourseFrm : Form {

public CourseFrm()

{

InitializeComponent(); }

private void CourseFrm_Load(object sender, EventArgs e) {

// TODO: 这行代码将数据加载到表“myschoolDataSet4.CourseMsg”中。您可以根据需要移动或删除它。

this.courseMsgTableAdapter2.Fill(this.myschoolDataSet4.CourseMsg); //// TODO: 这行代码将数据加载到表“myschoolDataSet2.CourseMsg”中。您可以根据需要移动或删除它。

//this.courseMsgTableAdapter1.Fill(this.myschoolDataSet2.CourseMsg);

}

private void btnsave_Click(object sender, EventArgs e) {

courseMsgTableAdapter.Update(mySchoolDataSet1.CourseMsg); }

private void btnclose_Click(object sender, EventArgs e) {

this.Close(); }

private void btnupdate_Click(object sender, EventArgs e) {

courseMsgTableAdapter.Fill(mySchoolDataSet1.CourseMsg); } } }

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient;

namespace MySchool {

public partial class CourseMsgFrm : Form {

string courseName; string courseClass; string required; int credit;

int prelectionCredit; int ExperimentCredit;

本文来源:https://www.bwwdw.com/article/qt0v.html

Top