private void checkSitehostUsername() { Response.ContentType = "txt/html"; Response.Clear(); wgiAdUnionSystem.BLL.wgi_sitehost bll = new wgiAdUnionSystem.BLL.wgi_sitehost(); string name = Request["username"]; if (bll.GetListByUsername(name).Tables[0].Rows.Count > 0) Response.Write("0"); else Response.Write("1"); Response.End(); }
protected void btn_login(object sender, EventArgs e) { string sessioncode = ""; try { if (Session["CheckCode"] != null && Session["CheckCode"].ToString() == "") return; else sessioncode = Session["CheckCode"].ToString(); } catch (Exception) { this.Page.Response.Redirect("/member/Default.aspx"); } if (sessioncode.ToLower().Equals(txtCode.Text.ToLower())) { UserPrincipal principal = new UserPrincipal(txtUser.Text, txtPass.Text, 2); if (!principal.Identity.IsAuthenticated) { lblLoginMessage.Visible = true; switch (principal.CheckStatus) { case 1: lblLoginMessage.Text = "用户名不正确!"; break; case 2: lblLoginMessage.Text = "用户名密码错误!"; break; case 3: lblLoginMessage.Text = "您的账户尚未被审核通过!"; break; case 4: lblLoginMessage.Text = "您的账户已被锁定!"; break; default: lblLoginMessage.Text = "未知错误!"; break; } } else { //如果用户通过验证,则将用户信息保存在缓存中,以备后用 //在实际中,朋友们可以尝试使用用户验证票的方式来保存用户信息,这也是.NET内置的用户处理机制 Context.User = principal; string userdata = ""; wgiAdUnionSystem.BLL.wgi_sitehost bll = new wgiAdUnionSystem.BLL.wgi_sitehost(); DataTable dt = bll.GetListByUsername(principal.Identity.Name).Tables[0]; if (dt != null && dt.Rows.Count > 0) { userdata = "member|" + dt.Rows[0]["userid"].ToString() + "|" + dt.Rows[0]["username"].ToString() + "|" + Convert.ToDateTime(dt.Rows[0]["lastdate"]).ToString("yyyy-MM-dd HH:mm:ss") + "|" + dt.Rows[0]["contact"].ToString() + "|" + dt.Rows[0]["balance"].ToString(); } string uid = dt.Rows[0]["userid"].ToString(); string uname = dt.Rows[0]["username"].ToString(); try { bll.updateLoginTime(int.Parse(uid), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //记录学员登录时间 wgiAdUnionSystem.Model.wgi_loginlog logs = new wgiAdUnionSystem.Model.wgi_loginlog(); //logs.logid = int.Parse(uid); logs.logip = CommonData.GetIp(this.Page); logs.logname = uname; logs.logtime = DateTime.Now; logs.usertype = 1;//1表示网站主 new wgiAdUnionSystem.BLL.wgi_loginlog().Add(logs); } catch (Exception ex) { Response.Write("<script>alert('内部错误!');location.href='/index.aspx'</script>"); } //Session["sid"] = uid; //Session["utype"] = "member"; FlowControl.SaveLoginInfo(principal.Identity.Name, userdata); //Response.Redirect("/member/Default.aspx"); //setpanel(); initData(); string[] userdatas = userdata.Split('|'); this.lblbank.Text = userdatas[5] + "元"; this.lbllast.Text = userdatas[3]; this.lblname.Text = userdatas[4]; this.lbluname.Text = userdatas[2]; if (!string.IsNullOrEmpty(Request.QueryString["url"])) this.Page.Response.Redirect(Request["url"]); } } else { lblLoginMessage.Visible = true; lblLoginMessage.Text = "验证码错误!"; } }
protected void dosubmit(object sender, CommandEventArgs e) { wgiAdUnionSystem.BLL.wgi_sitehost bll = new wgiAdUnionSystem.BLL.wgi_sitehost(); string username = ""; if (e.CommandArgument.ToString() == "add") { username = this.txtusername.Text; if (bll.GetListByUsername(username).Tables[0].Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('用户名已被使用');", true); return; } } string password = this.txtpassword.Text; string email = this.txtemail.Text; string mobile = this.txtmobile.Text; string accountname = this.txtaccountname.Text; string accountno = this.txtaccountno.Text; string bank = this.txtbank.Text; string branch = this.txtbranch.Text; int usertype = 1;//usertype是个人/网站/博客等,因为已经在usersite里面可以多重定义,所以改为用户在系统里的类型,如网站主,广告主 string contact = this.txtcontact.Text; string qq = this.txtqq.Text; string idcard = this.txtidcard.Text; string address = this.txtaddress.Text; string zipcode = this.txtzipcode.Text; string tel = this.txttel.Text; decimal balance = Convert.ToDecimal(0.00); DateTime regdate = DateTime.Now; string regip = CommonData.GetIp(this.Page); //DateTime lastdate = DateTime.Now; //string lastip = ""; int status = 1;//0表示尚未审核通过,暂时默认网站主注册即通过 if (e.CommandArgument.ToString() == "add") { wgiAdUnionSystem.Model.wgi_sitehost model = new wgiAdUnionSystem.Model.wgi_sitehost(); model.username = username; model.password = password; model.email = email; model.mobile = mobile; model.contact = contact; model.qq = qq; model.idcard = idcard; model.address = address; model.zipcode = zipcode; model.tel = tel; //银行账户信息允许管理员添加,却不允许管理员更改 model.accountname = accountname; model.accountno = accountno; model.bank = bank; model.branch = branch; //账号状态信息自动读取,不允许编辑 //model.balance = balance; //model.lastdate = lastdate; //model.lastip = lastip; model.regdate = regdate; model.regip = regip; model.usertype = usertype; model.status = status; try { bll.Add(model); ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('添加成功');top.location=top.location;", true); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('内部错误');", true); } } else if (e.CommandArgument.ToString() == "edit") { try { int userid = int.Parse(this.hiduid.Value); wgiAdUnionSystem.Model.wgi_sitehost model = bll.GetModel(userid); model.password = password; model.email = email; model.mobile = mobile; model.contact = contact; model.qq = qq; model.idcard = idcard; model.address = address; model.zipcode = zipcode; model.tel = tel; if (ddlstatus.Visible = true) model.status = int.Parse(ddlstatus.Text); bll.Update(model); ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('修改成功');top.location=top.location;", true); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('内部错误');", true); } } }
protected void btnAdd_Click(object sender, EventArgs e) { string username = this.txtusername.Text; wgiAdUnionSystem.BLL.wgi_sitehost bll = new wgiAdUnionSystem.BLL.wgi_sitehost(); if (bll.GetListByUsername(username).Tables[0].Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('用户名已被使用');", true); return; } #region 服务器验证 string strErr = ""; if (this.txtusername.Text == "") { strErr += "username不能为空!\\n"; } if (this.txtpassword.Text == "") { strErr += "password不能为空!\\n"; } if (this.txtpassword.Text != this.txtpwd2.Text) { strErr += "password不能为空!\\n"; } if (this.txtemail.Text == "") { strErr += "email不能为空!\\n"; } if (this.txtmobile.Text == "" && this.txttel.Text == "") { strErr += "电话、手机至少选填一项!\\n"; } if (this.txtaccountname.Text == "") { strErr += "accountname不能为空!\\n"; } if (this.txtaccountno.Text == "") { strErr += "accountno不能为空!\\n"; } if (this.txtbank.Text == "") { strErr += "bank不能为空!\\n"; } if (this.txtbranch.Text == "") { strErr += "branch不能为空!\\n"; } //if (!PageValidate.IsNumber(txtusertype.Text)) //{ // strErr += "usertype不是数字!\\n"; //} if (this.txtcontact.Text == "") { strErr += "contact不能为空!\\n"; } //if (this.txtqq.Text == "") //{ // strErr += "qq不能为空!\\n"; //} if (this.txtidcard.Text == "") { strErr += "idcard不能为空!\\n"; } //if (this.txtaddress.Text == "") //{ // strErr += "address不能为空!\\n"; //} //if (this.txtzipcode.Text == "") //{ // strErr += "zipcode不能为空!\\n"; //} //if (!PageValidate.IsNumber(txtstatus.Text)) //{ // strErr += "status不是数字!\\n"; //} if (strErr != "") { MessageBox.Show(this, strErr); return; } #endregion string password = this.txtpassword.Text; string email = this.txtemail.Text; string mobile = this.txtmobile.Text; string accountname = this.txtaccountname.Text; string accountno = this.txtaccountno.Text; string bank = this.txtbank.Text; string branch = this.txtbranch.Text; int usertype = 1;//usertype是个人/网站/博客等 string contact = this.txtcontact.Text; string qq = this.txtqq.Text; string idcard = this.txtidcard.Text; string address = this.txtaddress.Text; string zipcode = this.txtzipcode.Text; string tel = this.txttel.Text; decimal balance = Convert.ToDecimal(0.00); DateTime regdate = DateTime.Now; string regip = CommonData.GetIp(this.Page); //DateTime lastdate = DateTime.Now; //string lastip = ""; int status = 1;//0表示尚未审核通过,暂时默认网站主注册即通过 wgiAdUnionSystem.Model.wgi_sitehost model = new wgiAdUnionSystem.Model.wgi_sitehost(); model.username = username; model.password = password; model.email = email; model.mobile = mobile; model.accountname = accountname; model.accountno = accountno; model.bank = bank; model.branch = branch; model.usertype = usertype; model.contact = contact; model.qq = qq; model.idcard = idcard; model.address = address; model.zipcode = zipcode; model.tel = tel; model.balance = balance; model.regdate = regdate; model.regip = regip; //model.lastdate = lastdate; //model.lastip = lastip; model.status = status; try { bll.Add(model); Response.Redirect("regSuccess.aspx"); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('内部错误');", true); } }