客車網上售票系統(分解六)
阿新 • • 發佈:2020-08-09
1、今日完成任務:
(1)完善登入功能,根據使用者輸入的賬號密碼實現使用者跳入使用者頁面管理員跳入管理員頁面
(2)使用者資訊頁面實現可以修改使用者資訊(身份證號和使用者真實姓名不可以修改)
2、核心原始碼:
(1)完善登入功能後臺程式碼
private void userLogin() { string userName = Request["txtUserName"]; string userPwd = Request["txtUserPwd"]; string msg = string.Empty; Userinfo user= null; bool b = bll.CheckUserInfo(userName, userPwd, out msg, out user); if (b) { //驗證成功 Session["user"] = user; //判斷使用者是否選擇了”自動登入“ if (!string.IsNullOrEmpty(Request["cbAutoLogin"])) { HttpCookie cookie1= new HttpCookie("cp1", userName); HttpCookie cookie2 = new HttpCookie("cp2", WebCommon.GetMd5String(WebCommon.GetMd5String(userPwd))); cookie1.Expires = DateTime.Now.AddMinutes(1); cookie2.Expires = DateTime.Now.AddMinutes(1); Response.Cookies.Add(cookie1); Response.Cookies.Add(cookie2); }//單擊提交按鈕,將隱藏域的值提交過來 判斷是否有值 if (string.IsNullOrEmpty(Request["hiddenReturnUrl"])) { //判斷使用者型別,管理員跳入管理員介面,使用者跳入使用者介面 if (user.Utype==1) { //管理員 Response.Redirect("UpdateAdminInfo.aspx"); } else { //使用者 Response.Redirect("UpdatePersonalInfo.aspx"); } } else { //有值 跳入值所傳遞的url Response.Redirect(Request["hiddenReturnUrl"]); } } else { Msg = msg; //Response.Write("<script>alert('" + Msg + "')</script>"); } }
(1)使用者資訊頁面前臺效果圖
(2)使用者資訊頁面前臺程式碼
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <link href="../css/reset.css" rel="stylesheet" /> <link href="../css/iconfont.css" rel="stylesheet" /> <link href="../css/aa.css" rel="stylesheet" /> <script src="../js/jquery-1.9.1.min.js"></script> <script src="../js/f.js"></script> <script src="../js/laydate/laydate.js"></script> <script> //執行一個laydate例項 laydate.render({ elem: '#test1' //指定元素 }); </script> <style type="text/css"> .icon-weibiaoti1:before { content: "\e695"; } .icon-xinxiliulan:before { content: "\e614"; } #test1 { clear: both; border: 1px solid #ccc; height: 25px; position: relative; left: 50px; bottom: 20px; } .InputDiv { border: none; } #txtCfd, #txtMdd { border: 1px solid #ccc; height: 25px; } #btnSelect { color: #fff; } .auto-style1 { background: #fff; margin-left: 40px; } .headboxtext { height: 30px; line-height: 30px; } #GridView1 { text-align: center; } table { width: 800px; border-collapse: collapse; } table tr td { border: 1px solid #000; } .auto-style2 { width: 812px; height: 134px; } .auto-style3 { width: 810px; height: 80px; } #ts { width: 300px; } #ts tr td { border: none; } .auto-style4 { height: 35px; } .btn { background-color: #FD4C4C; width: 80PX; height: 30px; color: #fff; } .txt { border: 1px solid #808080; height: 20px; } .left { width: 80px; padding-left: 5px; } </style> <title>使用者資訊</title> </head> <body> <form id="form1" runat="server"> <div class="PublicHead clearfix"> <div class="leftBox clearfix"> <!--<div class="companyLogo"> <img src="images/logo.jpg" /> </div>--> <!--<i class="iconfont icon-caidan"></i>--> <div class="companyText"> 客車網上售票系統 </div> </div> <div class="RightBox clearfix"> <div class="UserPhotoBox"> <div class="UserPic"> <img src="../Images/user.jpg" /> </div> <div class="UserName"> 使用者 </div> </div> <a href="Login.aspx"> <div class="dropOutBox"> <i class="iconfont icon-app_icons--"></i> <span>退出</span> </div> </a> </div> </div> <div class="PublicDownWhole clearfix"> <!--左側--> <div class="leftBox"> <ul> <a href="UpdateAdminInfo.aspx"> <li class="Select"><i class="iconfont icon-yonghuguanli"></i><span>使用者資訊</span></li> </a> <a href="UserInfo.aspx"> <li class=""><i class="iconfont icon-tubiao_dingdan"></i><span>使用者管理</span></li> </a> <a href="Pwgl.aspx"> <li><i class="iconfont icon-fenlei"></i><span>票務管理</span></li> </a> </ul> </div> <!--右側--> <div class="RightBox"> <div class="PublicContentBox"> <!--公用指向頁面名字--> <div class="PublicPointToAgeText"> <span class="span1">客車網上售票系統 </span><span class="span2">個人使用者資訊</span> </div> <!--表修改--> <div class="auto-style1" style="margin-left: 0px; height: 700px;"> <div class="headbox"> <div class="headboxtext"> <%--<span class="span1">車票查詢</span>--%> <asp:Label ID="Label2" runat="server" Text="個人使用者資訊"></asp:Label> </div> </div> <!--查詢到的表格--> <div style="width: 810px; margin-left: 10px;"> <table class="auto-style3" id="ts"> <tr style="background-color: #fe7844; height: 30px; color: #fff; text-align: left;"> <td colspan="2"> 個人資訊修改</td> </tr> <tr> <td class="auto-style4 left">使用者名稱: </td> <td class="auto-style4 right"> <asp:TextBox ID="txtUserName" runat="server" CssClass="txt"></asp:TextBox> <td class="auto-style4"> </tr> <tr> <td class="auto-style4 left">密碼: </td> <td class="auto-style4 right"> <asp:TextBox ID="txtPwd" runat="server" CssClass="txt"></asp:TextBox> <td class="auto-style4"> </tr> <tr> <td class="auto-style4 left">身份證號: </td> <td class="auto-style4 right"> <asp:TextBox ID="txtCard" runat="server" CssClass="txt" ReadOnly="true"></asp:TextBox> <td class="auto-style4"> </tr> <tr> <td class="auto-style4 left">真實姓名: </td> <td class="auto-style4 right"> <asp:TextBox ID="txtRealName" runat="server" CssClass="txt" ReadOnly="true"></asp:TextBox> <td class="auto-style4"> </tr> <tr> <td class="auto-style4 left">郵箱: </td> <td class="auto-style4 right"> <asp:TextBox ID="txtEmail" runat="server" CssClass="txt"></asp:TextBox> <td class="auto-style4"> </tr> <tr> <td class="auto-style4 left">電話: </td> <td class="auto-style4 right"> <asp:TextBox ID="txtTel" runat="server" CssClass="txt"></asp:TextBox> <td class="auto-style4"> </tr> <tr style="text-align: center;"> <td colspan="2"> <asp:Button ID="btnUpdate" runat="server" Text="確定" CssClass="btn" OnClick="btnUpdate_Click" /> </td> </tr> </table> </div> </div> </div> </div> </div> </form> </body> </html>
(3)使用者資訊頁面後臺程式碼
public partial class UpdateAdminInfo : System.Web.UI.Page { UserinfoManager bll = new UserinfoManager(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Userinfo user = (Userinfo)Session["user"]; int uid = user.Uid; DataSet ds = bll.GetDataByUid(uid); this.txtUserName.Text = ds.Tables[0].Rows[0]["Uname"].ToString(); this.txtPwd.Text = ds.Tables[0].Rows[0]["Upwd"].ToString(); this.txtRealName.Text = ds.Tables[0].Rows[0]["Urealname"].ToString(); this.txtCard.Text = ds.Tables[0].Rows[0]["Ucard"].ToString(); this.txtEmail.Text = ds.Tables[0].Rows[0]["Email"].ToString(); this.txtTel.Text = ds.Tables[0].Rows[0]["Tel"].ToString(); } } protected void btnUpdate_Click(object sender, EventArgs e) { Userinfo user = (Userinfo)Session["user"]; int uid = user.Uid; //獲取前臺資料 string userName = this.txtUserName.Text; string pwd = this.txtPwd.Text; //string card = this.txtCard.Text; //string realName = this.txtRealName.Text; string email = this.txtEmail.Text; string tel = this.txtTel.Text; bool boo = bll.Update(userName, pwd, email, tel, uid); if (boo) { //成功 Response.Write("<script>alert('修改成功!!!')</script>"); } else { //失敗 Response.Write("<script>alert('修改失敗!!!')</script>"); } } }
3、遇到的問題:
(1)很多想實現的效果因為能力有限沒辦法實現,需要前端技術
4、解決的方法:
(1)技術能力方面需要利用這個暑假做提升