protected void btndangky_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txttenkhachhang.Text)) { return; } if (string.IsNullOrEmpty(txtmatkhau.Text)) { return; } if (string.IsNullOrEmpty(txttenkhachhang.Text)) { return; } if (string.IsNullOrEmpty(txtemail.Text)) { return; } if (string.IsNullOrEmpty(txtsdt.Text)) { return; } if (string.IsNullOrEmpty(txtdiachi.Text)) { return; } try { Admins vcontroller = new Admins(); Entities.KhachHang vusers = new Entities.KhachHang(); string errMsg = string.Empty; vusers.Tendangnhap = txttenkhachhang.Text; vusers.Matkhau = txtmatkhau.Text; vusers.Email = txtemail.Text; vusers.Hoten = txttenkhachhang.Text; vusers.Sodienthoai = txtsdt.Text; vusers.Diachi = txtdiachi.Text; vusers.Laadmin = false; vusers.Trangthai = true; vusers.Gioitinh = Convert.ToInt32(ddlgioitinh.SelectedValue); int result = vcontroller.save_khachhang(vusers, ref errMsg); if (result > 0) { Response.Redirect("~/dangnhap.aspx"); } else { if (result == -1) { throw new Exception("Sai tên tài khoản hoặc mật khẩu!"); } else { throw new Exception("Hệ thống gặp sự cố trong quá trình xác thực tài khoản!"); } } } catch (Exception ex) { throw new Exception("Hệ thống gặp sự cố trong quá trình xác thực tài khoản!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txttendangnhap.Text)) { NotificationMessage("tên đăng nhập không được để trống", 0); return; } if (string.IsNullOrEmpty(txtmatkhau.Text)) { NotificationMessage("mật khẩu không được để trống", 0); return; } if (string.IsNullOrEmpty(txthoten.Text)) { NotificationMessage("họ tên không được để trống", 0); return; } if (string.IsNullOrEmpty(txtemail.Text)) { NotificationMessage("email không được để trống", 0); return; } if (string.IsNullOrEmpty(txtsdt.Text)) { NotificationMessage("số điện thoại không được để trống", 0); return; } if (string.IsNullOrEmpty(txtdiachi.Text)) { NotificationMessage("địa chỉ không được để trống", 0); return; } try { Admins vcontroller = new Admins(); Entities.KhachHang vusers = new Entities.KhachHang(); string errMsg = string.Empty; vusers.Tendangnhap = txttendangnhap.Text; vusers.Matkhau = txtmatkhau.Text; vusers.Email = txtemail.Text; vusers.Hoten = txthoten.Text; vusers.Sodienthoai = txtsdt.Text; vusers.Diachi = txtdiachi.Text; vusers.Laadmin = true; vusers.Trangthai = true; vusers.Gioitinh = Convert.ToInt32(ddlgioitinh.SelectedValue); int result = vcontroller.save_khachhang(vusers, ref errMsg); if (result > 0) { ucNotificationDialog.MessageContent = "Thêm mới user thành công!"; ucNotificationDialog.MessageType = 1; ucNotificationDialog.RedirectUrl = "~/Admin/users.aspx"; ucNotificationDialog.Show(); } else { NotificationMessage("Vui lòng kiểm tra lại.", 0); } } catch (Exception ex) { Response.Write(ex.Message); NotificationMessage("Hệ thống gặp sự cố trong quá trình thêm user mới!", 0); } }
protected void ucConfirmDialog_Yes(object sender) { ucConfirmDialog.Hide(); try { Admins vcontroller = new Admins(); Entities.KhachHang vusers = new Entities.KhachHang(); string errMsg = string.Empty; vusers.MaKH = Convert.ToInt32(Request.QueryString["ID"]); vusers.Tendangnhap = txttendangnhap.Text; vusers.Matkhau = txtmatkhau.Text; vusers.Email = txtemail.Text; vusers.Hoten = txthoten.Text; vusers.Sodienthoai = txtsdt.Text; vusers.Diachi = txtdiachi.Text; vusers.Laadmin = true; vusers.Trangthai = true; vusers.Gioitinh = Convert.ToInt32(ddlgioitinh.SelectedValue); int result = vcontroller.save_khachhang(vusers, ref errMsg); if (result > 0) { ucNotificationDialog.MessageContent = "cập nhập user thành công!"; ucNotificationDialog.MessageType = 1; ucNotificationDialog.RedirectUrl = "~/Admin/users.aspx"; ucNotificationDialog.Show(); } else { NotificationMessage("Vui lòng kiểm tra lại.", 0); } } catch (Exception ex) { Response.Write(ex.Message); ucNotificationDialog.MessageContent = "Hệ thống gặp sự cố trong quá trình cập nhật !"; ucNotificationDialog.MessageType = 0; ucNotificationDialog.Show(); } }