下面是用户注册系统开发的三层构架实例:数据库基类采用上面提供的代码。
1、用户注册模块数据层开发:
using System;
using System.Data;
using System.Data.SqlClient;
using HaiSky.HtJob;
using System.XML;
namespace HaiSky.HtJob.Accounts.AccountsData
{
public class User : HaiSky.HtJob.HaiSkyDbObject
{
public User(string newConnectionString) : base(newConnectionString)
{//直接路由连接字符串}
public int Create(string user_nm,string user_pwd)
{
int rowsAffected;
SqlParameter[] parameters = {new SqlParameter("@user_nm",SqlDBType.Char,16),
new
SqlParameter("@user_pwd",SqlDbType.Char,16)};
parameters[0].Value = user_nm;
parameters[1].Value = user_pwd;
parameters[2].Direction = ParameterDirection.Output;
try
{
RunProcedure("IF_user_info",parameters,out rowsAffected);
}
catch
{ }
return (int)parameters[2].Value;
}
}
}
2、用户注册商务层开发:
using System;
using System.Configuration;
using HaiSky.HtJob.Accounts.AccountsData;
namespace HaiSky.HtJob.Accounts.AccountBusiness
{
public class User : HaiSky.HtJob.HaiSkyBizObject