扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
/// <SUMMARY>
/// Function Add new customer. Calls
/// the function in Data layer.
/// </SUMMARY>
public void Add()
{
cusData.Add(this);
}
/// <SUMMARY>
/// Function Update customer details.
/// Calls the function in Data layer.
/// </SUMMARY>
public void Update()
{
cusData.Update(this);
}
/// <SUMMARY>
/// Function Find customer. Calls the
/// function in Data layer.
/// It returns the details of the customer using
/// customer ID via a Dataset to GUI tier.
/// </SUMMARY>
public DataSet Find(String str)
{
if (str == "")
throw new Exception("Please provide ID to search");
DataSet data = null;
data = cusData.Find(str);
return data;
}
}
}
数据访问层
数据层包括处理MS Access数据库的细节。所有这些细节都是透明的,不会影响到商业逻辑层。数据访问层有个指向商业逻辑层的引用BOCustomer cus。为了应用方便并且支持其他数据库。
using System;
using System.Data.OleDb;
using System.Data;
namespace _3tierarchitecture
{
/// <SUMMARY>
/// Summary description for DACustomer.
/// </SUMMARY>
public class DACustomer
{
private OleDbConnection cnn;
//change connection string as per the
//folder you unzip the files
private const string CnnStr =
"Provider=Microsoft.Jet.OLEDB.4.0;Data " +
"Source= D:\\Rahman_Backup\\Programming\\" +
"Csharp\\3tierarchitecture\\customer.mdb;";
//local variables
private String strTable="";
private String strFields="";
private String strValues="";
private String insertStr="";
//this needs to be changed based on customer
//table fields'' Name of the database!
private const String thisTable = "tblCustomer";
private const String cus_ID = "CUS_ID";
private const String cus_LName = "CUS_L_NAME";
private const String cus_FName = "CUS_F_NAME";
private const String cus_Tel = "CUS_TEL";
private const String cus_Address = "CUS_ADDRESS";
public DACustomer()
{
}
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者