第一范文网 - 专业文章范例文档资料分享平台

软件工程项目开发报告模板

来源:用户分享 时间:2025/5/31 18:04:54 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

软件工程项目开发课程报告

5. 系统实现

本系统采用了三层架构来实现,即分为用户界面层(UI)、业务逻辑层(BLL)和数据访问层(DAL),用户界面层是展示给用户的界面,方便用户与系统进行交互;业务逻辑层是对系统业务实体的封装,完成系统业务功能;数据访问层直接与数据库打交道,为业务逻辑层提供底层的数据库操作。

5.1 Database类主要是与数据库连接,提供数据库操作功能,代码如下:

namespace MyElectCourse.DAL {

public class Database {

protected string connectionString; protected SqlConnection connection = null;

public Database() {

connectionString =

ConfigurationManager.ConnectionStrings[\].ConnectionString.ToString(); }

~Database() {

if (connection != null) {

connection = null; }

}

protected void Open() {

if (connection == null) {

connection = new SqlConnection(connectionString); }

if (connection.State.Equals(ConnectionState.Closed)) {

connection.Open(); } }

protected void Close() {

if (connection != null) {

connection.Close(); } }

16

软件工程项目开发课程报告

public int ExecuteSQL(string sqlstr) {

int count = -1; this.Open();

SqlCommand cmd = new SqlCommand(sqlstr, connection); count = cmd.ExecuteNonQuery(); this.Close();

return count; }

public DataSet GetDataSet(string sqlstr) {

this.Open();

DataSet ds = new DataSet();

SqlDataAdapter adapter = new SqlDataAdapter(sqlstr,connection); adapter.Fill(ds); this.Close();

return ds; }

public DataTable GetDataTable(string sqlstr) {

DataSet ds = this.GetDataSet(sqlstr); DataTable dt = new DataTable(); if (ds.Tables.Count > 0) {

dt = ds.Tables[0]; }

return dt; }

public SqlDataReader GetDataReader(string sqlstr) {

this.Open();

SqlCommand cmd = new SqlCommand(sqlstr, connection);

SqlDataReader sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //this.Close(); return sdr; } } }

5.2 UserBase类是所有系统角色用户的基类,完成用户登录验证与修改密码的功能,代码如下:

namespace MyElectCourse.BLL {

17

软件工程项目开发课程报告

public class UserBase {

private string userID; public string UserID {

get { return userID; } set { userID = value; } }

private string userPSW; public string UserPSW {

get { return userPSW; } set { userPSW = value; } }

public string loginCheck(string uid, string upwd, string urole) {

String selectStr = String.Empty; switch (urole) {

case \: //身份为教师时 selectStr = \ + uid + \; break;

case \: //身份为学生时

selectStr = \ + uid + \; break;

case \: //身份为管理员时

selectStr = \ + uid + \; break; default:

return null; }

Database db = new Database();

DataTable dt = db.GetDataTable(selectStr); if (dt.Rows.Count > 0) //如果该用户存在 {

if (dt.Rows[0][1].ToString().Equals(upwd)) //密码正确 {

switch (urole) {

case \: //身份为教师时 return \;

case \: //身份为学生时 return \;

18

软件工程项目开发课程报告

case \: //身份为管理员时 return \; default: return null; } }

else //密码错误,给出提示信息! {

return \; } }

else //用户不存在或用户名输入错误 {

return \; } }

public string modifyPWD(String urole, String uid, String oldPwd, String newPwd) {

String updateStr = String.Empty; switch (urole) {

case \: //身份为教师时

updateStr = \ + newPwd + \ + uid + \; break;

case \: //身份为学生时

updateStr = \ + newPwd + \ + uid + \; break;

case \: //身份为管理员时

updateStr = \ + newPwd + \

break;

}

string ucheck = this.loginCheck(uid, oldPwd, urole);

if (ucheck.Equals(\) || ucheck.Equals(\) || ucheck.Equals(\)) {

int t = new Database().ExecuteSQL(updateStr); //根据修改后返回的结果给出提示 if (t > 0) {

return \; } else {

return \; } } else {

19

搜索更多关于: 软件工程项目开发报告模板 的文档
软件工程项目开发报告模板.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c5h6n19j8pb6b8ve00zsa83uyx9681900ve3_5.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top