62,046
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 登录
/// </summary>
/// <param name="code">代理商工号</param>
/// <param name="pwd">密码明文</param>
/// <returns></returns>
public AgentInfo Login(string code, string pwd)
{
if (string.IsNullOrEmpty(code))
throw new Exception("代理商工号不能为空");
if (string.IsNullOrEmpty(pwd))
throw new Exception("密码不能为空");
AgentInfo agent = this.Get(code);
if (agent == null)
throw new Exception("没有这个代理商编号");
pwd = this.MD5(pwd.ToLower());
if (!agent.Password.Equals(pwd))
throw new Exception("密码错误");
//...
OnAfterLogin(new AgentEventArgs(agent));
return agent;
}
private void Logon(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(chk.Text))
{
ltl_note.Text = "验证码不能为空";
}
else if (chk.Text.ToLower() != Session[CheckCode.LoginCode].ToString().ToLower())
{
ltl_note.Text = "验证码不正确";
}
else
{
try
{
ags.AfterLogin += new AgentEventHandler(this.CheckLogin);
AgentInfo agent = ags.Login(uid.Text, pwd.Text);
Session[SessionName] = agent;
Response.Redirect("Main.aspx");
}
catch (Exception ex)
{
ltl_note.Text = ex.Message;
}
}
}
private void CheckLogin(object sender, AgentEventArgs e)
{
//试用代理商再判断是不是已经有本区域正式代理商了。
if (e.Agent.Status == AgentStatusDefine.试用)
{
List<AgentInfo> list = ags.List(e.Agent.Area);
if (list != null && list.Count > 0)
{
int count = list.Count(a => a.Status == AgentStatusDefine.正式);
if (count > 0)
{
throw new Exception("本地区已经有正式代理商,试用代理商不能再登);
}
}
}
}
var a = true;
var i = 0; j = 0;
a && (i = 5);
a || (j = 5);
alert(i);
alert(j);
//上面的语句的意思就是
if(a){
i = 5;
}
if(!a){
j = 5;
}
//&& 和 || 可以结合使用。不过这样就不容易看懂了。