protected void Page_Load(object sender, EventArgs e) { Context.Items["strTitle"] = "Đăng ký"; if (objSytem.isLogin()) { Response.Redirect("/"); } if (Request.RequestType == "POST") { Account = Request.Form["account"]; Password = Request.Form["password"]; Password2 = Request.Form["password2"]; Email = Request.Form["email"]; Phone = Request.Form["phone"]; if (Account == "") { Message = "Bạn cần nhập tên tài khoản"; return; } if (Email == "") { Message = "Bạn cần nhập địa chỉ hòm thư"; return; } if (Password == "") { Message = "Bạn cần nhập mật khẩu"; return; } if (Password != Password2) { Message = "Nhập lại mật khẩu không khớp"; return; } int ret = objAccount.addAccount(Account, Password); if (ret != 0) { objAccount.setAccountInfo(ret, Email, Phone); objSytem.Login(Account, Password, true, 0); Response.Redirect("/"); } else { Message = "Có lỗi xảy ra! Xin thử lại.";// +objSytem.Message; } } }
protected void btnSaver_Click(object sender, EventArgs e) { String Acct = txtUserName.Text.Trim(); if (Acct == "") { objSystemClass.addMessage("Tài khoản không được để trống"); txtUserName.Focus(); return; } if (objAccount.getAccount(Acct) != null) { objSystemClass.addMessage("Tài khoản đã tồn tài"); txtUserName.Focus(); return; } String pass = txtPassword.Text; if (pass == "") { objSystemClass.addMessage("Mật khẩu không được để trống"); txtPassword.Focus(); return; } if (pass != txtPassword2.Text) { objSystemClass.addMessage("Mật khẩu 2 không khớp"); txtPassword2.Focus(); return; } int group = 0; try { group = int.Parse(ddlGroup.SelectedValue); } catch {} DateTime age; try { age = DateTime.Parse(txtNgaySinh.Value); } catch { objSystemClass.addMessage("Định dạng ngày sinh không đúng!"); txtNgaySinh.Focus(); return; } int sex = 0; try{ sex = int.Parse(ddlGioiTinh.Text); } catch { objSystemClass.addMessage("Bạn cần chọn giới tính"); ddlGioiTinh.Focus(); return; } if (sex < 0 && sex > 1) { objSystemClass.addMessage("Bạn cần chọn giới tính"); ddlGioiTinh.Focus(); return; } int ret = objAccount.addAccount(Acct, pass, group); if (ret == 0) { objSystemClass.addMessage("Có lỗi xảy ra! (" + objAccount.Message + ")"); return; } objAccount.setAccountInfo(ret, txtEmail.Text.Trim(), txtFullName.Text, age, sex); objSystemClass.addMessage("Tạo tài khoản thành công."); Response.Redirect("AccountEdit.aspx?id=" + ret); }