public static bool UpdateAdmin(ADMIN admin) { bool status = false; try { using (OracleConnection connection = new OracleConnection(conlink)) { if (connection.State == ConnectionState.Closed) { connection.Open(); } string query = "UPDATE ADMIN SET ADMINNAME= :adminname ,PASSWORD = :password where ADMINID=:adminid"; OracleCommand cmd = new OracleCommand(query, connection); cmd.Parameters.Add(new OracleParameter(":adminname", admin.ADMINNAME)); cmd.Parameters.Add(new OracleParameter(":password", admin.PASSWORD)); cmd.Parameters.Add(new OracleParameter(":adminid", admin.ADMINID)); cmd.ExecuteNonQuery(); if (connection.State == ConnectionState.Open) { connection.Close(); } status = true; } } catch (Exception ex) { throw ex; } return(status); }
public static bool InsertAdmin(ADMIN admin) { bool status = false; try { using (OracleConnection connection = new OracleConnection(conlink)) { if (connection.State == ConnectionState.Closed) { connection.Open(); } string query = "INSERT INTO ADMIN (ADMINNAME,PASSWORD) " + "VALUES (:adminname,:password)"; OracleCommand cmd = new OracleCommand(query, connection); cmd.Parameters.Add(new OracleParameter(":adminname", admin.ADMINNAME)); cmd.Parameters.Add(new OracleParameter(":password", admin.PASSWORD)); cmd.ExecuteNonQuery(); if (connection.State == ConnectionState.Open) { connection.Close(); } status = true; } } catch (Exception ex) { throw ex; } return(status); }
public async Task <ActionResult <BaseRespone> > Put(int id, ADMIN admin) { var ad = await _db.Admins.FindAsync(id); if (ad == null) { return(new BaseRespone { ErrorCode = 1, Message = "Error put. This admin is not exists!" }); } ad.Adminid = admin.Adminid; ad.Username = admin.Username; ad.Password = admin.Password; ad.Fullname = admin.Fullname; //ad.image = company.PHONE; _db.Admins.Update(ad); await _db.SaveChangesAsync(); return(new BaseRespone { Message = "Put is successful", Data = ad }); }
public ActionResult Login(FormCollection collection) { var tendn = collection["username"]; var matkhau = collection["password"]; if (String.IsNullOrEmpty(tendn)) { ViewData["Loi1"] = "Phải nhập tên đăng nhập"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["Loi2"] = "Phải nhập mật khẩu"; } else { ADMIN ad = db.ADMINs.SingleOrDefault(n => n.UserAdmin == tendn && n.PassAdmin == matkhau); if (ad != null) { Session["Taikhoanadmin"] = ad; return(RedirectToAction("Index", "Admin")); } else { ViewBag.Thongbao = "Tên đăng nhập or mật khẩu không đúng"; } } return(View()); }
public IList <ADMIN> login(string tk, string mk) { DataTable dt = new DataTable(); string cmdtext = string.Format("select * from NHAN_VIEN_ where Email='{0}' and matKhau='{1}'", tk, mk); dt = DataAccessHelper.log(cmdtext); List <ADMIN> li = new List <ADMIN>(); foreach (DataRow dr in dt.Rows) { ADMIN ad = new ADMIN(); ad.manhanvien = dr[0].ToString(); ad.tennhanvien = dr[1].ToString(); ad.maloainhanvien = dr[2].ToString(); ad.gioitinh = dr[3].ToString(); ad.ngaysinh = DateTime.Parse(dr[4].ToString()); ad.ngayvaolam = DateTime.Parse(dr[5].ToString()); ad.diachi = dr[6].ToString(); ad.sodienthoai = dr[7].ToString(); ad.email = dr[8].ToString(); ad.matkhau = dr[9].ToString(); ad.hinhanh = dr[10].ToString(); li.Add(ad); } return(li); }
public object GetInfoUserByID(string maNhanVien) { DataTable dt = new DataTable(); string cmdText = string.Format(@" Select TenNhanVien,NV.MaLoaiNhanVien,GioiTinh,NgaySinh,DiaChi,SoDienThoai,Email,HinhAnh,TenLoaiNhanVien,NV.MaNhanVien From dbo.NHAN_VIEN_ NV Inner Join dbo.LOAI_NHAN_VIEN_ LNV On NV.MaLoaiNhanVien = LNV.MaLoaiNhanVien Where NV.MaNhanVien = '{0}'", maNhanVien); dt = DataAccessHelper.log(cmdText); List <ADMIN> li = new List <ADMIN>(); foreach (DataRow dr in dt.Rows) { ADMIN user = new ADMIN(); user.tennhanvien = dr[0].ToString(); user.maloainhanvien = dr[1].ToString(); user.gioitinh = dr[2].ToString(); user.ngaysinh = DateTime.Parse(dr[3].ToString()); user.diachi = dr[4].ToString(); user.sodienthoai = dr[5].ToString(); user.email = dr[6].ToString(); user.hinhanh = dr[7].ToString(); user.tenloainhanvien = dr[8].ToString(); user.manhanvien = dr[9].ToString(); li.Add(user); } return(li); }
public ActionResult EditTeacher(string username) { string un = username; // cmm rồi đó ADMIN tk = (ADMIN)Session["TaikhoanSV"]; if (tk == null || String.IsNullOrEmpty(tk.ToString())) { return(RedirectToAction("ViewAccountAdmin")); } else { //var gv = data.ADMINs.First(p => p.Role == 2); ViewBag.Name = tk.Name; ViewBag.Taikhoan = tk.Name; ViewBag.UserName = tk.Username; var pw = data.ADMINs.First(p => p.Username.Contains(username)); if (pw == null) { Response.StatusCode = 404; return(null); } return(View(pw)); } }
/// <summary> /// 更新管理员信息,由BLL层调用,成功返回true,失败返回fales; /// </summary> /// <param name="admin">要更新的管理员Admin实例</param> /// <returns>成功返回true,失败返回false</returns> public Boolean UpdateAdminInfo(Admin admin) { Boolean result = false; avfunEntities DataEntity = DataEntityManager.GetDataEntity(); try { ADMIN destAdmin = (from usr in DataEntity.ADMIN where usr.admin_id == admin.User_id && usr.admin_timestamp == admin.User_timestamp select usr).Single(); //全套更新 destAdmin.admin_id = admin.User_id; destAdmin.admin_account = admin.User_account; destAdmin.admin_password = admin.User_password; destAdmin.admin_last_login_time = admin.User_last_login_date; destAdmin.admin_last_login_ip = admin.User_last_login_ip; destAdmin.admin_nickname = admin.User_nickname; DataEntity.SaveChanges(); result = true; } catch { result = false; } return(result); }
public ActionResult AddAccountStudent(TAIKHOAN tksv, FormCollection collection) { ADMIN tk = (ADMIN)Session["TaikhoanSV"]; if (tk == null || String.IsNullOrEmpty(tk.ToString())) { return(RedirectToAction("LoginAdminStudent")); } else { ViewBag.UserName = tk.Username; ViewBag.Taikhoan = tk.Name; string rePass = collection["NLMK"]; string Pass = collection["MatKhau"]; if (rePass.Equals(Pass)) { var count = (from c in data.BAIVIETs select c).Count(); ViewBag.Count = count; data.TAIKHOANs.InsertOnSubmit(tksv); data.SubmitChanges(); return(RedirectToAction("AddAccountStudent")); } else { ViewBag.Mk = "Mật khẩu không khớp, xin nhập lại !"; return(View()); } } }
public ActionResult ViewAccountAdmin(string timkiem, int?page) { ADMIN tk = (ADMIN)Session["TaikhoanSV"]; if (tk == null || String.IsNullOrEmpty(tk.ToString())) { return(RedirectToAction("LoginAdminStudent")); } else { ViewBag.UserName = tk.Username; ViewBag.Taikhoan = tk.Name; ViewBag.Pass = tk.Password; ViewBag.Role = tk.Role; int pageNumber = (page ?? 1); int pageSize = 7; var filter = from d in data.ADMINs select d; if (!string.IsNullOrEmpty(timkiem)) { filter = filter.Where(a => a.Username.Contains(timkiem)); return(View(filter.ToPagedList(pageNumber, pageSize))); } return(View(data.ADMINs.Where(b => b.Role == 2).ToList().ToPagedList(pageNumber, pageSize))); } }
public ActionResult AddNewStudent() { ADMIN tk = (ADMIN)Session["TaikhoanSV"]; if (tk == null || String.IsNullOrEmpty(tk.ToString())) { return(RedirectToAction("LoginAdminStudent")); } else { ViewBag.UserName = tk.Username; ViewBag.Taikhoan = tk.Name; ViewBag.MaKhoa = new SelectList(data.KHOAs.ToList().OrderBy(n => n.MaKhoa), "MaKhoa", "TenKhoa"); ViewBag.MaKhoaHoc = new SelectList(data.KHOAHOCs.ToList().OrderBy(n => n.MaKhoaHoc), "MaKhoaHoc", "TenKhoaHoc"); ViewBag.MaLop = new SelectList(data.LOPs.ToList().OrderBy(n => n.MaLop), "MaLop", "TenLop"); var count = (from c in data.BAIVIETs select c).Count(); ViewBag.Count = count; return(View()); } }
public ActionResult ComfirmDeleteNews(int id) { ADMIN tk = (ADMIN)Session["TaikhoanSV"]; if (tk == null || String.IsNullOrEmpty(tk.ToString())) { return(RedirectToAction("LoginAdminStudent")); } else { ViewBag.UserName = tk.Username; ViewBag.Taikhoan = tk.Name; var count = (from c in data.BAIVIETs select c).Count(); ViewBag.Count = count; var bv = data.BAIVIETs.First(d => d.IdBV == id); if (bv == null) { Response.StatusCode = 404; return(null); } else { data.BAIVIETs.DeleteOnSubmit(bv); data.SubmitChanges(); return(RedirectToAction("ViewNews")); } } }
public ActionResult EditNews(int id) { ADMIN tk = (ADMIN)Session["TaikhoanSV"]; if (tk == null || String.IsNullOrEmpty(tk.ToString())) { return(RedirectToAction("LoginAdminStudent")); } else { ViewBag.UserName = tk.Username; ViewBag.Taikhoan = tk.Name; var count = (from c in data.BAIVIETs select c).Count(); ViewBag.Count = count; var bv = data.BAIVIETs.First(m => m.IdBV == id); if (bv == null) { Response.StatusCode = 404; return(null); } return(View(bv)); } }
public ActionResult DeletePoint(int id) { ADMIN tk = (ADMIN)Session["TaikhoanSV"]; if (tk == null || String.IsNullOrEmpty(tk.ToString())) { return(RedirectToAction("LoginAdminStudent")); } else { ViewBag.UserName = tk.Username; ViewBag.Taikhoan = tk.Name; var count = (from c in data.BAIVIETs select c).Count(); ViewBag.Count = count; var diem = data.DIEMs.First(d => d.Stt == id); if (diem == null) { Response.StatusCode = 404; return(null); } return(View(diem)); } }
public ActionResult Login(FormCollection collection) { var userad = collection["Userad"]; var passad = collection["Passad"]; if (String.IsNullOrEmpty(userad)) { ViewData["loi1"] = "Tài khoản không được bỏ trống"; } else if (String.IsNullOrEmpty(passad)) { ViewData["loi2"] = "Mật khẩu không được bỏ trống"; } else { ADMIN ad = db.ADMINs.SingleOrDefault(n => n.USERADMIN == userad && n.PASSADMIN == passad); if (ad != null) { Session["Admin"] = userad; return(RedirectToAction("Dondathang", "Admin")); } else { ViewBag.Thongbao = "Tên đăng nhập hoặc mật khẩu không đúng"; } } return(View()); }
public IHttpActionResult Post([FromBody] ADMIN admin) { if (!ModelState.IsValid || admin == null) { string errors = ""; foreach (var modelstate in ModelState.Values) { foreach (var error in modelstate.Errors) { errors += "|" + error.ErrorMessage + "|" + error.Exception; } } throw new BadInputException() { ExceptionMessage = errors }; } var result = _adminService.Add(admin); if (result == null) { return(NotFound()); } return(Created("admins", admin)); }
public ActionResult Login(FormCollection collection) { var tendn = collection["username"]; var matkhau = collection["password"]; if (String.IsNullOrEmpty(tendn)) { ViewData["Loi1"] = "Phải nhập tên đăng nhập"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["Loi2"] = "Phải nhập mật khẩu"; } else { ADMIN ad = data.ADMINs.SingleOrDefault(n => n.TENDANGNHAP == tendn && n.MATKHAU == matkhau); if (ad != null) { ViewBag.Thongbao = "Đăng nhập thành công"; Session["Taikhoanadmin"] = ad; return(RedirectToAction("Tin", "Admin")); } else { ViewBag.Thongbao = "Tên đăng nhập hoặc mật khẩu không chính xác"; } } return(View()); }
public HttpResponseMessage Put(String email, [FromBody] ADMIN ADMIN) { try { using (knowhauEntities entities = new knowhauEntities()) { var entity = entities.ADMINs.FirstOrDefault(e => e.email == email); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Admin with email " + email.ToString() + " not found to update")); } else { entity.email = ADMIN.email; entity.name = ADMIN.name; entity.password = ADMIN.password; entity.username = ADMIN.username; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public ActionResult Login(FormCollection f) { var tendn = f["username"]; var matkhau = f["password"]; if (String.IsNullOrEmpty(tendn)) { ViewData["Loi1"] = "Phai nhap ten dang nhap"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["Loi2"] = "Phai nhap mat khau"; } else { ADMIN ad = data.ADMINs.SingleOrDefault(n => n.UserAdmin == tendn && n.PassAdmin == matkhau); if (ad != null) { Session["Taikhoanadmin"] = ad; return(RedirectToAction("Index", "Admin")); } else { ViewBag.Thongbao = "Tai khoan khong ton tai"; } } return(View()); }
public void UpdateProfileUser(ADMIN user) { SqlParameter[] parm = new SqlParameter[] { new SqlParameter("@TenNhanVien", SqlDbType.NVarChar, 100), new SqlParameter("@GioiTinh", SqlDbType.NVarChar, 5), new SqlParameter("@NgaySinh", SqlDbType.Date), new SqlParameter("@DiaChi", SqlDbType.NVarChar, 200), new SqlParameter("@Email", SqlDbType.NVarChar, 100), new SqlParameter("@MaLoaiNhanVien", SqlDbType.NVarChar, 20), new SqlParameter("@HinhAnh", SqlDbType.NVarChar, 50), new SqlParameter("@SodienThoai", SqlDbType.NVarChar, 14), new SqlParameter("@MaNhanVien", SqlDbType.NVarChar, 20), }; parm[0].Value = user.tennhanvien; parm[1].Value = user.gioitinh; parm[2].Value = DateTime.Parse(user.ngaysinh.ToString()); parm[3].Value = user.diachi; parm[4].Value = user.email; parm[5].Value = user.maloainhanvien; parm[6].Value = user.hinhanh; parm[7].Value = user.sodienthoai; parm[8].Value = user.manhanvien; DataAccessHelper.ExecuteNonQuery(DataAccessHelper.ConnectionString, CommandType.StoredProcedure, "Update_Profile_User", parm); }
public ActionResult Login(FormCollection collection) { var tendn = collection["username"]; var matkhau = collection["pass"]; if (String.IsNullOrEmpty(tendn)) { ViewData["loi1"] = "Phải nhâp tài khoản"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["loi2"] = "Phải nhâp mật khẩu"; } else { ADMIN ad = data.ADMINs.SingleOrDefault(n => n.USERADMIN == tendn && n.PASSADMIN == matkhau); if (ad != null) { Session["TaikhoanAdmin"] = ad; return(RedirectToAction("TrangChu", "Admin")); } else { ViewBag.ThongBao = "Tên đăng nhập hoặc mật khẩu không đúng"; } } return(View()); }
public IList <ADMIN> getListUser(string page, string pagesize) { DataTable dt = new DataTable(); string cmdText = string.Format(@" Select TenNhanVien,NV.MaLoaiNhanVien,GioiTinh,NgaySinh,DiaChi,SoDienThoai,Email,HinhAnh,TenLoaiNhanVien,NV.MaNhanVien From dbo.NHAN_VIEN_ NV Inner Join dbo.LOAI_NHAN_VIEN_ LNV On NV.MaLoaiNhanVien = LNV.MaLoaiNhanVien Order By MaNhanVien Offset {1}*({0}-1) Rows Fetch next {1} rows only", page, pagesize); dt = DataAccessHelper.log(cmdText); List <ADMIN> li = new List <ADMIN>(); foreach (DataRow dr in dt.Rows) { ADMIN user = new ADMIN(); user.tennhanvien = dr[0].ToString(); user.maloainhanvien = dr[1].ToString(); user.gioitinh = dr[2].ToString(); user.ngaysinh = DateTime.Parse(dr[3].ToString()); user.diachi = dr[4].ToString(); user.sodienthoai = dr[5].ToString(); user.email = dr[6].ToString(); user.hinhanh = dr[7].ToString(); user.tenloainhanvien = dr[8].ToString(); user.manhanvien = dr[9].ToString(); li.Add(user); } return(li); }
public bool Save(ADMIN admin) { var model = db.ADMINs.FirstOrDefault(n => n.MaQuanTri == admin.MaQuanTri); try { if (model != null) { model.TenQuanTri = admin.TenQuanTri; model.TenDangNhap = admin.TenDangNhap; model.MatKhau = admin.MatKhau; model.QuyenTruyCap = admin.QuyenTruyCap; model.NgayTao = admin.NgayTao; model.IsDelete = admin.IsDelete; db.SaveChanges(); } else { ADMIN model2 = new ADMIN(); model2.TenQuanTri = admin.TenQuanTri; model2.TenDangNhap = admin.TenDangNhap; model2.MatKhau = admin.MatKhau; model2.QuyenTruyCap = 1; model2.NgayTao = DateTime.Now; model2.IsDelete = false; db.ADMINs.Add(model2); db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public ActionResult Login(FormCollection collection) { // Gán các giá trị người dùng nhập liệu cho các biến var tendn = collection["useradmin"]; var matkhau = collection["passadmin"]; if (String.IsNullOrEmpty(tendn)) { ViewData["Loi1"] = "Phải nhập tên đăng nhập"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["Loi2"] = "Phải nhập mật khẩu"; } else { //Gán giá trị cho đối tượng được tạo mới (ad) ADMIN ad = db.ADMINs.SingleOrDefault(n => n.UserAdmin == tendn && n.PassAdmin == matkhau); if (ad != null) { // ViewBag.Thongbao = "Chúc mừng đăng nhập thành công"; Session["Taikhoanadmin"] = ad; return(RedirectToAction("Index", "Admin")); } else { ViewBag.Thongbao = "Tên đăng nhập hoặc mật khẩu không đúng"; } } return(View()); }
public ActionResult Login(FormCollection collection) { if (ModelState.IsValid) { var user = collection["username"]; var pass = collection["password"]; if (String.IsNullOrEmpty(user)) { ViewData["Loi1"] = "Phải nhập tên đăng nhập"; } if (String.IsNullOrEmpty(pass)) { ViewData["Loi2"] = "Phải nhập mật khẩu"; } if (!String.IsNullOrEmpty(user) && !String.IsNullOrEmpty(pass)) { ADMIN ad = data.ADMINs.SingleOrDefault(n => n.useradmin == user && n.passadmin == pass); if (ad != null) { FormsAuthentication.SetAuthCookie(ad.hoten, false); Session["Admin"] = ad; return(RedirectToAction("Index", "Admin")); } else { ModelState.AddModelError("CredentialError", "Tên đăng nhập hoặc mật khẩu không đúng"); return(View()); //ViewBag.ThongBao = "Tên đăng nhập hoặc mật khẩu không đúng"; } } } return(View()); }
public ActionResult Login(FormCollection collection) { var tendn = collection["username"]; var matkhau = collection["password"]; if (String.IsNullOrEmpty(tendn)) { ViewData["Loi1"] = "phải nhập tên đăng nhập"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["Loi2"] = "phải nhập mật khẩu"; } else { ADMIN ad = db.ADMINs.SingleOrDefault(n => n.Taikhoan == tendn && n.Pass == matkhau); if (ad != null) { Session["TaikhoanAdmin"] = ad.HoTen; Session["AdminRole"] = ad.Role; return(RedirectToAction("Index", "Admin")); } else { ViewBag.Thongbao = "Tên đăng nhập hoặc mật khẩu không đúng"; } } return(View()); }
// Action thêm admin public ActionResult ThemAdmin(FormCollection f, ADMIN Admin) { try { string TENAD = f["TENAD"].ToString(); DateTime NGAYSINH = DateTime.Parse(f["NGAYSINH"].ToString()); string GIOITINH = f["GIOITINH"].ToString(); string DIACHI = f["DIACHI"].ToString(); string EMAIL = f["EMAIL"].ToString(); string MATKHAU = f["MATKHAU"].ToString(); Admin.TENAD = TENAD; Admin.NGAYSINH = NGAYSINH; Admin.GIOITINH = GIOITINH; Admin.DIACHI = DIACHI; Admin.EMAIL = EMAIL; Admin.MATKHAU = MATKHAU; Admin.TRANGTHAI = true; db.ADMINs.Add(Admin); db.SaveChanges(); } catch (Exception) { } return(RedirectToAction("Admin", "QLAdmin")); }
public static ADMIN GetAdmin(int id) { ADMIN admin = null; string query = "select * from ADMIN where ADMINID =:id"; OracleConnection connection = new OracleConnection(conlink); OracleCommand command = new OracleCommand(query, connection); command.Parameters.Add(new OracleParameter(":id", id)); try { connection.Open(); OracleDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { admin = new ADMIN() { ADMINID = int.Parse(reader["ADMINID"].ToString()), ADMINNAME = reader["ADMINNAME"].ToString(), PASSWORD = reader["PASSWORD"].ToString(), }; } } reader.Close(); } catch (Exception ex) { throw ex; } finally { connection.Close(); } return(admin); }
public ActionResult Create(string username, string password) { var item = new ADMIN(); item.USER_NAME = username; item.PASSWORD = password; item.IS_DELETE = 0; item.UPDATE_TIME = DateTime.Now; item.ADMIN_ROLE_RELATION = new List <ADMIN_ROLE_RELATION>(); var role = Request.Form["role"]; var rolesId = role.Split(new char[] { ',' }); foreach (var roleId in rolesId) { var rId = WebFunctions.StringToIntNullable(roleId); if (rId.HasValue) { var adminRole = new ADMIN_ROLE_RELATION(); adminRole.ROLE_ID = rId; adminRole.CREATE_TIME = DateTime.Now; adminRole.UPDATE_TIME = DateTime.Now; adminRole.IS_DELETE = 0; item.ADMIN_ROLE_RELATION.Add(adminRole); } } DB.ADMIN.Add(item); DB.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult LoginAdmin(ADMIN model) { using (db) { //Lấy username và password ở bản ghi đầu tiên var user = db.ADMINs.Where(x => x.TenDNAdmin == model.TenDNAdmin && x.MatKhauAdmin == model.MatKhauAdmin).FirstOrDefault(); if (user == null) { ViewBag.error = "Email or Password is fail"; return(View("LoginAdmin", model)); } else { //ViewBag.avatar = user.Avatar; //ViewBag.Online = user.IsActive; //Session["Online"] = user.IsActive; //Session["Avatar"] = user.Avatar; Session["MaAdmin"] = user.MaAdmin; Session["TenDNAdmin"] = user.TenDNAdmin; Session["Avartar"] = user.HinhAnh; Session["Email"] = user.EmailAdmin; //return View(user) return(RedirectToAction("IndexAdmin", "AdminCRUD")); } } }
Avfun_UI.Admin IAdminDAL.ConvertADMINToAdmin(ADMIN admin) { throw new NotImplementedException(); }