protected void btnSubmit_Click(object sender, EventArgs e) { pwdsp.InnerText = ""; usernamesp.InnerText = ""; string userName = txtUserName.Value; string pwd = txtPwd.Value; if (string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(pwd)) { usernamesp.InnerText = "用户名不能为空!"; pwdsp.InnerText = ""; } if (string.IsNullOrEmpty(pwd) && !string.IsNullOrEmpty(userName)) { usernamesp.InnerText = ""; pwdsp.InnerText = "密码不能为空!"; } if (string.IsNullOrEmpty(pwd) && string.IsNullOrEmpty(userName)) { pwdsp.InnerText = "密码不能为空!"; usernamesp.InnerText = "用户名不能为空!"; } UserLoginBLL bll = new UserLoginBLL(); UserLogin user = bll.GetUserByUserName(userName); if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(pwd)) { if (user == null) { usernamesp.InnerText = "用户名不存在!"; //Response.Write("<script>alert('用户名不存在');</script>"); } else { if (user.Pwd == pwd) { Session["UserName"] = userName; Response.Redirect("Defult.aspx"); } else { usernamesp.InnerText = " "; pwdsp.InnerText = "密码错误!"; //Response.Write("<script> alert('密码错误!');</script>"); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null) { //未登录则跳转到登录页面 Response.Redirect("/Login.aspx"); } //if (Request.QueryString["UserName"] == null) //{ // Response.Redirect("/Login.aspx"); // } string username = Session["UserName"].ToString(); UserLogin user = bll.GetUserByUserName(username); StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append(string.Format("<p><img src='{0}' alt='' /></p><p>{1}</p><p>{2}</p>", user.Head, user.UserName, user.Sex)); sb.Append("</div>"); person.InnerHtml = sb.ToString(); List <GetEssay> allessayList = bll3.GetAllEssay(); StringBuilder sbAllEss = new StringBuilder(); if (allessayList != null) { sbAllEss.Append("<span class='list-title'><span style = 'display: block;float: left; margin-left: 22px;width:103.6px;color: #2ed4b4;'>序号</span><span style = 'display: block;float: left; width:349.6px;color: #2ed4b4;'> 标题 </span><span style ='display: block;float: left; width:103.6px;color: #2ed4b4;'>作者</span></span> "); foreach (var item in allessayList) { sbAllEss.Append(string.Format("<span class='list-item' id = 'ess{0}' runat='server'><a class='link' href='EssCont.aspx?SEssid={1}'>", item.Id, item.Id)); sbAllEss.Append(string.Format("<span style='display: block; float: left; margin-left: 22px;width:103.6px; color: #2ed4b4;'>{0}</span>", item.Id)); sbAllEss.Append(string.Format("<span style='display: block; float: left; width:349.6px; color: black;'>{0}</span>", item.Title)); sbAllEss.Append(string.Format("<span style='display: block; float: left; width:103.6px; color: black;'>{0}</span>", item.Author)); sbAllEss.Append("</a></span>"); } ess.InnerHtml = sbAllEss.ToString(); } else { sbAllEss.Append("<span class='list-title'><span style = 'display: block;float: left; margin-left: 22px;width:103.6px;color: #2ed4b4;'>序号</span><span style = 'display: block;float: left; width:349.6px;color: #2ed4b4;'> 标题 </span><span style ='display: block;float: left; width:103.6px;color: #2ed4b4;'>作者</span></span> "); ess.InnerHtml = sbAllEss.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null) { //未登录则跳转到登录页面 Response.Redirect("/Login.aspx"); } //if (Request.QueryString["UserName"] == null) //{ // Response.Redirect("/Login.aspx"); // } string username = Session["UserName"].ToString(); UserLogin user = bll.GetUserByUserName(username); StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append(string.Format("<p><img src='{0}' alt='' /></p><p>{1}</p><p>{2}</p>", user.Head, user.UserName, user.Sex)); sb.Append("</div>"); person.InnerHtml = sb.ToString(); int id = Convert.ToInt32(Request.QueryString["SEssid"]); GetEssay singleEssay = bll3.GetSingleEssayById(id); StringBuilder sbSingleEss = new StringBuilder(); if (singleEssay != null) { sbSingleEss.Append(string.Format("<span class='list-title'><span style = 'display: block;float: left; margin-left: 22px;width:103.6px;color: #2ed4b4;'>序号:{0}</span><span style = 'display: block;float: left; width:349.6px;color: #2ed4b4;'>标题:{1}</span><span style ='display: block;float: left; width:203.6px;color: #2ed4b4;'>作者:{2}</span></span> ", singleEssay.Id, singleEssay.Title, singleEssay.Author)); sbSingleEss.Append(string.Format("<div>{0}</div>", GetInterIDList(singleEssay.Textpath))); ess.InnerHtml = sbSingleEss.ToString(); } else { //sbSingleEss.Append("<span class='list-title'><span style = 'display: block;float: left; margin-left: 22px;width:103.6px;color: #2ed4b4;'>序号</span><span style = 'display: block;float: left; width:349.6px;color: #2ed4b4;'> 标题 </span><span style ='display: block;float: left; width:103.6px;color: #2ed4b4;'>作者</span></span> "); ess.InnerHtml = ""; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null) { //未登录则跳转到登录页面 Response.Redirect("/Login.aspx"); } string username = Session["UserName"].ToString(); UserLogin user = bll.GetUserByUserName(username); StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append(string.Format("<p><img src='{0}' alt='' width='96px' height='96px' /></p><p>{1}</p><p>{2}</p>", user.Head, user.UserName, user.Sex)); sb.Append("</div>"); p_person.InnerHtml = sb.ToString(); //显示头像 StringBuilder sbhead = new StringBuilder(); sbhead.Append(string.Format("<img src='{0}' alt='' width='96px' height='96px' />", user.Head)); head.InnerHtml = sbhead.ToString(); p_username.InnerText = user.UserName; StringBuilder sb1 = new StringBuilder(); sb1.Append(string.Format("<input type='text'name='nick' value ='{0}' />", user.Nick.Trim())); p_nick.InnerHtml = sb1.ToString(); StringBuilder sb2 = new StringBuilder(); sb2.Append(string.Format("<input type='tel' class='tiny' data-role='birthyear' name='year' value ='{0}'><span class='tiny - inline - label'>年</span>", user.Year.Trim())); sb2.Append(string.Format("<input type='tel' class='ex - tiny' data -role='birthmonth' name='mouth' value ='{0}'><span class='tiny - inline - label'> 月</span>", user.Mouth.Trim())); sb2.Append(string.Format("<input type='tel' class='ex - tiny 'data-role='birthday' name='day' value ='{0}'><span class='tiny - inline - label'>日</span>", user.Day.Trim())); p_bir.InnerHtml = sb2.ToString(); StringBuilder sb3 = new StringBuilder(); StringBuilder sb4 = new StringBuilder(); if (user.Sex.Trim() == "男") { sb3.Append("<input type = 'radio' class='styledbox' id='radio-gender-1' data-role='gender 'name='rb' value='M' checked>"); p_rb1.InnerHtml = sb3.ToString(); sb4.Append("<input type = 'radio' class='styledbox' id='radio-gender-2' data-role='gender 'name='rb' value='W'>"); p_rb2.InnerHtml = sb4.ToString(); } else { sb3.Append("<input type = 'radio' class='styledbox' id='radio-gender-1' data-role='gender 'name='rb' value='M' >"); p_rb1.InnerHtml = sb3.ToString(); sb4.Append("<input type = 'radio' class='styledbox' id='radio-gender-2' data-role='gender 'name='rb' value='W' checked>"); p_rb2.InnerHtml = sb4.ToString(); } //加载文章 string author = Session["UserName"].ToString(); List <GetEssay> essayList = bll3.GetEssayByAuthor(author); StringBuilder sbessay = new StringBuilder(); if (essayList != null) { sbessay.Append("<span class='list-title'><span style = 'display: block;float: left; margin-left: 22px;width:103.6px;color: #2ed4b4;'>序号</span><span style = 'display: block;float: left; width:249.6px;color: #2ed4b4;'> 标题 </span><span style ='display: block;float: left; width:103.6px;color: #2ed4b4;'>作者</span></span> "); foreach (var item in essayList) { sbessay.Append(string.Format("<span class='list-item' id = 'ess{0}' runat='server'><a class='link'>", item.Id)); sbessay.Append(string.Format("<span style='display: block; float: left; margin-left: 22px;width:103.6px; color: #2ed4b4;'>{0}</span>", item.Id)); sbessay.Append(string.Format("<span style='display: block; float: left; width:249.6px; color: black;'>{0}</span>", item.Title)); sbessay.Append(string.Format("<span style='display: block; float: left; width:103.6px; color: black;'>{0}</span>", item.Author)); sbessay.Append("</a></span>"); } essay.InnerHtml = sbessay.ToString(); } else { sbessay.Append("<span class='list-title'><span style = 'display: block;float: left; margin-left: 22px;width:103.6px;color: #2ed4b4;'>序号</span><span style = 'display: block;float: left; width:249.6px;color: #2ed4b4;'> 标题 </span><span style ='display: block;float: left; width:103.6px;color: #2ed4b4;'>作者</span></span> "); essay.InnerHtml = sbessay.ToString(); } }
protected void Button1_Click(object sender, EventArgs e) { string userName = txtUserName.Text.Trim(); string pwd = txtPwd.Text; string pwd1 = txtPwd1.Text; string nick = txtNick.Text; string sex = ""; string head = "/img/touxiang.png"; UserLogin getuser = bll2.GetUserByUserName(userName); if (getuser != null) { usernamesp.InnerText = "用户名已存在,请重新输入"; } //123 if (userName == "") { usernamesp.InnerText = "请输入用户名!"; } if (nick == "") { nicksp.InnerText = "昵称不能为空!"; } if (pwd == "") { pwdsp.InnerText = "密码不能为空!"; } if (pwd != pwd1) { pwdsp1.InnerText = "密码不一致,请重新输入"; } if (txtYear.Value == "" || txtMouth.Value == "" || txtDay.Value == "") { ymdsp.InnerText = "请输入日期!"; } if (getuser == null && userName != "" && nick != "" && pwd != "" && pwd == pwd1 && txtYear.Value != "" && txtMouth.Value != "" && txtDay.Value != "") { usernamesp.InnerText = ""; nicksp.InnerText = ""; pwdsp.InnerText = ""; pwdsp1.InnerText = ""; ymdsp.InnerText = ""; int yearint, mouthint, dayint; try { yearint = Convert.ToInt32(txtYear.Value); mouthint = Convert.ToInt32(txtMouth.Value); dayint = Convert.ToInt32(txtDay.Value); } catch (Exception) { ymdsp.InnerText = "日期错误,请重新输入"; return; } if ((yearint < 1900 || yearint > 2018) || (mouthint < 0 || mouthint > 12) || (dayint < 0 || dayint > 31)) { ymdsp.InnerText = "日期错误,请重新输入"; } else { ymdsp.InnerText = ""; if (Request["rb"] == "M") { sex = "男"; } if (Request["rb"] == "W") { sex = "女"; } bool user = bll.SetUserByUserName(userName, nick, pwd, txtYear.Value, txtMouth.Value, txtDay.Value, sex, head); if (user == false) { Response.Write("<script>alert('注册失败,请重新输入');</script>"); } else { Response.Write("<script>alert('注册成功');</script>"); Session["UserName"] = userName; Response.Redirect("Defult.aspx"); } } } //123 }