




已阅读5页,还剩23页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
建立3层架构Entity层:book.cs using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ZDSoft.LibraryManage.Entity public class Book public Book() BBookID = 0; MManID = ; BBookName = ; WWriter = ; public Book(int bookid, string manid, string bookname, string writer) BBookID = bookid; MManID = manid; BBookName = bookname; WWriter = writer; private int BBookID; / / 图?书编号? / public int BookID get return BBookID; set BBookID = value; private string MManID; / / 管理编号? / public string ManID get return MManID; set MManID = value; private string BBookName; / / 图?书名? / public string BookName get return BBookName; set BBookName = value; private string WWriter; / / 作者? / public string Writer get return WWriter; set WWriter = value; using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ZDSoft.LibraryManage.Entity public class Borrow public Borrow() private int BBorrowID; / / 借书编号? / public int BorrowID get return BBorrowID; set BBorrowID = value; private string CCardID; / / 借书证号? / public string CardID get return CCardID; set CCardID = value; private string MManID; / / 管理编号? / public string ManID get return MManID; set MManID = value; private DateTime BBorrowDate; / / 借书日?期 / public DateTime BorrowDate get return BBorrowDate; set BBorrowDate =value; private DateTime RReturnDate; / / 还1书日?期 / public DateTime ReturnDate get return RReturnDate; set RReturnDate = value; Reader.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ZDSoft.LibraryManage.Entity public class Reader public Reader() this.RReaderID = 0; this.RReaderName = ; this.CCardID = ; this.TTel = ; / / 构1造用?户实体? / / 读者?编号? / 姓?名? / 借书证号? / 联a系电?话 public Reader(int readerid, string readername, string cardid, string tel) this.RReaderID = readerid; this.RReaderName = readername; this.CCardID = cardid; this.TTel = tel; private int RReaderID; / / 读者?编号? / public int ReaderID get return RReaderID; set RReaderID = value; private string CCardID; / / 借书证号? / public string CardID get return CCardID; set CCardID = value; private string RReaderName; / / 姓?名? / public string ReaderName get return RReaderName; set RReaderName = value; private string TTel; / / 联a系电?话 / public string Tel get return TTel; set TTel = value; User.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ZDSoft.LibraryManage.Entity public class EntityUser public EntityUser() UUserID = 0; UUserName = ; PPassWord = ; LLevel =; private int UUserID; / / 用?户编号? / public int UserID get return UUserID; set UUserID = value; private string UUserName; / / 用?户名? / public string UserName get return UUserName; set UUserName = value; private string PPassWord; / / 登?录?密码? / public string PassWord get return PPassWord; set PPassWord = value; private string LLevel; / / 用?户权限T / public string Level get return LLevel; set LLevel = value; BookDAl.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Data.SqlClient;using ZDSoft.LibraryManage.Entity;namespace ZDSoft.LibraryManage.DAL public class BookDal private Book BBook; public Book Book get return BBook; set BBook = value; private Book DataRowToEntity(DataRow dr) Book book = new Book(); book.BookID = int.Parse(drBOOKID.ToString(); book.BookName = drBOOKNAME.ToString(); book.ManID = drMANID.ToString(); book.Writer = drWRITER.ToString(); return book; / / 根据Y图?书编号?获?取?图?书 / / 图?书实体?类 / 对?应|的?图?书信?息 public Book GetByID(string bookID) /SqlParameter sqlp = new SqlParameter new SqlParameter(BookID, bookID) ; DataTable dt = SqlOperator.SelectAll(T_Book_SelectBookID); Book book = null; if (dt.Rows.Count = 1) book = DataRowToEntity(dt.Rows0); return book; public Book SearchBookID() SqlParameter sqlp = new SqlParameter new SqlParameter(BookID, BBook.BookID) ; DataTable dt = SqlOperator.Select(sqlp, T_Book_SelectBookID); Book book = null; if (dt.Rows.Count 0) foreach (DataRow dr in dt.Rows) book = DataRowToEntity(dr); return book; / / 根据Y图?书管理编号?获?取?图?书 / / 图?书信?息实体?类 / 对?应|的?图?书信?息 public IList GetByManageID(string manID) / SqlParameter sqlp = new SqlParameter new SqlParameter(ManID, manID) ; DataTable dt = SqlOperator.SelectAll(T_Book_SelectManID); IList list = null; if (dt.Rows.Count 0) Book book = null; foreach (DataRow dr in dt.Rows) book = DataRowToEntity(dr); if (list = null) list = new List(); list.Add(book); return list; / / 根据Y管理编号?查询图?书 / / 返回?查询结果?DataTable public DataTable Search() SqlParameter sqlp = new SqlParameter new SqlParameter(ManID, BBook.ManID) ; DataTable dt = SqlOperator.Select(sqlp, T_Book_SelectManID); return dt; /public IList Search() / / SqlParameter sqlp = new SqlParameter new SqlParameter(ManID, BBook.ManID) ; / DataTable dt = SqlOperator.Select(sqlp, T_Book_SelectManID); / IList list = null; / if (dt.Rows.Count 0) / / Book book = null; / foreach (DataRow dr in dt.Rows) / / book = DataRowToEntity(dr); / if (list = null) / / list = new List(); / / list.Add(book); / / / return list; / / / 根据Y管理编号?或图?书名?查询图?书信?息 / / 关?键字? / 条?件t / 返回?查询结果? public IList GetByNameAndMainID(string key, string se) SqlConnection conn = new SqlConnection(SqlConnect.ReturnConnection(); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = new SqlCommand(); sda.SelectCommand.Connection = conn; sda.SelectCommand.CommandText = select * from T_Book where + se + like %+key+%; sda.SelectCommand.Parameters.Add(key, SqlDbType.NVarChar, 12).Value = key; DataTable dt = new DataTable(); IList list = null; try conn.Open(); sda.Fill(dt); if (dt.Rows.Count 0) Book book = null; book = new Book(); if (list = null) list = new List(); list.Add(book); conn.Close(); catch (SqlException ex) throw new Exception(检索数y据Y发生错误, ex); finally if (conn.State = ConnectionState.Open) conn.Close(); return list; public IList Select(string id) SqlParameter sqlp = new SqlParameter new SqlParameter(ManID, id) ; DataTable dt = SqlOperator.Select(sqlp, T_Book_SelectID); IList list = null; if (dt.Rows.Count 0) Book book = null; foreach (DataRow dr in dt.Rows) book = DataRowToEntity(dr); if (list = null) list = new List(); list.Add(book); return list; / / 查询所有D图?书信?息 / public IList GetAllBook() DataTable dt = new DataTable(); IList listbook = null; dt = SqlOperator.SelectAll(T_Book_Select); if (dt.Rows.Count 0) Book book = null; foreach (DataRow dr in dt.Rows) book = DataRowToEntity(dr); if (listbook = null) listbook = new List(); listbook.Add(book); return listbook; / / 根据Y管理编号?或图?书名?查询图?书信?息 / / 关?键字? / 条?件t / 返回?查询结果? public IList Select(string key, string se) SqlConnection conn = new SqlConnection(SqlConnect.ReturnConnection(); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = new SqlCommand(); sda.SelectCommand.Connection = conn; sda.SelectCommand.CommandText = select * from T_Book where + se + like %+key+%; sda.SelectCommand.Parameters.Add(key, SqlDbType.NVarChar, 12).Value = key; DataTable dt = new DataTable(); IList listbook = null; try conn.Open(); sda.Fill(dt); if (dt.Rows.Count 0) Book book = null; foreach (DataRow dr in dt.Rows) book = DataRowToEntity(dr); if (listbook = null) listbook = new List(); listbook.Add(book); conn.Close(); catch (SqlException ex) throw new Exception(检索数y据Y发生错误, ex); finally if (conn.State = ConnectionState.Open) conn.Close(); return listbook; / / 增?加图?书 / / 图?书属?性?类实体? public void InsertBook(Book book) SqlParameter sqlp = new SqlParameter new SqlParameter(ManID, book.ManID), new SqlParameter(BookName, book.BookName), new SqlParameter(Writer, book.Writer) ; int row = SqlOperator.Insert(sqlp, T_Book_Insert); / / 根据Y图?书编号?更新?图?书信?息 / public void UpdateBook(Book book) SqlParameter sqlp = new SqlParameter new SqlParameter(BookID, book.BookID), new SqlParameter(BookName, book.BookName), new SqlParameter(Writer, book.Writer); int row = SqlOperator.Update(sqlp, T_Book_Update); / / 根据Y图?书编号?删?除y图?书 / public void DeleteBook(string bookID) SqlParameter sqlp = new SqlParameter new SqlParameter(BookID, bookID) ; int row = SqlOperator.Delete(sqlp, T_Book_Delete); BorrowDAl.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Data.SqlClient;using ZDSoft.LibraryManage.Entity;namespace ZDSoft.LibraryManage.DAL public class BorrowDal private Borrow BBorrow; public Borrow Borrow get return BBorrow; set BBorrow = value; / / 插?入?借书信?息 / / 返回?影响行D数y public int Insert() SqlParameter sqlp = new SqlParameter new SqlParameter(CardID, BBorrow.CardID), new SqlParameter(ManID, BBorrow.ManID), new SqlParameter(BorrowDate, BBorrow.BorrowDate) ; int row = SqlOperator.Insert(sqlp, T_BORROW_Insert); return row; / / 更新?借书信?息 / / 返回?影响行D数y public int Update() SqlParameter sqlp = new SqlParameter new SqlParameter(CardID, BBorrow.CardID), new SqlParameter(ManID, BBorrow.ManID), new SqlParameter(ReturnDate, BBorrow.ReturnDate); int row = SqlOperator.Update(sqlp, T_BORROW_Update); return row; REaderdal.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Data.SqlClient;using ZDSoft.LibraryManage.Entity;namespace ZDSoft.LibraryManage.DAL public class ReaderDal private Reader RReader; pu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年计算机技术与软件专业技术资格(中级)《软件设计师》智慧海洋监测算法设计模拟考核试卷
- 旅游平台短视频内容创意策划考核试卷
- 媒体融合中的媒体融合人才培养计划策略考核试卷
- 模具激光表面处理技术与应用考核试卷
- 解析卷-人教版八年级上册物理物态变化《汽化和液化》专题攻克试题(含答案解析)
- 学生自主学习导学资源的建设及其应用研究
- 基于“计数单位”视角:苏教版教材中数与运算的整体化与一致性探究
- 重难点解析人教版八年级物理上册第5章透镜及其应用-生活中的透镜专项训练试题(详解版)
- 难点解析-人教版八年级物理上册第6章质量与密度-质量综合练习练习题(解析版)
- 2025年建筑节能政策咨询合同协议
- 海上风电基础知识培训课件
- 2025年医疗器械临床试验质量管理规范培训考试试题及答案
- 国际道路应急预案
- 人防指挥所信息化建设方案
- 生死疲劳阅读报告课件
- 胸椎管狭窄症诊疗规范
- 2025年国家管网集团高校毕业生招聘945人正式启动笔试参考题库附带答案详解
- 夜班护士安全培训内容课件
- 新版中华民族共同体概论课件第九讲混一南北与中华民族大统合 (元朝时期)-2025年版
- 2025至2030中国城际出行市场发展前景与趋势预测分析报告
- 征拆工作课件
评论
0/150
提交评论