|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
听03很多师兄说主讲老师杭城方讲课很差就连旁听也没有去了)用户注册 上面是用户注册体系开辟的三层构架实例:数据库基类接纳下面供应的代码。
1、用户注册模块数据层开辟:
usingSystem;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingHaiSky.HtJob;
usingSystem.Xml;
namespaceHaiSky.HtJob.Accounts.AccountsData
{
publicclassUser:HaiSky.HtJob.HaiSkyDbObject
{
publicUser(stringnewConnectionString):base(newConnectionString)
{//间接路由毗连字符串}
publicintCreate(stringuser_nm,stringuser_pwd)
{
introwsAffected;
SqlParameter[]parameters={newSqlParameter("@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,outrowsAffected);
}
catch
{}
return(int)parameters[2].Value;
}
}
}
2、用户注册商务层开辟:
usingSystem;
usingSystem.Configuration;
usingHaiSky.HtJob.Accounts.AccountsData;
namespaceHaiSky.HtJob.Accounts.AccountBusiness
{
publicclassUser:HaiSky.HtJob.HaiSkyBizObject
{
intuserID;
stringuserName;
stringuserPwd;
stringstrConn;
publicUser()
{
strConn=ConfigurationSettings.AppSettings["strConn"];
}
publicintCareate()
{
AccountsData.UserdataUser=newAccountsData.User(strConn);
userID=dataUser.Create(userName,userPwd);
returnuserID;
}
publicintUserID
{
get
{
returnuserID;
}
set
{
userID=value;
}
}
publicstringUserName
{
get
{
returnuserName;
}
set
{
userName=value;
}
}
publicstringUserPwd
{
get
{
returnuserPwd;
}
set
{
userPwd=value;
}
}
}
}
3、用户注册暗示层开辟:
usingSystem;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Web;
usingSystem.Web.SessionState;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.HtmlControls;
usingHaiSky.HtJob.Accounts.AccountBusiness;
namespaceHaiSky.HtJob.Modules.Accounts
{
publicclassRegister:System.Web.UI.Page
{
protectedSystem.Web.UI.WebControls.TextBoxTextBox1;
protectedSystem.Web.UI.WebControls.TextBoxTextBox2;
protectedSystem.Web.UI.WebControls.TableTable1;
protectedSystem.Web.UI.WebControls.ButtonButton1;
privatevoidPage_Load(objectsender,System.EventArgse)
{
Table1.Rows[0].Cells[0].Visible=false;
}
#regionWebFormDesignergeneratedcode
overrideprotectedvoidOnInit(EventArgse)
{
InitializeComponent();
base.OnInit(e);
}
privatevoidInitializeComponent()
{
this.Button1.Click+=newSystem.EventHandler(this.Button1_Click);
this.Load+=newSystem.EventHandler(this.Page_Load);
}
#endregion
privatevoidButton1_Click(objectsender,System.EventArgse)
{
inti;
HtJob.Accounts.AccountBusiness.UserBusinessUser=newHtJob.Accounts.AccountBusiness.User();
BusinessUser.UserName=TextBox1.Text;
BusinessUser.UserPwd=TextBox2.Text;
i=BusinessUser.Careate();
Response.Write(i.ToString());//这里输入前往值
}
}
}
4、该体系挪用的存储历程:
CREATEPROCEDUREIF_user_info
(@user_nmchar(16),@user_pwdchar(16),@user_IDintoutput)
AS
insertuser_info(user_nm,user_pwd)values(@user_nm,@user_pwd)
set@user_ID=@@identity
IF@@ERROR>0
BEGIN
RAISERROR(InsertofArticlefailed,16,1)如果需要重新编写代码,几乎任何一门计算机语言都可以跨平台了,还用得着Java嘛,而且像PHP/C#等语言不需要修改代码都可以跨Windows/Linux。 |
|