public int DeleteConfirmed(string[] inputCheck) { Email Email = new Email(); Imap imp = new Imap(); // Connect to the server, login and select inbox. imp.Connect("IMAP.gmail.com"); imp.Login("*****@*****.**", "tantan1193"); imp.SelectFolder("INBOX"); EnvelopeCollection envelopes = imp.DownloadEnvelopes(Imap.AllMessages, false); envelopes.Reverse(); int rowFinish = 0; if (inputCheck == null) { return(rowFinish); } foreach (var s in inputCheck) { long idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s)); foreach (Envelope env in envelopes) { if (idMenu == env.Uid) { imp.DeleteMessages(env.Uid.ToString(), true); break; } } } // Disconnect from the server. imp.Disconnect(); return(rowFinish); }
public ActionResult Header() { var id = DefineFuntion.UserId(); ViewBag.User = db.Users.Find(id); return(PartialView()); }
private int EventStatus(string[] inputCheck, string typeName) { int rowFinish = 0; if (inputCheck == null) { return(rowFinish); } foreach (var s in inputCheck) { try { int id = Convert.ToInt32(DefineFuntion.Decrypt(s)); var obj = db.LandGroups.Find(id); if (typeName == "activity") { obj.Status = 1;//Cho phép dùng } else if (typeName == "inactive") { obj.Status = 2;//Không cho dung } else if (typeName == "trash") { obj.Status = 3;//Dưa vào thùng rác } db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); rowFinish++; } catch (Exception) { } } return(rowFinish); }
public ActionResult MenuLeft() { //var obj = Membership.GetUser(); var idUs = DefineFuntion.UserId(); ViewBag.UserRoles = share.GetRolesUser(); // db.UserRoles.Where(t => t.UserId == idUs).Select(t => t.Role.Code).ToArray(); ViewBag.UserRolesMenu = share.GetRolesUserMenu(); ViewBag.User = db.Users.Find(idUs); return(PartialView()); }
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()); }
[Authorize(Roles = "QL,Regency,RegencyD")] //Delete public int DeleteConfirmed(string[] inputCheck) { //System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Chắc chắn không?", "Thông báo", System.Windows.Forms.MessageBoxButtons.YesNo); int rowFinish = 0; if (inputCheck == null) { return(rowFinish); } //if (dialogResult == System.Windows.Forms.DialogResult.Yes) //{ foreach (var s in inputCheck) { try { int idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s)); Regency obj = db.Regencies.Find(idMenu); //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Xóa Chức Vụ", Contens = JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), ItemId = obj.RegencyId, Type = (int)DefineFuntion.TypeHistory.Career, }); db.Regencies.Remove(obj); db.SaveChanges(); rowFinish++; } catch (Exception) { int idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s)); Regency obj = db.Regencies.Find(idMenu); obj.Status = 3; db.SaveChanges(); } } //} // else if (dialogResult == System.Windows.Forms.DialogResult.No) //{ // return rowFinish; //} return(rowFinish); }
public ActionResult Edit(ServiceOther ServiceOther, string codeSystem, string typeName) { ServiceOther.ServiceOtherId = Convert.ToInt32(DefineFuntion.Decrypt(codeSystem)); int ms = 0; var me = db.ServiceOthers.Find(ServiceOther.ServiceOtherId); try { var dat = DateTime.Now.ToString("MM'/'dd'/'yyyy HH:mm:ss"); me.Name = ServiceOther.Name; me.Status = ServiceOther.Status; me.Address = ServiceOther.Address; me.AddressShow = ServiceOther.AddressShow; me.Description = ServiceOther.Description; me.Contents = ServiceOther.Contents; me.UpdateBy = ServiceOther.UpdateBy = @User.Identity.GetUserName(); me.UpdateDay = ServiceOther.UpdateDay = DateTime.Parse(dat); db.SaveChanges(); ms = 3;//Nếu cập nhật thành công //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Cập Nhật Dịch Vụ", Contens = JsonConvert.SerializeObject(me, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), ItemId = me.ServiceOtherId, Type = (int)DefineFuntion.TypeHistory.ServiceOther, }); } catch (Exception) { ms = 4;//Nếu cập nhật không thành công } if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = codeSystem, mess = ms })); } }
public ActionResult Edit(string id, int?mess) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } int obj = Convert.ToInt32(DefineFuntion.Decrypt(id)); var landGroup = db.LandGroups.Find(obj); if (landGroup == null) { return(HttpNotFound()); } ViewBag.Mess = (mess ?? 0); ViewBag.Status = new SelectList(DefineFuntion.ListStatus, "Value", "Text", landGroup.Status); return(View(landGroup)); }
public ActionResult Edit(ServiceOtherPrice ServiceOtherPrice, string codeSystem, string typeName) { ServiceOtherPrice.ServiceOtherPriceId = Convert.ToInt32(DefineFuntion.Decrypt(codeSystem)); int ms = 0; var me = db.ServiceOtherPrices.Find(ServiceOtherPrice.ServiceOtherPriceId); try { me.Name = ServiceOtherPrice.Name; me.Status = ServiceOtherPrice.Status; me.FromDay = ServiceOtherPrice.FromDay; me.ToDay = ServiceOtherPrice.ToDay; me.Price = ServiceOtherPrice.Price; me.PriceAdult = ServiceOtherPrice.PriceAdult; me.PriceChild = ServiceOtherPrice.PriceChild; me.PriceInfant = ServiceOtherPrice.PriceInfant; me.PriceBaby = ServiceOtherPrice.PriceBaby; db.SaveChanges(); ms = 3;//Nếu cập nhật thành công //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Cập Nhật Giá Dịch Vụ", Contens = JsonConvert.SerializeObject(me, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), ItemId = me.ServiceOtherPriceId, Type = (int)DefineFuntion.TypeHistory.ServiceOtherPrice, }); } catch (Exception) { ms = 4;//Nếu cập nhật không thành công } if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = codeSystem, mess = ms })); } }
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 Edit(string id, int?mess) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } int obj = Convert.ToInt32(DefineFuntion.Decrypt(id)); var ServiceOtherPrice = db.ServiceOtherPrices.Find(obj); if (ServiceOtherPrice == null) { return(HttpNotFound()); } ViewBag.Mess = (mess ?? 0); ViewBag.Status = new SelectList(DefineFuntion.ListStatus, "Value", "Text", 1); ViewBag.ServiceOther = new SelectList(shared.GetServiceOther(), "Value", "Text"); ViewBag.Provider = new SelectList(shared.GetProvider(), "Value", "Text"); ViewBag.Contract = new SelectList(shared.GetContract(), "Value", "Text"); ViewBag.Paymen = new SelectList(shared.GetPaymen(), "Value", "Text"); return(View(ServiceOtherPrice)); }
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()); }
[Authorize(Roles = "QL,LandGroup,LandGroupD")] //Delete public int DeleteConfirmed(string[] inputCheck) { int rowFinish = 0; if (inputCheck == null) { return(rowFinish); } foreach (var s in inputCheck) { try { int idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s)); LandGroup obj = db.LandGroups.Find(idMenu); //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Xóa LandGroup", Contens = JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), ItemId = obj.LandGroupId, Type = (int)DefineFuntion.TypeHistory.LandGroup, }); db.LandGroups.Remove(obj); db.SaveChanges(); rowFinish++; } catch (Exception) { int idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s)); LandGroup obj = db.LandGroups.Find(idMenu); obj.Status = 3; db.SaveChanges(); } } return(rowFinish); }
public ActionResult Index(string sortOrder, string searchString, int?numberRow, int?page) { ViewBag.Mess = 0; ViewBag.ArrRow = DefineFuntion.ArrRow; ViewBag.NumberRow = Convert.ToInt32(numberRow) <= 0 ? 20 : Convert.ToInt32(numberRow); ViewBag.SearchString = searchString; DefineSort(sortOrder); var obj = db.LandGroups.Where(t => t.Status != 3).ToList(); obj = Authorities(obj); if (!String.IsNullOrEmpty(searchString)) { searchString = searchString.ToLower(); var searchStr = DefineFuntion.RemoveCharAndNoSign(searchString); obj = obj.Where(s => (s.Name ?? "").ToLower().Contains(searchStr)).ToList(); } obj = EvenSort(obj, sortOrder); int pageSize = Convert.ToInt32(numberRow) <= 0 ? 20 : Convert.ToInt32(numberRow); int pageNumber = (page ?? 1); return(View(obj.ToPagedList(pageNumber, pageSize))); }
public ActionResult Edit(LandGroup landGroup, string codeSystem, string typeName) { landGroup.LandGroupId = Convert.ToInt32(DefineFuntion.Decrypt(codeSystem)); int ms = 0; var me = db.LandGroups.Find(landGroup.LandGroupId); try { me.Name = landGroup.Name; me.Status = landGroup.Status; me.Note = landGroup.Note; db.SaveChanges(); ms = 3;//Nếu cập nhật thành công //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Xóa Chức Vụ", Contens = JsonConvert.SerializeObject(me, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), ItemId = me.LandGroupId, Type = (int)DefineFuntion.TypeHistory.LandGroup, }); } catch (Exception) { ms = 4;//Nếu cập nhật không thành công } if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = codeSystem, mess = ms })); } }
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()); }