public ActionResult ChangePassword(string OldPass, string NewPass, string ReNewPass) { int ms = 0; string str = ""; if (NewPass == ReNewPass) { if (!string.IsNullOrWhiteSpace(OldPass) && !string.IsNullOrWhiteSpace(NewPass) && !string.IsNullOrWhiteSpace(ReNewPass)) { var id = DefineFuntion.UserId(); var obj = db.Users.Find(id); if (obj != null) { if (obj.Password == DefineFuntion.Encrypt(OldPass)) { obj.Password = DefineFuntion.Encrypt(ReNewPass); obj.RePassDay = DateTime.Now; db.SaveChanges(); } else { ms = 3; str = "Mật khẩu củ không đúng!"; } } else { ms = 3; str = "Vui lòng đăng nhập!"; } } else { ms = 3; str = "Vui lòng nhập đầy đủ thông tin!"; } } else { ms = 3; str = "Nhập lại mật khẩu sai!"; } ViewBag.Mess = ms; ViewBag.Str = str; return(View()); }
public ActionResult Create(ServiceOther ServiceOther, string typeName) { var shared = new SharedFuntionController(); int ms = 0; try { var dat = DateTime.Now.ToString("MM'/'dd'/'yyyy HH:mm:ss"); ServiceOther.CreateBy = @User.Identity.GetUserName(); ServiceOther.CreateDay = DateTime.Parse(dat); db.ServiceOthers.Add(ServiceOther); db.SaveChanges(); ms = 1; //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Thêm Dịch Vụ", Contens = "", ItemId = ServiceOther.ServiceOtherId, Type = (int)DefineFuntion.TypeHistory.ServiceOther, }); } catch (Exception) { ms = 2; } if (ms != 2) { if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = DefineFuntion.Encrypt(ServiceOther.ServiceOtherId), mess = ms })); } } ViewBag.Status = new SelectList(DefineFuntion.ListStatus, "Value", "Text", ServiceOther.Status); return(View("Create", "ServiceOther")); }
public ActionResult Create(Regency rengency, string typeName) { var shared = new SharedFuntionController(); int ms = 0; try { if (ModelState.IsValid) { db.Regencies.Add(rengency); db.SaveChanges(); ms = 1; //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Thêm Chức Vụ", Contens = "", ItemId = rengency.RegencyId, Type = (int)DefineFuntion.TypeHistory.Regency, }); } } catch (Exception) { ms = 2; } if (ms != 2) { if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = DefineFuntion.Encrypt(rengency.RegencyId), mess = ms })); } } ViewBag.Status = new SelectList(DefineFuntion.ListStatus, "Value", "Text", rengency.Status); return(View()); }
public ActionResult Create(LandGroup landGroup, string typeName) { var shared = new SharedFuntionController(); int ms = 0; try { db.LandGroups.Add(landGroup); db.SaveChanges(); ms = 1; //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Thêm LandGroup", Contens = "", ItemId = landGroup.LandGroupId, Type = (int)DefineFuntion.TypeHistory.LandGroup, }); } catch (Exception ex) { ms = 2; ViewBag.Err = ex.InnerException; } if (ms != 2) { if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = DefineFuntion.Encrypt(landGroup.LandGroupId), mess = ms })); } } ViewBag.Status = new SelectList(DefineFuntion.ListStatus, "Value", "Text", landGroup.Status); return(View()); }
public ActionResult Create(Career career, string typeName) { var shared = new SharedFuntionController(); int ms = 0; try { db.Careers.Add(career); db.SaveChanges(); ms = 1; //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Thêm ngành", Contens = "", ItemId = career.CareerId, Type = (int)DefineFuntion.TypeHistory.Career, }); } catch (Exception) { ms = 2; } if (ms != 2) { if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = DefineFuntion.Encrypt(career.CareerId), mess = ms })); } } ViewBag.Status = new SelectList(DefineFuntion.ListStatus, "Value", "Text", career.Status); return(View()); }