文件名称:c#学生选课管理系统
文件大小:2.71MB
文件格式:ZIP
更新时间:2018-02-03 02:36:26
Microsoft Visual Studio 2010
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 XKGLXT { public partial class Login : Form { Model.User mdl_ui = new Model.User(); BLL.User bll_ui = new BLL.User(); Model.Student mdl_st = new Model.Student(); BLL.Student bll_st = new BLL.Student(); BLL.Right bll_rt = new BLL.Right(); public Login() { InitializeComponent(); } private void BtnLogin_Click(object sender, EventArgs e) { //MessageBox.Show(cbxRole.SelectedIndex.ToString()); if (cbxRole.Text=="管理员") { mdl_ui.UserID = TxtUser.Text; mdl_ui.Pwd = TxtPass.Text; Model.Login.UserNo = TxtUser.Text; if (bll_ui.login(mdl_ui) > 0) { Model.Login.flag = true; MessageBox.Show("登录成功"); this.Close(); } else { Model.Login.flag = false; MessageBox.Show("用户名或密码错误!"); } } if (cbxRole.Text == "教师") { mdl_ui.UserID = TxtUser.Text; mdl_ui.Pwd = TxtPass.Text; Model.Login.UserNo = TxtUser.Text; if (bll_ui.login(mdl_ui) > 0) { Model.Login.flag = true; MessageBox.Show("登录成功"); this.Close(); } else { Model.Login.flag = false; MessageBox.Show("用户名或密码错误!"); } } if(cbxRole.Text=="学生") { mdl_st.StuNo = TxtUser.Text; mdl_st.Pwd = TxtPass.Text; Model.Login.StuNo = TxtUser.Text; Model.Login.Role=cbxRole.SelectedValue.ToString(); MessageBox.Show(Model.Login.Role); if (bll_st.Stulogin(mdl_st) > 0) { Model.Login.flag = true; MessageBox.Show("登录成功"); this.Close(); } else { Model.Login.flag = true; MessageBox.Show("用户名或密码错误!"); } } if (cbxRole.Text == "--请选择角色--") { MessageBox.Show("请选择角色才能进入系统!", "选课系统提示!"); } } private void BtnExit_Click(object sender, EventArgs e) { Application.Exit(); } private void LoadRoleData() { DataTable dt = new DataTable(); dt = bll_rt.GetAllData(); DataRow row = dt.NewRow(); row["RoleName"] = "--请选择角色--"; row["RoleId"] = "-1"; dt.Rows.InsertAt(row, 0); cbxRole.ValueMember = "RoleId"; cbxRole.DisplayMember = "RoleName"; cbxRole.DataSource = dt; } private void Login_Load(object sender, EventArgs e) { LoadRoleData(); } } }