[高等教育]毕业设计附件封面.doc
毕 业 设 计 附 件 一程序清单专业 学生姓名王子悦班级U计算机081学号0811503126指导教师安晶AdminBLL.csusing System;using System.Collections.Generic;using System.Linq;using System.Web;using ProductStockSystem.Model;using ProductStockSystem.DAO;namespace ProductStockSystem.BLL / <summary> /AdminBll 的摘要说明:管理员信息处理的业务层 / </summary> public class AdminBLL /*保存业务逻辑错误信息*/ private string errMessage; public string getErrMessage() return this.errMessage; public AdminBLL() this.errMessage = "" /*验证用户登录信息*/ public bool CheckLogin(Admin admin) /*建立数据访问层对象*/ AdminDAO adminDAO = new AdminDAO(); /*首先验证用户名是否存在*/ if (!adminDAO.ExistUsername(admin.getUsername() this.errMessage = "对不起,用户名不存在!" return false; /*如果用户名存在再验证密码输入是否正确*/ if (!adminDAO.CheckUser(admin) this.errMessage = "对不起,密码错误!" return false; return true; /*修改密码*/ public bool ChangePassword(string username, string password) AdminDAO adminDAO = new AdminDAO(); return adminDAO.ChangePassword(username, password); AdminDAO.csusing System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Data;using ProductStockSystem.DB;using ProductStockSystem.Model;namespace ProductStockSystem.DAO / <summary> /AdminDAO 的摘要说明: 管理员信息处理数据层 / </summary> public class AdminDAO /*保存业务逻辑错误信息*/ private string errMessage; public void setErrMessage(string errMessage) this.errMessage = errMessage; public string getErrMessage() return this.errMessage; public AdminDAO() this.errMessage = "" public bool AddUser(string username, string password) if (username = "") this.errMessage = "用户名不能为空!" return false; if (password = "") this.errMessage = "密码不能为空!" return false; string querySql = "select * from admin where username=" + SqlString.GetQuotedString(username); DataBase db = new DataBase(); DataSet ds = db.GetDataSet(querySql); if (ds.Tables0.Rows.Count > 0) this.errMessage = "用户名已经存在!" return false; string insertString = "insert into admin (username,password) values (" insertString += SqlString.GetQuotedString(username) + "," + SqlString.GetQuotedString(password) + ")" if (db.InsertOrUpdate(insertString) < 0) this.errMessage = "用户添加失败!" return false; return true; /*查询帐号是否存在,存在返回true,不存在返回false*/ public bool ExistUsername(string username) DataBase db = new DataBase(); string query_sql = "select * from admin where username = " + SqlString.GetQuotedString(username); System.Data.DataSet ds = db.GetDataSet(query_sql); if (ds.Tables0.Rows.Count = 0) return false; return true; /*查询帐号密码是否都正确*/ public bool CheckUser(Admin admin) DataBase db = new DataBase(); string query_sql = "select * from admin where username = " + SqlString.GetQuotedString(admin.getUsername() + " and password = " + SqlString.GetQuotedString(admin.getPassword(); System.Data.DataSet ds = db.GetDataSet(query_sql); if (ds.Tables0.Rows.Count = 0) return false; return true; /*修改密码*/ public bool ChangePassword(string username, string password) string sql = "update admin set password=" + SqlString.GetQuotedString(password) + " where username='" + username + "'" DataBase db = new DataBase(); return db.InsertOrUpdate(sql) > 0; /*根据用户名查询用户信息*/ public static Admin GetAdminInfo(string username) Admin admin = null; string querySql = "select * from admin where username=" + SqlString.GetQuotedString(username); DataBase db = new DataBase(); System.Data.DataSet ds = db.GetDataSet(querySql); if (ds.Tables0.Rows.Count > 0) System.Data.DataRow dr = ds.Tables0.Rows0; admin = new Admin(); admin.setUsername(username); admin.setPassword(dr"password".ToString(); admin.setClassManageFlag(Convert.ToInt32(dr"class_manage_flag"); admin.setProductManageFlag(Convert.ToInt32(dr"product_manage_flag"); admin.setProductInFlag(Convert.ToInt32(dr"productIn_flag"); admin.setProductOutFlag(Convert.ToInt32(dr"productOut_flag"); admin.setStockFlag(Convert.ToInt32(dr"stock_flag"); admin.setQueryFlag(Convert.ToInt32(dr"record_query_flag"); admin.setSupplyerManageFlag(Convert.ToInt32(dr"supplyer_manage_flag"); admin.setCustomerManageFlag(Convert.ToInt32(dr"customer_manage_flag"); admin.setUserManageFlag(Convert.ToInt32(dr"user_manage_flag"); return admin; /*设置用户权限*/ public bool UpdateFlag(Admin admin) string updateString = "update admin set class_manage_flag=" updateString += admin.getClassManageFlag() + ",product_manage_flag=" updateString += admin.getProductManageFlag() + ",productIn_flag=" updateString += admin.getProductInFlag() + ",productOut_flag=" updateString += admin.getProductOutFlag() + ",stock_flag=" updateString += admin.getStockFlag() + ",record_query_flag=" updateString += admin.getQueryFlag() + ",supplyer_manage_flag=" updateString += admin.getSupplyerManageFlag() + ",customer_manage_flag=" updateString += admin.getCustomerManageFlag() + ",user_manage_flag=" updateString += admin.getUserManageFlag() + " where username=" + SqlString.GetQuotedString(admin.getUsername(); DataBase db = new DataBase(); return db.InsertOrUpdate(updateString) > 0; CustomerDAO.csusing System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using ProductStockSystem.Model;using ProductStockSystem.DB;/ <summary>/ CustomerDAO 的摘要说明:客户信息管理处理业务逻辑层/ </summary>public class CustomerDAO /*保存业务处理的错误信息*/ private string errMessage; public string getErrMessage() return this.errMessage; public CustomerDAO() this.errMessage = "" /*添加客户信息*/ public bool AddCustomer(Customer customer) /*验证客户名称不能为空*/ if (customer.getCustomerName() = "") this.errMessage = "对不起,客户名称输入不能为空!" return false; /*验证客户名称是否已经存在*/ string querySql = "select * from t_customer where customer_name=" + SqlString.GetQuotedString(customer.getCustomerName(); DataBase db = new DataBase(); DataSet ds = db.GetDataSet(querySql); if (ds.Tables0.Rows.Count > 0) this.errMessage = "对不起,该客户名称已经存在!" return false; /*执行客户信息的添加操作*/ string insertString = "insert into t_customer (customer_name,person_name,telephone,address) values (" insertString += SqlString.GetQuotedString(customer.getCustomerName() + "," insertString += SqlString.GetQuotedString(customer.getPersonName() + "," insertString += SqlString.GetQuotedString(customer.getTelephone() + "," insertString += SqlString.GetQuotedString(customer.getAddress() + ")" if (db.InsertOrUpdate(insertString) < 0) this.errMessage = "客户信息添加失败!" return false; return true; /*根据客户编号查询客户信息*/ public static Customer QueryCustomer(int customerId) Customer customer = null; string querySql = "select * from t_customer where customer_id=" + customerId; DataBase db = new DataBase(); DataSet ds = db.GetDataSet(querySql); if (ds.Tables0.Rows.Count > 0) DataRow dr = ds.Tables0.Rows0; customer = new Customer(); customer.setCustomerId(customerId); customer.setCustomerName(dr"customer_name".ToString(); customer.setPersonName(dr"person_name".ToString(); customer.setTelephone(dr"telephone".ToString(); customer.setAddress(dr"address".ToString(); return customer; /*删除客户信息*/ public bool DeleteCustomer(int customerId) /*查询是否还存在该客户的出库信息*/ string querySql = "select * from t_product_out where customer_id=" + customerId; DataBase db = new DataBase(); DataSet ds = db.GetDataSet(querySql); if (ds.Tables0.Rows.Count > 0) this.errMessage = "还存在该客户的出库信息!无法删除!" return false; /*执行客户信息的删除*/ string deleteString = "delete from t_customer where customer_id=" + customerId; if (db.InsertOrUpdate(deleteString) < 0) this.errMessage = "客户信息删除失败!" return false; return true; ProductClassDAO.csusing System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using ProductStockSystem.DB;using ProductStockSystem.Model;using System.Collections;namespace ProductStockSystem.DAO / <summary> / ProductClassDAO 的摘要说明:图书类别信息处理数据层 / </summary> public class ProductClassDAO private string errMessage; public string getErrMessage() return this.errMessage; public ProductClassDAO() this.errMessage = "" /*添加图书类别信息*/ public bool AddProductClass(ProductClass productClass) if (productClass.getClassName() = "") this.errMessage = "请输入图书类别名称!" return false; DataBase db = new DataBase(); string query_sql = "select * from t_class where class_name = " + SqlString.GetQuotedString(productClass.getClassName(); System.Data.DataSet ds = db.GetDataSet(query_sql); if (ds.Tables0.Rows.Count > 0) this.errMessage = "你输入的图书类别名称已经存在!" return false; string sql = "insert into t_class (class_name) values (" + SqlString.GetQuotedString(productClass.getClassName() + ")" return db.InsertOrUpdate(sql) > 0; /*根据图书类别编号取得图书类别信息*/ public static ProductClass GetProductClass(int classId) ProductClass productClass = null; string queryString = "select * from t_class where class_id=" + classId; DataBase db = new DataBase(); DataSet classDs = db.GetDataSet(queryString); if (classDs.Tables0.Rows.Count > 0) DataRow dr = classDs.Tables0.Rows0; productClass = new ProductClass(); productClass.setClassId(classId); productClass.setClassName(dr"class_name".ToString(); return productClass; /*更新图书类别信息*/ public bool UpdateProductClass(ProductClass productClass) if (productClass.getClassName() = "") this.errMessage = "请输入图书类别名称!" return false; DataBase db = new DataBase(); string query_sql = "select * from t_class where class_id<>" + productClass.getClassId() + " and class_name = " + SqlString.GetQuotedString(productClass.getClassName(); System.Data.DataSet ds = db.GetDataSet(query_sql); if (ds.Tables0.Rows.Count > 0) this.errMessage = "你输入的图书类别名称已经存在!" return false; string sql = "update t_class set class_name=" + SqlString.GetQuotedString(productClass.getClassName() + " where class_id=" + productClass.getClassId(); return db.InsertOrUpdate(sql) > 0; /*删除某个图书类别*/ public bool DeleteProductClass(int classId) /*首先查询该图书类别下是否还存在图书信息*/ string querySql = "select * from t_product where class_id=" + classId; DataBase db = new DataBase(); DataSet ds = db.GetDataSet(querySql); if (ds.Tables0.Rows.Count > 0) this.errMessage = "对不起,还存在该类别的图书信息!" return false; /*如果该类别下已经没有图书信息了就开始执行删除操作*/ string deleteString = "delete from t_class where class_id=" + classId; if (db.InsertOrUpdate(deleteString) < 0) this.errMessage = "删除图书类别信息发生了错误!" return false; return true; /*查询所有的图书类别*/ public ArrayList QueryAllProductClass() ArrayList classList = new ArrayList(); string queryString = "select * from t_class" DataBase db = new DataBase(); DataSet classDs = db.GetDataSet(queryString);