protected void Submit_Click(object sender, EventArgs e) { dtoKhachHang = new KhachHang(); bllKhachHang = new KhachHangBLL(); dtoKhachHang.HoTen = HoTen.Text; dtoKhachHang.NgaySinh = NgaySinh.Text; dtoKhachHang.GioiTinh = GioiTinh.Text; dtoKhachHang.CMND = CMND.Text; dtoKhachHang.DiaChi = DiaChi.Text; dtoKhachHang.DT = DT.Text; dtoKhachHang.Email = Email.Text; dtoKhachHang.PassWord = PassWord.Text; try { object oKH = bllKhachHang.insertKhachHang(dtoKhachHang); if (oKH != null) { HoTen.Text = oKH.ToString(); } } catch (Exception) { throw; } //try //{ // object oKH; // oKH = bllKhachHang.selectKhachHang("hhhhhh"); // HoTen.Text = oKH.ToString(); //Session["HoTen"] = dtoKhachHang.HoTen; //Session["MaKH"] = oKH.ToString(); //HttpCookie cookie = new HttpCookie("Email", dtoKhachHang.Email); //cookie.Expires = DateTime.Now.AddDays(1D); //Response.Cookies.Add(cookie); //Response.Write(act); //if (act == "loginshop") //{ // Response.Redirect("Cart.aspx"); //} //else //{ // Response.Redirect("Default.aspx"); //} //} //catch (Exception) //{ // throw; //} }
protected void btnSubmit_Click(object sender, EventArgs e) { dtoKhachHang = new KhachHang(); bllKhachHang = new KhachHangBLL(); SqlDataReader reader; dtoKhachHang.Email = Email.Text; dtoKhachHang.PassWord = PassWord.Text; try { reader = bllKhachHang.checkKhachHang(Email.Text); if (reader.Read()) { if ((string)reader["PassWord"] == PassWord.Text) { if ((int)reader["IsAdmin"] == 1) { Response.Redirect("Admin/Default.aspx"); } else { Response.Redirect("Default.aspx"); } } else { error.Text = "Mật khẩu không đúng!"; } } else { error.Text = "Email không tồn tại!"; } } catch (Exception) { throw; } }