展开全部
写个最简单的
string userName=textbox1.text;
string userPass=textbox2.text;
if(userName!="" && userPass!="")
{
//登陆成功
}else
{
//登陆失败
}
string userName=textbox1.text;
string userPass=textbox2.text;
if(userName!="" && userPass!="")
{
//登陆成功
}else
{
//登陆失败
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数据层
private static SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TongShaConnectionString"].ConnectionString);
public static SqlConnection Conn
{
get
{
switch (conn.State)
{
case ConnectionState.Broken:
conn.Open();
conn.Close();
break;
case ConnectionState.Closed:
conn.Open();
break;
case ConnectionState.Connecting:
break;
case ConnectionState.Executing:
break;
case ConnectionState.Fetching:
break;
case ConnectionState.Open:
break;
default:
break;
}
return conn;
}
set { conn = value; }
}
public object TongShaSelectOne(object ziduan, object biao, object tiaojian)
{
string strSQL = string.Format("select {0} from {1} where {2}",ziduan,biao,tiaojian);
object i = TongSha_SQLHelper.GetScalar(strSQL);
return i;
}
业务层:
TongSha_SQLService ts = new TongSha_SQLService();
public object GetManagerUserByNameAndPassWord(object manageuserUserName, object manageUserPassWord)
{
string ziduan = "ManageUserId";
string biao = "ManagerUser";
string tiaojian = string.Format("ManageuserUserName='{0}' and ManageUserPassWord='{1}' and ManageUserState=0", manageuserUserName, manageUserPassWord);
object id= ts.TongShaSelectOne(ziduan, biao, tiaojian);
return id;
}
表示层:
ManagerUserManager mum = new ManagerUserManager();
object manageUserId = mum.GetManagerUserByNameAndPassWord(manageuserUserName, manageUserPassWord);
if (Convert.ToString(manageUserId)!="")
{
Response.Cookies["ManagerUserId"].Value = Convert.ToString(manageUserId);
Response.Cookies["ManagerUserId"].Expires = DateTime.Now.AddDays(1);
Response.Redirect("Index.aspx");
}
else
{
Page.RegisterStartupScript("alert", "<script>alert('用户名或密码错误!');location.href='Login.aspx'</script>");
return;
}
数据库不用给了吧!!!!!
private static SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TongShaConnectionString"].ConnectionString);
public static SqlConnection Conn
{
get
{
switch (conn.State)
{
case ConnectionState.Broken:
conn.Open();
conn.Close();
break;
case ConnectionState.Closed:
conn.Open();
break;
case ConnectionState.Connecting:
break;
case ConnectionState.Executing:
break;
case ConnectionState.Fetching:
break;
case ConnectionState.Open:
break;
default:
break;
}
return conn;
}
set { conn = value; }
}
public object TongShaSelectOne(object ziduan, object biao, object tiaojian)
{
string strSQL = string.Format("select {0} from {1} where {2}",ziduan,biao,tiaojian);
object i = TongSha_SQLHelper.GetScalar(strSQL);
return i;
}
业务层:
TongSha_SQLService ts = new TongSha_SQLService();
public object GetManagerUserByNameAndPassWord(object manageuserUserName, object manageUserPassWord)
{
string ziduan = "ManageUserId";
string biao = "ManagerUser";
string tiaojian = string.Format("ManageuserUserName='{0}' and ManageUserPassWord='{1}' and ManageUserState=0", manageuserUserName, manageUserPassWord);
object id= ts.TongShaSelectOne(ziduan, biao, tiaojian);
return id;
}
表示层:
ManagerUserManager mum = new ManagerUserManager();
object manageUserId = mum.GetManagerUserByNameAndPassWord(manageuserUserName, manageUserPassWord);
if (Convert.ToString(manageUserId)!="")
{
Response.Cookies["ManagerUserId"].Value = Convert.ToString(manageUserId);
Response.Cookies["ManagerUserId"].Expires = DateTime.Now.AddDays(1);
Response.Redirect("Index.aspx");
}
else
{
Page.RegisterStartupScript("alert", "<script>alert('用户名或密码错误!');location.href='Login.aspx'</script>");
return;
}
数据库不用给了吧!!!!!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询