在三层体系结构中登录的代码-BAL DAL表示层 [英] code for login in threetier architecture -BAL DAL Presentation layer

查看:165
本文介绍了在三层体系结构中登录的代码-BAL DAL表示层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我了解如何在三层体系结构中为登录页面编写代码

我拿了1>这样的文件夹实用程序:数据库连接和其他功能...
2> datacontainer:在此我声明参数并设置如下所示的get属性

private int _loginid;
私有字符串_username;
private String _password;

public int loginid
{
get {return _loginid;}
设置{_loginid = Value;}
}

像往常一样,我写了用户名和密码

3>来到数据层,我声明了数据容器的对象,并在数据层中编写了如下代码

私有void NacreLogin(DataContainer objdc,字符串CmdText)
{
util.Open();
SqlCommand Cmd =新的SqlCommand();
Cmd.Parameters.Clear();
Cmd.Connection = util.SqlCon; /*此处由于安全级别的缘故,我无法访问SqlCon */
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.CommandText = CmdText;
Cmd.Parameters.Add("@ loginid",SqlDbType.Int).Value = objdc.loginid;
Cmd.Parameters.Add("@ username",SqlDbType.VarChar).Value = objdc.username;
Cmd.Parameters.Add("@ password",SqlDbType.VarChar).Value = objdc.password;
}
我的疑问是
如何用商务逻辑编写代码.
当我设计并编写login.aspx的代码时.然后在username,password和loginid中输入用于登录的值.业务逻辑中的流程是什么
如何将输入的值与数据库sp_tbl_login存储的过程值进行比较.

预先感谢

any one pls help me out how to write code for login page in three tier architecture

i took folders like 1> Utilities : database connections and extra......
2> datacontainer: in this i declare parameters and set get properties like below

private int _loginid;
private string _username;
private String _password;

public int loginid
{
get{return _loginid;}
set {_loginid =Value;}
}

as usual username and password i wrote

3> coming to datalayer i declared object of datacontainer and i write code like below in datalayer

private void NacreLogin(DataContainer objdc, string CmdText)
{
util.Open();
SqlCommand Cmd = new SqlCommand();
Cmd.Parameters.Clear();
Cmd.Connection = util.SqlCon;/*here iam getting SqlCon not accessble due to security level*/
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.CommandText = CmdText;
Cmd.Parameters.Add("@loginid", SqlDbType.Int).Value = objdc.loginid;
Cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = objdc.username;
Cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = objdc.password;
}
My doubts are
how to write code in buisness logic.
when i design and code login.aspx . and enter the values in username,password and loginid for login.what is the process in business logic
how entered values will be compared to database sp_tbl_login storedprocedure values.

Thanks In Advance

推荐答案

老实说.修正您的代码.这个过程很明显.传递用户名和密码,如果有效,请找回.当人们知道很多流行词(例如3层),却不知道如何编写最琐碎的任务时,这总是令人担忧的.您无法访问对象b/c,这在您的设计中存在问题.我们不知道那是什么,基于1/2您发布的错误消息,并且无法访问SqlCon属性.但是,您的数据层应包含连接.它还会住在哪里?

为什么登录方法会接受要调用的proc的名称?这似乎使我感到沮丧.您将拥有许多共享此方法的不同登录过程?
Honestly. Fix your code. The process is obvious. Pass in the username and password and get back if it''s valid. It''s always concerning when people know lots of buzzwords (like 3 tier), but don''t know how to code the most trivial task. You can''t access the object b/c there''s an issue in your design. We don''t know what that is, based on the 1/2 an error message you posted, and no access to the SqlCon property. Your data layer should contain the connection, however. Where else would it live ?

Why would a login method accept the name of the proc to call ? That seems retarded to me. you''ll have many different login procs that share this method ?


这篇关于在三层体系结构中登录的代码-BAL DAL表示层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆