public ActionResult EditCustomer(int id) { var adminDao = new AdminDAO(); CustomerModel customer = adminDao.getCustomer(id); return(View(customer)); }
private void button1_Click(object sender, EventArgs e) { { string username = txtUsername.Text; string password = txtPassword.Text; if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { MessageBox.Show("Username and password cann't be null"); } else { AdminDAO adminDAO = new AdminDAO(); int id = adminDAO.IsLogin(username, password); if (id > 0) { Program.adminId = id; new AdminDashboard().Show(); this.Hide(); } else { MessageBox.Show("Either username or password is wrong"); } } } }
public static ObservableCollection <AdminDAO> selectAdmin() { ObservableCollection <AdminDAO> l = new ObservableCollection <AdminDAO>(); string query = "SELECT * FROM admin;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataReader reader = null; try { cmd.ExecuteNonQuery(); reader = cmd.ExecuteReader(); while (reader.Read()) { AdminDAO p = new AdminDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetInt32(6), reader.GetInt32(7)); l.Add(p); } } catch (Exception e) { MessageBox.Show("Il y a un problème dans la table Categorie : {0}", e.StackTrace); } reader.Close(); return(l); }
protected void Page_Load(object sender, EventArgs e) { AdminMaster m = (AdminMaster)Page.Master; m.bodyclass = "yui-skin-sam"; if (Request.Params.Get("emailon") != null) { if (Request.Params.Get("emailon") == "1") { foreach (EmailSetting es in AdminDAO.GetEmailSettings()) { es.Send = true; AdminDAO.MakePersistent(es); } } else if (Request.Params.Get("emailon") == "0") { foreach (EmailSetting es in AdminDAO.GetEmailSettings()) { es.Send = false; AdminDAO.MakePersistent(es); } } Response.Redirect("EmailSettings.aspx"); } }
public IHttpActionResult CheckDuplicate(string username) { bool rs = true; try { Admin ad = new AdminDAO().GetAdminById(username); if (ad != null) { rs = false; } Cast cast = new CastDAO().GetCastById(username); if (cast != null) { rs = false; } } catch (Exception) { throw; } if (rs) { return(Ok()); } return(Conflict()); }
public ActionResult CapNhatCTHD(int macathe, int mahoadon) { int? tongtien = new AdminDAO().CapNhatCTHD(macathe, mahoadon); string tong = tongtien.Value.ToString("C", CultureInfo.CurrentCulture); return(Json(new { tong = tong }, JsonRequestBehavior.AllowGet)); }
public ActionResult UnBlock(bool confirm, int idAdmin) { if (Session["TaiKhoan"] != null) { var tk = Session["TaiKhoan"] as KhachHang; if (tk.LoaiTK == "Khách Hàng") { return(View("../Home/Index")); } else { if (confirm == true) { AdminDAO dao = new AdminDAO(); dao.UnBlock(idAdmin, tk.MaKH); Session["ListAdmin"] = dao.GetList(); Session["ListAdminBlock"] = dao.GetListBlock(); } return(View("Index")); } } else { return(View("../DangNhap/Index")); } }
public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { var dao = new AdminDAO(); var result = dao.Login(model.UserName, Encryptor.MD5Hash(model.Password)); if (result == 1) { var admin = dao.GetByUserName(model.UserName); var AdminSession = new AdminLogin(); AdminSession.UserName = admin.UserName; Session.Add(Constant.ADMIN_SESSION, AdminSession); return(RedirectToAction("Index", "Product")); } else if (result == 0) { ModelState.AddModelError("", "The requested user could not be found."); } else if (result == 2) { ModelState.AddModelError("", "Password incorrect"); } else { ModelState.AddModelError("", "E-mail incorrect"); } } return(View("Index")); }
public static String GetRedirectionUrlWithParams(Uri url, String country) { IList <Country> countries = AdminDAO.GetFranchiseCountries(); String domain = "www"; switch (country) { case "US": domain = "www"; break; case "GB": domain = "eu"; break; default: domain = "www"; foreach (Country c in countries) { if (c.Continent.Equals(AdminDAO.GetCountryByID(country).Continent)) { domain = c.CountryID.ToLower(); } } break; } String newurl = ""; newurl += "http://" + domain + ".airnetzcharter.com"; newurl += url.PathAndQuery; return(newurl); }
public ActionResult Search(string stt, string email, string gioiTinh, DateTime?ngaySinh) { var tk = Session["TaiKhoan"] as KhachHang; if (tk == null) { return(View("../Login/Index")); } else { if (tk.LoaiTK != "Admin") { return(View("../Home/Index")); } else { var dao = new AdminDAO(); if (stt == "block") { Session["ListBlockAd"] = dao.SearchBlock(email, gioiTinh, ngaySinh); } else { Session["ListAd"] = dao.Search(email, gioiTinh, ngaySinh, tk.IdKhachHang); } return(View("Index")); } } }
public static AdminViewModel getAdmin(int idAdmin) { AdminDAO pDAO = AdminDAO.getAdmin(idAdmin); AdminViewModel p = new AdminViewModel(pDAO.idAdminDAO, pDAO.nomAdminDAO, pDAO.prenomAdminDAO, pDAO.mailAdminDAO, pDAO.numeroTelAdminDAO, pDAO.motDePasseAdminDAO, pDAO.ageAdminDAO, pDAO.idLieuAdminDAO); return(p); }
public void ShouldReturnAllEntities() { var data = new List <Admin> { new Admin() { Id = 0, AdminId = "Admin1", Password = "******" }, new Admin() { Id = 1, AdminId = "Admin2", Password = "******" }, new Admin() { Id = 2, AdminId = "Admin3", Password = "******" } }.AsQueryable(); var mockContext = new Mock <UserDataContext>(); var mockSet = SetupDbSet(data); mockContext.Setup(c => c.Admin).Returns(mockSet.Object); var dao = new AdminDAO(mockContext.Object); var results = dao.All(); Assert.AreEqual(3, results.Count); Assert.AreEqual("Admin1", results[0].AdminId); Assert.AreEqual("Admin2", results[1].AdminId); Assert.AreEqual("Admin3", results[2].AdminId); }
public String GetBidJson(BookRequest b, Operator op) { String resp = ""; IList <OperatorBid> bidlist = BookRequestDAO.GetBidsForRequest(b); ListSet opbids = new ListSet(); OperatorBid minbid = null; Currency targetcurr = AdminDAO.GetCurrencyByID("USD"); Double minval = double.PositiveInfinity; foreach (OperatorBid ob in bidlist) { if (ob.Operator.Equals(op)) { opbids.Add(ob); } Double temp = ob.Currency.ConvertTo(ob.BidAmount, targetcurr); if (temp < minval) { minval = temp; minbid = ob; } } resp += "{\"TotalBids\":" + bidlist.Count + ",\"OperatorBids\":" + JavaScriptConvert.SerializeObject(opbids) + ",\"MinBid\":" + JavaScriptConvert.SerializeObject(minbid) + "}"; return(resp); }
public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { var dao = new AdminDAO(); var result = dao.Login(model.UserName, model.PassWord); if (result == 1) { var user = dao.GetByID(model.UserName); var userSession = new UserLogin(); userSession.UserName = user.UserName; userSession.UserID = user.ID; userSession.Name = user.Name; Session.Add(CommonConstants.USER_SESSION, userSession); return(RedirectToAction("Index", "Home")); } else if (result == 0) { ModelState.AddModelError("", "Tài khoản không tồn tại"); } else if (result == -1) { ModelState.AddModelError("", "Tài khoản bị khóa"); } else if (result == -2) { ModelState.AddModelError("", "Mật khẩu không đúng"); } else { ModelState.AddModelError("", "Đăng nhập không đúng"); } } return(View("Index")); }
public ActionResult Them(CaThe model, HttpPostedFileBase fileVideo) { model.NgaySinh = DateTime.Parse(Request.Form["NgaySinh"]); model.Video = DateTime.Now.Ticks + fileVideo.FileName; if (fileVideo.ContentLength > 0) { var fileName = Path.GetFileName(fileVideo.FileName); var path = Path.Combine(Server.MapPath("~/assets/client/videos/"), DateTime.Now.Ticks + fileName); fileVideo.SaveAs(path); } if (Session["fileUpload"] != null) { string _fileName; string listImages = ""; fileUpload = (List <HttpPostedFileBase>)Session["fileUpload"]; foreach (var item in fileUpload) { string pic = Path.GetFileName(item.FileName).Substring(0, Path.GetFileName(item.FileName).IndexOf(".")); _fileName = pic + ".jpg"; var path = Path.Combine(Server.MapPath("~/assets/client/images/"), _fileName); item.SaveAs(path); listImages += _fileName + "|"; } model.HinhAnh = listImages; model.TinhTrang = "Sẵn bán"; var dao = new AdminDAO(); dao.ThemCaThe(model); Session["fileUpload"] = null; } return(RedirectToAction("CaThe", new { MaLoai = model.MaLoai, message = "Thêm cá thể thành công" })); }
public static String GetCountryToRedirect(String ipaddress) { Int64 ipno = Int64.Parse(IPAddressToNumber(ipaddress).ToString()); String c = AdminDAO.GetCountryForIpNumber(ipno); if (c != null) { Country temp = AdminDAO.GetCountryByID(c); IList <Country> fclist = AdminDAO.GetFranchiseCountries(); if (fclist.Contains(temp)) { return(temp.CountryID); } else { foreach (Country cr in fclist) { if (cr.Continent.Equals(temp.Continent)) { return(cr.CountryID); } } return("US"); } } else { return("US"); } }
public ActionResult HoaDon_Ngay() { List <HoaDon> model = new List <HoaDon>(); List <NguoiDung> TenNguoiDung = new List <NguoiDung>(); string ngay_bd = Request.Form["ngay_bd"]; string ngay_kt = Request.Form["ngay_kt"]; string i = Request.Form["tinhtrang"]; if (i == null) { model = new AdminDAO().HoaDon_Ngay(DateTime.Parse(ngay_bd), DateTime.Parse(ngay_kt), int.Parse("0")); } else { model = new AdminDAO().HoaDon_Ngay(DateTime.Parse(ngay_bd), DateTime.Parse(ngay_kt), int.Parse(i)); ViewBag.tinhtrang = i; } if (model.Count > 0) { foreach (var m in model) { TenNguoiDung.Add(new AdminDAO().GetNguoiDung_MaHoaDon(m.MaHoaDon)); } } ViewBag.TenNguoiDung = TenNguoiDung; ViewBag.Ngaybd = ngay_bd; ViewBag.Ngaykt = ngay_kt; return(View(model)); }
public ActionResult Details(int id) { AdminDAO adminDAO = new AdminDAO(); AdminModel user = adminDAO.FetchOne(id); return(View("Details", user)); }
public ActionResult Update(int idAdmin) { if (Session["TaiKhoan"] != null) { var tk = Session["TaiKhoan"] as KhachHang; if (tk.LoaiTK == "Khách Hàng") { return(View("../Home/Index")); } else { AdminDAO dao = new AdminDAO(); var admin = dao.GetAdmin(idAdmin); if (admin == null) { ViewBag.Alert = "Không thể tìm thấy tài khoản"; } else { Session["UpdateAdmin"] = admin; } return(View("Index")); } } else { return(View("../DangNhap/Index")); } }
public AdminBO() { encripta = new Encripta(); proceso = new List <Admin>(); objArchivo = new AdminDAO(); proceso = objArchivo.leerArchivo(); }
public ActionResult TimKiem(string username, string ho, string ten, string tinhtrang) { if (Session["TaiKhoan"] != null) { var tk = Session["TaiKhoan"] as KhachHang; if (tk.LoaiTK == "Khách Hàng") { return(View("../Home/Index")); } else { AdminDAO dao = new AdminDAO(); if (tinhtrang == "Unblock") { Session["ListAdmin"] = dao.Search(username, ho, ten); } else { Session["ListAdminBlock"] = dao.SearchBlock(username, ho, ten); } return(View("Index")); } } else { return(View("../DangNhap/Index")); } }
public ActionResult Users(string name, string currentFilter, int page = 1, int pageSize = 10) { var admin = Session["Admin"] as TMDT.Account; if (admin == null) { return(RedirectToAction("Login", "Admin")); } var model = new AdminDAO().ListAllUser(page, pageSize); if (name != null) { page = 1; } else { name = currentFilter; } ViewBag.CurrentFilter = name; if (!String.IsNullOrEmpty(name)) { model = new AdminDAO().ListNUser(name, page, pageSize); } return(View(model)); }
public List <String> CheckLogin(string username, string password) { List <String> list = new List <string>(); try { Admin ad = new AdminDAO().CheckLogin(username, password); if (ad != null) { list.Add("successfull"); list.Add("admin"); list.Add(ad.Username); } Cast cast = new CastDAO().CheckLogin(username, password); if (cast != null) { list.Add("successfull"); list.Add("cast"); list.Add(cast.Username); } if (list.Count == 0) { list.Add("fail"); } } catch (Exception) { throw; } return(list); }
public ActionResult ResetPass(int id) { var admin = Session["Admin"] as TMDT.Account; if (admin == null) { return(RedirectToAction("Login", "Admin")); } new AdminDAO().ResetPass(id); string smtpUserName = "******"; string smtpPassword = "******"; string smtpHost = "smtp.gmail.com"; int smtpPort = 25; string emailTo = new AdminDAO().getemail(id); string subject = "Mật khẩu của bạn đã được khôi phục"; string path = Server.MapPath(@"~/public/images/nenlogo.png"); string body = string.Format( "<br/>Xin chào {0}.<br/>Bạn hoặc ai đó đã khôi phục lại mật khẩu của bạn. Mật khẩu hiện tại là 123456.", new AdminDAO().getname(id), Url.Action("ConfirmEmail", "Home", new { Token = id, Email = new AdminDAO().getemail(id) }, Request.Url.Scheme)); EmailService service = new EmailService(); bool kq = service.Send(smtpUserName, smtpPassword, smtpHost, smtpPort, emailTo, subject, body, ""); return(View("AddUserNotification")); }
private void button1_Click(object sender, EventArgs e) { string companyName = txtCompanyName.Text; string username = txtUsername.Text; string password = txtPassword.Text; Bug_Tracker.Model.Admin admin = new Bug_Tracker.Model.Admin { CompanyName = companyName, Username = username, Password = password }; if (string.IsNullOrEmpty(companyName) || string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { MessageBox.Show("Fill up the form properly"); } else { try { AdminDAO adminDAO = new AdminDAO(); adminDAO.Insert(admin); MessageBox.Show("Account created"); this.Dispose(); new Admin().Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); Console.WriteLine(ex.Message); } } }
public ActionResult CanhBao(int id) { var admin = Session["Admin"] as TMDT.Account; if (admin == null) { return(RedirectToAction("Login", "Admin")); } string smtpUserName = "******"; string smtpPassword = "******"; string smtpHost = "smtp.gmail.com"; int smtpPort = 25; string emailTo = new AdminDAO().getemail(id); string subject = "Bạn có điểm đánh giá quá thấp"; string body = string.Format( "<br/>Xin chào {0}.<br/>Điểm đánh giá của bạn hiện tại là " + new AdminDAO().getrating(id) + ", số điểm này là quá thấp, điều này có thể dẫn đến đơn hàng của bạn.", new AdminDAO().getname(id), Url.Action("ConfirmEmail", "Home", new { Token = id, Email = new AdminDAO().getemail(id) }, Request.Url.Scheme)); EmailService service = new EmailService(); bool kq = service.Send(smtpUserName, smtpPassword, smtpHost, smtpPort, emailTo, subject, body, ""); return(View("AddUserNotification")); }
private void availBookTimeToolStripMenuItem_Click(object sender, EventArgs e) { Admin a = AdminDAO.GetAccountByUsername(user); AdminAvailibleBookingTimeGUI f = new AdminAvailibleBookingTimeGUI(a); embed(toolStripContainer1.ContentPanel, f); }
private void Comboload() { comboBox1.DataSource = null; comboBox1.ValueMember = "idUser"; comboBox1.DisplayMember = "name"; comboBox1.DataSource = AdminDAO.Userslist(); }
public DataTable GetAdminBystrName(string strCate) { string restr = strCate.Remove(strCate.LastIndexOf(",")).Replace(",", "','"); AdminDAO adminDAO = new AdminDAO(); return(adminDAO.GetAdminByStrName(restr)); }
public ActionResult SignUpAdmin(AdminModel model) { if (ModelState.IsValid) { var adminDao = new AdminDAO(); if (adminDao.CheckUserName(model.Username)) { ModelState.AddModelError("", "This account has already existed."); } else if (adminDao.CheckEmail(model.Email)) { ModelState.AddModelError("", "This email has already existed."); } else if (adminDao.CheckPhoneNumber(model.PhoneNumber)) { ModelState.AddModelError("", "This phone number has already existed."); } else { adminDao.insertAccount(model); adminDao.insertAdmin(model); string message = "Sign up successfully."; return(RedirectToAction("AdminHome", "Admin", new { message })); } } return(View(model)); }