public ActionResult Index(FormCollection collection) { var ten = collection["id"]; var matkhau = collection["pass"]; if (String.IsNullOrEmpty(ten)) { ViewData["loi1"] = "Chưa nhập tài khoản"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["loi2"] = "Bạn Chưa Nhập Mật Khẩu"; } else { QUANLY ql = db.QUANLies.SingleOrDefault(n => n.USERNAME == ten && n.PASS == matkhau); if (ql != null) { SetAlert("Đăng nhập thành công!", "success"); Session["Admin"] = ql; return(RedirectToAction("ShowSanpham", "Admin")); } else { SetAlert("Đăng nhập sai!", "error"); } } return(View()); }
public ActionResult DangNhap(FormCollection collection) { var tk = collection["taikhoan"]; var mk = collection["password"]; if (String.IsNullOrEmpty(tk)) { ViewData["Loi1"] = "Chưa nhập tài khoản"; } else { if (String.IsNullOrEmpty(mk)) { ViewData["Loi2"] = "Chưa nhập mật khẩu"; } else { QUANLY ad = db.QUANLies.SingleOrDefault(m => m.TENTK == tk && m.PASS == mk); if (ad != null) { Session["Admin"] = ad; return(RedirectToAction("Index", "TrangAdmin")); } else { ViewData["Loi2"] = "Tài khoản hoặc mật khẩu sai"; } } } return(View()); }
/// <summary> /// Xóa tài khoản /// 1. Xóa thành công /// -1. Không được phép xóa /// 0. Tài khoản không tồn tại /// -2. Lỡi không xác định /// </summary> /// <param name="user"></param> /// <returns></returns> public int Delete(QUANLY user) { try { var us = db.QUANLies.Find(user.username); if (us != null) { if (us.IsAdmin == 1 && us.Allower == 1) { return(-1); } else { db.QUANLies.Remove(us); db.SaveChanges(); return(1); } } return(0); } catch (Exception) { return(-2); } }
protected void Page_Load(object sender, EventArgs e) { Application.Lock(); QUANLY ql = (QUANLY)Application["QUANLY"]; ArrayList lst = (ArrayList)Application["DanhSachNoiDung"]; int SoNguoi = ql.SoNguoiChoi + ql.SoNguoiXem; int CauLuuTruHienTai = (int)Application["CauLuuTruHienTai"]; int SoCauDaChat = (int)Application["SoCauDaChat"]; int SoCauDaLay = (int)Session["SoCauDaLay"]; XL_THE The = new XL_THE("Goc"); for (int i = Math.Max(SoCauDaLay, CauLuuTruHienTai); i < SoCauDaChat; ++i) { NoiDungChat ndc = (NoiDungChat)lst[i - CauLuuTruHienTai]; String NoiDung = ndc.NoiDung; String NguoiGui = ndc.TenNguoiGui; XL_THE TheCon = new XL_THE("Cau"); XL_THUOC_TINH ThuocTinh = new XL_THUOC_TINH("NoiDung", NoiDung); TheCon.Danh_sach_thuoc_tinh.Add(ThuocTinh); ThuocTinh = new XL_THUOC_TINH("NguoiGui", NguoiGui); TheCon.Danh_sach_thuoc_tinh.Add(ThuocTinh); The.Danh_sach_the.Add(TheCon); ndc.SoLanLay++; } Session["SoCauDaLay"] = SoCauDaChat; DonDep(); String Chuoi = The.Chuoi(); XL_CHUOI.Xuat(Response, Chuoi); Application.UnLock(); }
protected void Button1_Click(object sender, EventArgs e) { QUANLY ql = (QUANLY)Application["QUANLY"]; ql.SoNguoiXem++; Session["NguoiChoiThu"] = -1; // Khach Response.Redirect("~/CuaSoChinh.htm"); }
protected void Page_Load(object sender, EventArgs e) { QUANLY ql = (QUANLY)Application["QUANLY"]; lblSoNguoiChoi.Text = ql.SoNguoiChoi.ToString(); if (ql.SoNguoiChoi == 4) { Login1.Enabled = false; } }
protected void Page_Load(object sender, EventArgs e) { QUANLY ql = (QUANLY)Application["QUANLY"]; int luotdi = ql.LuotDi; int XiNgau = ql.XiNgau; Boolean DangDoXiNgau = ql.DangDoXiNgau; int[] vitri = ql.BanCo.ViTriCacQuanCo; XL_THE The = new XL_THE("Goc"); XL_THE TheCon = new XL_THE("LuotDi"); XL_THUOC_TINH ThuocTinh = new XL_THUOC_TINH("GiaTri", luotdi.ToString()); // Them luot di vao xml TheCon.Danh_sach_thuoc_tinh.Add(ThuocTinh); The.Danh_sach_the.Add(TheCon); TheCon = new XL_THE("XiNgau"); ThuocTinh = new XL_THUOC_TINH("GiaTri", XiNgau.ToString()); // Them Xi Ngau vao xml TheCon.Danh_sach_thuoc_tinh.Add(ThuocTinh); The.Danh_sach_the.Add(TheCon); TheCon = new XL_THE("DangDoXiNgau"); ThuocTinh = new XL_THUOC_TINH("GiaTri", (DangDoXiNgau ? 1 : 0).ToString()); // Them DangDoXiNgau vao xml TheCon.Danh_sach_thuoc_tinh.Add(ThuocTinh); The.Danh_sach_the.Add(TheCon); int SoNguoiChoi = ql.SoNguoiChoi; int SoNguoiXem = ql.SoNguoiXem; TheCon = new XL_THE("SoNguoiChoi"); ThuocTinh = new XL_THUOC_TINH("GiaTri", SoNguoiChoi.ToString()); // Them SoNguoiChoi vao xml TheCon.Danh_sach_thuoc_tinh.Add(ThuocTinh); The.Danh_sach_the.Add(TheCon); TheCon = new XL_THE("SoNguoiXem"); ThuocTinh = new XL_THUOC_TINH("GiaTri", SoNguoiXem.ToString()); // Them SoNguoiXem vao xml TheCon.Danh_sach_thuoc_tinh.Add(ThuocTinh); The.Danh_sach_the.Add(TheCon); // Vi tri cac quan co for (int i = 0; i < 16; ++i) { TheCon = new XL_THE("Co"); ThuocTinh = new XL_THUOC_TINH("ViTri", vitri[i].ToString()); TheCon.Danh_sach_thuoc_tinh.Add(ThuocTinh); The.Danh_sach_the.Add(TheCon); } String Chuoi = The.Chuoi(); XL_CHUOI.Xuat(Response, Chuoi); }
protected void Login1_LoggedIn(object sender, EventArgs e) { QUANLY ql = (QUANLY)Application["QUANLY"]; int NguoiChoiThu = ql.SoNguoiChoi; Session["NguoiChoiThu"] = NguoiChoiThu; NGUOICHOI nc = new NGUOICHOI(); nc.Username = Login1.UserName; ql.arrNguoiChoi.Add(nc); }
protected void Page_Load(object sender, EventArgs e) { try { QUANLY ql = (QUANLY)Application["QUANLY"]; Application.Lock(); ql.LuotDi = (ql.LuotDi + 1) % ql.SoNguoiChoi; ql.XiNgau = -1; ql.DangDoXiNgau = false; Application.UnLock(); } catch (Exception _e) { } }
public ActionResult DangKy(FormCollection collection, QUANLY ql) { var taikhoan = collection["id"]; var matkhau = collection["pass"]; var sdt = collection["phone"]; var hoten = collection["username"]; ql.USERNAME = taikhoan; ql.HOTEN = hoten; ql.SDT = sdt; ql.PASS = matkhau; db.QUANLies.InsertOnSubmit(ql); db.SubmitChanges(); return(RedirectToAction("Index", "Admin")); }
/// <summary> /// Tạo tài khoản Admin /// false . Tồn tại username or email /// true. Thêm thành công /// </summary> /// <param name="user"></param> /// <returns>bool</returns> public bool Insert(QUANLY user) { var us = db.QUANLies.SingleOrDefault(x => x.username == user.username || x.email == user.email); if (us != null) { return(false); } else { db.QUANLies.Add(user); db.SaveChanges(); return(true); } }
protected void Page_Load(object sender, EventArgs e) { QUANLY ql = (QUANLY)Application["QUANLY"]; int XiNgau = new Random().Next(6) + 1; XL_THE The = new XL_THE("Goc"); XL_THUOC_TINH ThuocTinh = new XL_THUOC_TINH("XiNgau", XiNgau.ToString()); // Them luot di vao xml The.Danh_sach_thuoc_tinh.Add(ThuocTinh); ql.XiNgau = XiNgau; ql.DangDoXiNgau = false; String Chuoi = The.Chuoi(); XL_CHUOI.Xuat(Response, Chuoi); }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <returns></returns> public bool Updae(QUANLY user) { try { var us = db.QUANLies.Find(user.username); us.fullname = user.fullname; us.phone = user.phone; us.password = user.password; us.email = user.email; us.Allower = user.Allower; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
private bool SiteSpecificAuthenticationMethod(string UserName, string Password) { List <String> arrUserName = new List <String>(); List <String> arrPassword = new List <String>(); arrUserName.Add("nguoi1"); arrUserName.Add("nguoi2"); arrUserName.Add("nguoi3"); arrUserName.Add("nguoi4"); arrPassword.Add("nguoi1"); arrPassword.Add("nguoi2"); arrPassword.Add("nguoi3"); arrPassword.Add("nguoi4"); UserName = UserName.ToUpper(); String _username = ""; String _password; for (int i = 0; i < arrUserName.Count; ++i) { _username = arrUserName[i]; _password = arrPassword[i]; _username = _username.ToUpper(); if (_username == UserName && _password == Password) { QUANLY ql = (QUANLY)Application["QUANLY"]; List <NGUOICHOI> arr = ql.arrNguoiChoi; for (int j = 0; j < arr.Count; ++j) { if (arr[j].Username.ToUpper() == UserName) { Login1.FailureText = "Tài khoản này đã được đăng nhập. Bạn không thể đăng nhập lần nữa."; return(false); } } return(true); } } Login1.FailureText = "Username và password không chính xác. Xin hãy nhập lại."; return(false); }
protected void Page_Load(object sender, EventArgs e) { int ConCo; int ViTri; try { ConCo = int.Parse(XL_CHUOI.Nhap(Request, "ConCo")); ViTri = int.Parse(XL_CHUOI.Nhap(Request, "ViTri")); QUANLY ql = (QUANLY)Application["QUANLY"]; Application.Lock(); ql.BanCo.ViTriCacQuanCo[ConCo] = ViTri; ql.XiNgau = -1; ql.DangDoXiNgau = false; Application.UnLock(); } catch (Exception _e) { } }
protected void Page_Load(object sender, EventArgs e) { int SoCauDaChat = (int)Application["SoCauDaChat"]; String NoiDung; NoiDung = XL_CHUOI.Nhap(Request, "NoiDung"); if (NoiDung != null) { QUANLY ql = (QUANLY)Application["QUANLY"]; int nguoichoithu = int.Parse(Session["NguoiChoiThu"].ToString()); String HoTen = (String)ql.arrNguoiChoi[nguoichoithu].Username; int SoNguoi = ql.SoNguoiChoi + ql.SoNguoiXem; Application.Lock(); ArrayList lst = (ArrayList)Application["DanhSachNoiDung"]; NoiDungChat nd = new NoiDungChat(NoiDung, HoTen, SoNguoi); lst.Add(nd); SoCauDaChat++; Application["SoCauDaChat"] = SoCauDaChat; Application.UnLock(); } }
public ActionResult Login(FormCollection collection) { ViewBag.SoNguoiTruyCap = HttpContext.Application["SoNguoiTruyCap"].ToString(); //Số lượng người truy cập từ application đã được tạo ViewBag.SoLuongNguoiOnline = HttpContext.Application["SoNguoiDangOnline"].ToString(); //Lấy số lượng người đang truy cập ViewBag.TongDoanhThu = ThongKeTongDoanhThu(); //Thống kê tổng doanh thu ViewBag.TongDDH = ThongKeDonHang(); //Thống kê dơn hàng ViewBag.TongThanhVien = ThongKeThanhVien(); //Thống kê thành viên var tk = collection["taikhoan"]; var mk = collection["password"]; if (String.IsNullOrEmpty(tk)) { ViewData["Loi1"] = "Chưa nhập tài khoản"; } else { if (String.IsNullOrEmpty(mk)) { ViewData["Loi2"] = "Chưa nhập mật khẩu"; } else { QUANLY ad = db.QUANLies.SingleOrDefault(m => m.TENTK == tk && m.PASS == mk); if (ad != null) { Session["Admin"] = ad; return(RedirectToAction("Index", "Admin")); } else { ViewData["Loi2"] = "Tài khoản hoặc mật khẩu sai"; } } } return(RedirectToAction("Index", "Admin")); }
protected void Page_Load(object sender, EventArgs e) { QUANLY ql = (QUANLY)Application["QUANLY"]; ql.DangDoXiNgau = true; }
public ActionResult CreateAccount(QUANLY user) { return(View()); }