public int CapNhatThongTinUser(UserDetail user) { int result = 1; if (user.password == user.confirmPW) { user_tb tmp = new user_tb(); tmp.username = user.username; tmp.password = user.password; tmp.email = user.email; tmp.dien_thoai = user.dien_thoai; tmp.dia_chi = user.dia_chi; tmp.ghi_chu = user.ghi_chu; tmp.user_guid = user.user_guid; bool check = _user.SetInfoAccount(tmp, user.password, user.confirmPW); if (check == true) { result = 0; } else { result = 1; } } return(result); }
public bool EditUser(UserDetail user) { bool check = true; #region Kiểm tra tồn tại và cập nhật dữ liệu. try { user_tb tmp = _database._databaseContext.user_tb.FirstOrDefault(c => c.user_code == user.user_code); tmp.username = user.username; tmp.password = user.password; tmp.email = user.email; tmp.dien_thoai = user.dien_thoai; tmp.dia_chi = user.dia_chi; tmp.ghi_chu = user.ghi_chu; _database._databaseContext.SaveChanges(); } catch (Exception ex) { check = false; } #endregion return(check); }
//public ActionResult ThongTin() //{ // return View("ThongTin"); //} // [Route("TuVan/GetInfoTuVan/{tuVanGuid?}")] public ActionResult GetInfoTuVan(string tuVanGuid) { BanTinTuVan bttv = null; try { if (!string.IsNullOrEmpty(Security.CurrentUserGuid)) { user_tb tmpUser = _user.GetInfoUserVHLH(Security.CurrentUserGuid); tu_van_tb tmpTuVan = _tuvan.GetTuVaByGuid(tuVanGuid); if (tmpUser != null && tmpTuVan != null) { if (tmpUser.don_vi_ref == tmpTuVan.don_vi_ref || _common.CheckAdmin()) { bttv = _tuvan.GetInfoTuVanByGuid(tuVanGuid); } } } } catch (Exception ex) { bttv = null; } return(View(bttv)); }
public bool createUser(UserDetail user) { bool check = false; try { user_tb tmp = new user_tb(); tmp.don_vi_ref = user.don_vi_ref; tmp.username = user.username; tmp.email = user.email; tmp.password = user.password; tmp.dia_chi = user.dia_chi; tmp.dien_thoai = user.dien_thoai; tmp.ghi_chu = user.ghi_chu; tmp.deleted_status = 0; tmp.row_id = new Guid().ToString(); tmp.user_guid = user.user_guid; _database._databaseContext.user_tb.Add(tmp); _database._databaseContext.SaveChanges(); check = true; } catch (Exception) { check = false; } return(check); }
/// <summary> /// 执行注册命令 /// </summary> /// <param name="command"></param> /// <returns></returns> public UserLoginCommandResult Execute(UserRegisterCommand command) { try { if (command.Password != command.ConfirmPassword) { return(new UserLoginCommandResult("两次输入密码不一致")); } // 开始事务 this._db.GetSession().BeginTran(); user_tb user = new user_tb(); user.user_account = command.UserAccount; user.user_pwd = command.Password.GetMd5Hash(); this._db.GetSession().Insert(user); // 提交事务 this._db.GetSession().CommitTran(); return(new UserLoginCommandResult() { UserInfo = user }); } catch (Exception e) { // 回滚事务 this._db.GetSession().RollbackTran(); return(new UserLoginCommandResult(e.ToString())); } }
// POST api/parent public bool PostParent(JObject result) { //XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(result.ToString()); List <student_tb> _lstudents_dto = new List <student_tb>(); int _lschool_id = 0; int _lclass_id = 0; //List of students of user type parent foreach (var s in result["students_dto"]) { //parent's child student etials student_tb st = new student_tb { student_id = (int)s["student_id"], user_id = (int)s["user_id"], school_id = (int)s["school_id"], firstname = (string)s["firstname"], surname = (string)s["surname"], rollno = (int)s["rollno"], class_id = (int)s["class_id"], address = (string)s["address"], sex = (string)s["sex"], remarks = (string)s["remarks"], date_created = DateTime.Now, }; _lschool_id = (int)s["school_id"]; _lclass_id = (int)s["class_id"]; _lstudents_dto.Add(st); _db.student_tb.Add(st);// Inserting a student } //parent user details user_tb _parent = new user_tb { user_id = (int)result["user_id"], school_id = _lschool_id, user_name = (string)result["user_name"], password = (string)result["password"], firstname = (string)result["firstname"], surname = (string)result["surname"], type = (string)result["type"], phoneno = (string)result["phoneno"], mobileno = (string)result["mobileno"], address = (string)result["address"], relation = (string)result["relation"], remarks = (string)result["remarks"], date_created = DateTime.Now, student_tb = _lstudents_dto }; _db.user_tb.Add(_parent); // Inserting a parent _db.SaveChanges(); //changes are commited to the Database. return(result != null); }
public user_tb ThongTinUser(string x) // lấy ra thông tin user { var query = (from user in _database._databaseContext.user_tb where user.user_guid == x select user).FirstOrDefault(); user_tb thongtin = query; return(thongtin); }
public ActionResult register(user_tb user_tbs) { if (ModelState.IsValid) { db.user_tb.Add(user_tbs); db.SaveChanges(); return(RedirectToAction("login")); } return(View(user_tbs)); }
/// <summary> /// ThamNT /// </summary> /// <param name="usergui">Mã grui tương ứng với user đăng nhập vào hệ thống</param> /// <returns>mã đơn vị lập bản tin tư vấn</returns> public int test_donvi_ref(string usergui) { user_tb donvi = _database._databaseContext.user_tb.Where(m => m.user_guid == usergui).SingleOrDefault(); if (donvi == null) { return(-1); } return(int.Parse(donvi.don_vi_ref.ToString())); }
/// <summary> /// HieuTM: Thêm mới hoặc cập nhật thay đổi cho tài khoản /// </summary> /// <param name="user"></param> /// <returns></returns> public bool UpdateUser(UserDetail user) { bool result = true; #region Kiểm tra tồn tại và cập nhật dữ liệu. try { user_tb tmp = _database._databaseContext.user_tb.FirstOrDefault(c => c.user_code == user.user_code); if (tmp == null) { tmp = new user_tb { user_code = user.user_code, username = user.username, password = "******", email = user.email, dien_thoai = user.dien_thoai, dia_chi = user.dia_chi, mo_ta = user.mo_ta, deleted_status = 0, account_status = user.account_status_ref, ghi_chu = user.ghi_chu, row_id = user.row_id, don_vi_ref = user.don_vi_ref }; _database._databaseContext.user_tb.Add(tmp); } else { tmp.user_code = user.user_code; tmp.username = user.username; tmp.password = user.password; tmp.email = user.email; tmp.dien_thoai = user.dien_thoai; tmp.dia_chi = user.dia_chi; tmp.mo_ta = user.mo_ta; tmp.deleted_status = user.deleted_status; tmp.account_status = user.account_status_ref; tmp.ghi_chu = user.ghi_chu; tmp.row_id = user.row_id; tmp.don_vi_ref = user.don_vi_ref; } _database._databaseContext.SaveChanges(); } catch (Exception ex) { result = false; } #endregion return(result); }
/// <summary> /// HieuTM: Lấy thông tin chi tiết theo dữ liệu user trên db VHLH /// </summary> /// <param name="userGuid"></param> /// <returns></returns> public user_tb GetInfoUserVHLH(string userGuid) { user_tb result = null; try { result = _database._databaseContext.user_tb.FirstOrDefault(x => x.user_guid == userGuid); } catch (Exception ex) { } return(result); }
public JsonResult ThongTinUse() // lấy ra thông tin của user { user_tb ThongTin = new user_tb(); if (string.IsNullOrEmpty(Security.CurrentUserGuid.Trim())) { ThongTin = null; } else { ThongTin = _user.ThongTinUser(Security.CurrentUserGuid); } return(Json(ThongTin, JsonRequestBehavior.AllowGet)); }
// GET: user/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } user_tb user_tb = db.user_tb.Find(id); if (user_tb == null) { return(HttpNotFound()); } return(View(user_tb)); }
public ActionResult login(user_tb user_tbs) { int counts = db.user_tb.Where(x => x.user_email == user_tbs.user_email && x.password == user_tbs.password).Count(); if (counts == 0) { ViewBag.invaliduser = "******"; return(View()); } else { FormsAuthentication.SetAuthCookie(user_tbs.user_email, false); return(RedirectToAction("Index", "Home")); } }
/// <summary> /// HieuTM: Thay doi thong tin tai khoan trong he thong /// </summary> /// <param name="PostData"></param> /// <param name="passwordNew"></param> /// <param name="confirmPassword"></param> /// <returns></returns> public JsonResult ChangeInForUser(string PostData, string passwordNew, string confirmPassword) // đổi thông tin của user ( bên js em có các kiểu giá trị trả về, a xem rồi trả về cho phù hợp ạ { JavaScriptSerializer serializer = new JavaScriptSerializer(); user_tb listposition = serializer.Deserialize <user_tb>(PostData); if (_user.SetInfoAccount(listposition, passwordNew, confirmPassword)) { return(Json(-2)); } else { return(Json(-1)); } // int x = _phuongan.udateUser(listposition, passwordNew); }
/// <summary> /// HieuTM: Cập nhật lại thông tin cho bảng user_tb /// </summary> /// <param name="accPassOld"></param> /// <param name="accPassNew"></param> /// <param name="accRePassNew"></param> /// <param name="accTel"></param> /// <param name="accEmail"></param> /// <param name="accGhiChu"></param> /// <param name="accDiaChi"></param> /// <returns></returns> public bool SetInfoAccount(user_tb data, string accPassNew, string accRePassNew) { bool result = false; try { #region Gọi service check cập nhật bên TLVN string url = linkServer + "Home/AcountAccSetVHLH"; var request = (HttpWebRequest)WebRequest.Create(url); string postData = String.Format( "userGuid={0}&accSetOldPassWord={1}&accSetPassWord={2}&accSetRePassWord={3}&accSetFullName={4}&accSetEmail={5}&accSetDiaChi={6}&inputAccSetTel={7}&accSetGhiChu", Security.CurrentUserGuid, data.password, accPassNew, accRePassNew, data.username, data.email, data.dia_chi, data.dien_thoai, data.ghi_chu); var datatmp = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = datatmp.Length; using (var stream = request.GetRequestStream()) { stream.Write(datatmp, 0, datatmp.Length); } var response = (HttpWebResponse)request.GetResponse(); string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); #endregion if (responseString == "1") { data.user_guid = Security.CurrentUserGuid; if (UpdateUserDbVHLH(data, accPassNew) == 1) { result = true; } } } catch (Exception ex) { } return(result); }
public bool deleteUser(int userId) { bool check = true; #region Kiểm tra tồn tại và cập nhật dữ liệu. try { user_tb tmp = _database._databaseContext.user_tb.FirstOrDefault(c => c.user_code == userId); tmp.deleted_status = 1; _database._databaseContext.SaveChanges(); } catch (Exception ex) { check = false; } #endregion return(check); }
public ActionResult InsertTuVan(BanTinTuVan bantintuvan) { // string _curentUsetID = Lib.Security.CurrentUserId; //trả về mã gui(trong bảng user) nếu chuỗi trắng thì chưa đăng nhập.Khi nào đăng nhập thì mới được thêm //kiểm tra mã trong bảng usertb string _curentUsetGuid = Security.CurrentUserGuid; bool result = false; if (!string.IsNullOrEmpty(_curentUsetGuid)) { user_tb tmpUser = _user.GetInfoUserVHLH(_curentUsetGuid); if (tmpUser != null & tmpUser.user_guid != null) { if (_tuvan.Insert(bantintuvan, tmpUser.don_vi_ref.Value)) { result = true; } } } return(Json(new { status = result })); }
/// <summary> /// HieuTM: Cập nhật dữ liệu cho bảng user_tb của db postgress VHLH; 1: Thành công; 0: Thất bại; -1: Có lỗi cập nhật /// </summary> /// <param name="x"></param> /// <param name="passwordNew"></param> /// <returns></returns> private int UpdateUserDbVHLH(user_tb x, string passwordNew) { int result = 0; try { var user = _database._databaseContext.user_tb.FirstOrDefault(e => e.user_guid == x.user_guid); user.username = x.username; user.email = x.email; user.dia_chi = x.dia_chi; user.dien_thoai = x.dien_thoai; user.ghi_chu = x.ghi_chu; // user.password = passwordNew; _database._databaseContext.SaveChanges(); result = 1; } catch (Exception) { result = -1; } return(result); }