public ActionResult Create(Article article) { if (ModelState.IsValid) { try { article.ArtPostTime = DateTime.Now; article.ArtStatus = "New"; ListAccount accountManager = new ListAccount(); bool isAdmin = accountManager.getRole(article.ArtUsername); if (isAdmin) { article.ArtStatus = "Active"; db.Articles.Add(article); db.SaveChanges(); return(RedirectToAction("Index", "Admin")); } db.Articles.Add(article); db.SaveChanges(); return(RedirectToAction("Profile", "Accounts")); } catch (Exception e) { CommonUse.WriteLogError(e); } } return(View(article)); }
public ActionResult Register(Account account) { bool isInsert = false; if (account.FullName.Equals("UserBlocked")) { ViewBag.Message = "Please input real Full Name"; return(View()); } try { // TODO: Add insert logic here ListAccount listAccount = new ListAccount(); isInsert = listAccount.RegisterNewAccount(account); if (isInsert) { Session["Msg_reg_succ"] = "Register Success"; return(RedirectToAction("Login")); } else { ViewBag.Message = "This Username has been exist! Please choose another one"; } } catch (Exception e) { ViewBag.Message = "This Username has been exist! Please choose another one"; CommonUse.WriteLogError(e); } return(View()); }
public async Task <IActionResult> Payloan(int?id) { if (id == null) { return(NotFound()); } var account = await _context.Account .Include(a => a.ApplicationUser) .FirstOrDefaultAsync(m => m.Id == id); if (account == null) { return(NotFound()); } string Current_UserId = _context.Users.Where(x => x.Email == User.Identity.Name).FirstOrDefault().Id; var accountList = await _context.Account.Where(u => u.UserId == Current_UserId && u.isActive).ToListAsync(); ListAccount listAccount = new ListAccount() { currentAccount = account, listAccount = accountList }; return(View(listAccount)); }
public ActionResult Block(string username) { ListAccount account = new ListAccount(); account.BlockAccount(username); return(RedirectToAction("Index", "Accounts")); }
// GET: AccountManager public ActionResult Index() { ViewBag.quyen = AccSession.FK_iMaQuyen; ViewBag.unknowThing = AccSession.SPassword; ViewBag.accUsername = AccSession.SUsername; List <TaiKhoan> data = new List <TaiKhoan>(); data = new ListAccount().GetListAccounts(); return(View(data)); }
private async void DeleteEmp(int?obj) { try { dc = new DialogContent() { Content = "Bạn muốn xóa tài khoản này ?", Tilte = "Thông Báo" }; var dialogYS = new DialogYesNo() { DataContext = dc }; var result = (bool)await DialogHost.Show(dialogYS, DialogHostId); if (result) { if (obj != null) { if (await employee_Repo.Remove((int)obj)) { ListAccount.Remove(ListAccount.SingleOrDefault(t => t.EmpID == (int)obj)); dc = new DialogContent() { Content = "Xóa Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; await DialogHost.Show(dialog, DialogHostId); } else { dc = new DialogContent() { Content = "Xóa Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; await DialogHost.Show(dialog, DialogHostId); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public ActionResult Index() { List <Account> list = new List <Account>(); try { ListAccount accountList = new ListAccount(); list = accountList.getListAccount(); } catch (Exception e) { CommonUse.WriteLogError(e); } return(View(list)); }
public async void SendGetAccount() { if (MyClub != null) { if (MyClub.Numbers != null && MyClub.Numbers.Count > 0) { foreach (var item in MyClub.Numbers) { var acc = await Helper.Instance().CheckExistAccount(item); if (acc.Number_Id > 0) { var accJoinClub = new Accountlocal(); accJoinClub.Avatar_Uri = acc.Avatar_Uri; accJoinClub.fullname = acc.fullname; accJoinClub.Number_Id = acc.Number_Id; accJoinClub.Level = "Hạng C"; accJoinClub.AccepLevel = "Đã Duyệt"; accJoinClub.Facebat = "Mặt A - Hãng A"; accJoinClub.Blade = "Cốt A - Hãng A"; if (!ChallengeAction.ListAccRecive.ContainsKey(acc.Number_Id)) { accJoinClub.Challenge = "pingpong.png"; } else { accJoinClub.Challenge = "pingpong_invi.png"; } accJoinClub.AddFriend = Helper.Instance().IsFriendImg(acc.Number_Id); ListAccount.Add(accJoinClub); if (!Helper.Instance().ListAcclocal.ContainsKey(acc.Number_Id)) { Helper.Instance().ListAcclocal.Add(acc.Number_Id, accJoinClub); } } } } } }
public ActionResult Login(Account account) { try { if (ModelState.IsValid) { ListAccount Accounts = new ListAccount(); string fullname = Accounts.checkLogin(account.Username, account.Password, account.Role); if (fullname != null) { if (fullname.Equals("UserBlocked")) { ViewBag.Message = "Your account was blocked ! "; } else { account.FullName = fullname; Session["FULL_NAME"] = account.FullName.ToUpper(); Session["USER_NAME"] = account.Username; Session["ROLE"] = account.Role; return(RedirectToAction("Index", "Home")); } } else { ViewBag.Message = "Invalid username or password"; } } } catch (Exception e) { CommonUse.WriteLogError(e); } return(View()); }
private async void ShowInfoEmp(string obj) { if (!string.IsNullOrEmpty(obj)) { var emp = ListAccount.SingleOrDefault(t => t.NameLogin.Equals(obj)); if (emp != null) { UserName = emp.UserName; NameLogin = emp.NameLogin; EmpID = emp.EmpID.ToString(); ImgEmp = emp.Avatar.LoadImage(); Phone = emp.Phone; IsB = IsG = false; if (emp.Sex == true) { IsB = true; } if (emp.Sex == false) { IsG = true; } if (emp.Role == 0) { IsE = true; } if (emp.Role == -1) { IsE = false; } Address = emp.Address; DOB = emp.DOB.ToString(); } DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(new AccountProfile(), DialogHostId); } }
public AccountMngVM() { AddAccountCmd = new RelayCommand <Button>((p) => { return(true); }, (p) => { IsAdding = true; IsEnabledUserNameTextBox = true; IsEnabledTextBox = true; }); EditCommand = new RelayCommand <Button>((p) => { return(SelectedAccount == null ? false : true); }, (p) => { IsAdding = false; IsEnabledUserNameTextBox = false; IsEnabledTextBox = true; }); SaveCommand = new RelayCommand <Button>((p) => { if (IsEnabledTextBox && ((Password != null && Password2 != null && IsAdding) || !IsAdding)) { return(true); } else { return(false); } }, (p) => { IsEnabledTextBox = false; IsEnabledUserNameTextBox = false; if (!IsAdding) { var account = DataProvider.Ins.DB.TAIKHOANs.Where(x => x.TENTK == SelectedAccount.TENTK).SingleOrDefault(); if (account == null) { MessageBoxWindow mess2 = new MessageBoxWindow(); mess2.Tag = "Không tìm thấy tài khoản này"; mess2.ShowDialog(); // MessageBox.Show("Không tìm thấy tài khoản này", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (Img != null) { Image = ByteToImageConverter.Ins.ImageToByte(Img); account.HINHANH = Image; } else { account.HINHANH = null; } account.TENTK = AccountName; account.TENHIENTHI = DisplayName; account.LOAITK = TypeAccount.IDType; if (Password != null) { if (Password != Password2) { MessageBoxWindow mess2 = new MessageBoxWindow(); mess2.Tag = "Nhập lại mật khẩu không khớp với mật khẩu đã nhập!"; mess2.ShowDialog(); // MessageBox.Show("Nhập lại mật khẩu không khớp với mật khẩu đã nhập!", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); } else { account.MATKHAU = Password; } } else { account.MATKHAU = DataProvider.Ins.DB.TAIKHOANs.Where(x => x.TENTK == SelectedAccount.TENTK).SingleOrDefault().MATKHAU; } DataProvider.Ins.DB.SaveChanges(); Password2 = Password = null; IsAdding = true; } else { if (Img != null) { Image = ByteToImageConverter.Ins.ImageToByte(Img); } else { Image = null; } var account = new TAIKHOAN() { TENTK = AccountName, TENHIENTHI = DisplayName, HINHANH = Image, LOAITK = TypeAccount.IDType, MATKHAU = Password }; if (DataProvider.Ins.DB.TAIKHOANs.Where(x => x.TENTK == account.TENTK).Count() > 0) { MessageBoxWindow mess2 = new MessageBoxWindow(); mess2.Tag = "Tài khoản đã tồn tại!"; mess2.ShowDialog(); //MessageBox.Show("Tài khoản đã tồn tại!", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (Password != Password2) { MessageBoxWindow mess2 = new MessageBoxWindow(); mess2.Tag = "Nhập lại mật khẩu không khớp với mật khẩu đã nhập!"; mess2.ShowDialog(); //MessageBox.Show("Nhập lại mật khẩu không khớp với mật khẩu đã nhập!", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); } else { DataProvider.Ins.DB.TAIKHOANs.Add(account); DataProvider.Ins.DB.SaveChanges(); ListAccount.Add(account); } } } }); DeleteCommand = new RelayCommand <Button>((p) => { return(true); }, (p) => { var account = DataProvider.Ins.DB.TAIKHOANs.Where(x => x.TENTK == SelectedAccount.TENTK).SingleOrDefault(); DataProvider.Ins.DB.TAIKHOANs.Remove(account); DataProvider.Ins.DB.SaveChanges(); ListAccount.Remove(SelectedAccount); }); SearchCmd = new RelayCommand <TextBox>((p) => { return(true); }, (p) => { if (p.Text != "") { var newList = new ObservableCollection <TAIKHOAN>(DataProvider.Ins.DB.Database.SqlQuery <TAIKHOAN>("USP_TIMTKTHEOTEN @TEN", new SqlParameter("TEN", p.Text))); ListAccount = newList; } else { var newList = new ObservableCollection <TAIKHOAN>(DataProvider.Ins.DB.TAIKHOANs); ListAccount = newList; } }); PasswordChangedCommand = new RelayCommand <PasswordBox>((p) => { return(true); }, (p) => { Password = p.Password; }); Password2ChangedCommand = new RelayCommand <PasswordBox>((p) => { return(true); }, (p) => { Password2 = p.Password; }); ListAccount = new ObservableCollection <TAIKHOAN>(DataProvider.Ins.DB.TAIKHOANs); ListTypeAccount = new ObservableCollection <TypeAccount>() { new TypeAccount(0), new TypeAccount(1) }; }
//protected System.Web.UI.WebControls.DropDownList listAccount; //protected System.Web.UI.WebControls.Label lblReceiver; //protected System.Web.UI.WebControls.Label lblMReceiver; //protected System.Web.UI.WebControls.DropDownList listDept; private void Page_Load(object sender, System.EventArgs e) { string resulttyep = Request.Params["result"]; string depid = Request.Params["dep"]; if (!Page.IsPostBack) { if (string.IsNullOrEmpty(resulttyep)) { } else { UDS.Components.Staff staff = new UDS.Components.Staff(); switch (resulttyep) { case "staff": ICollection retValue; if (string.IsNullOrEmpty(depid) || "0" == depid) { retValue = staff.GetAllStaffs().ToDataTable(true).DefaultView; } else { retValue = staff.GetStaffByPosition(Int32.Parse(depid)); } IList retList = new ArrayList(); var em = retValue as DataView; foreach (DataRow dr in em.Table.Rows) { ListAccount la = new ListAccount(); la.RealName = dr["RealName"].ToString(); la.StaffName = dr["Staff_Name"].ToString(); retList.Add(la); } var jsonSer = new Newtonsoft.Json.JsonSerializer(); StringWriter sw = new StringWriter(); using (JsonWriter jw = new JsonTextWriter(sw)) { jw.Formatting = Formatting.Indented; jsonSer.Serialize(jw, retList); } Response.ContentType = "text/json"; Response.Write(sw.ToString()); sw.Close(); Response.End(); break; case "position": DataTable ds = staff.GetPositionList(1).ToDataTable(true); List<MaiSystem.Position> retPoss = new List<MaiSystem.Position>(); foreach (DataRow dr in ds.Rows) { MaiSystem.Position p = new MaiSystem.Position(); p.PositionID = dr["Position_ID"].ToString(); p.PositionName = dr["Position_Name"].ToString(); retPoss.Add(p); } MaiSystem.Position fp = new MaiSystem.Position(); fp.PositionName = "��˾���в���"; fp.PositionID = "0"; retPoss.Insert(0, fp); var posSer = new Newtonsoft.Json.JsonSerializer(); StringWriter possw = new StringWriter(); using (JsonWriter jw = new JsonTextWriter(possw)) { jw.Formatting = Formatting.Indented; posSer.Serialize(jw, retPoss); } Response.ContentType = "text/json"; Response.Write(possw.ToString()); possw.Close(); Response.End(); break; } } } }
private async void Submit(string obj) { try { var newemp = new Account() { Address = Address, Avatar = ImgEmp.ConvertToByte(), UserName = UserName, NameLogin = NameLogin, Phone = Phone, DOB = Convert.ToDateTime(DOB), }; if (IsB) { newemp.Sex = true; } if (IsG) { newemp.Sex = false; } if (IsE == true) { newemp.Role = 1; } if (string.IsNullOrEmpty(obj)) { //Create new customer var objresult = await employee_Repo.Add(newemp); if (objresult != null) { dc = new DialogContent() { Content = "Thêm Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); ListAccount.Add(objresult); } else { dc = new DialogContent() { Content = "Thêm Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } } else { //update customer newemp.EmpID = Convert.ToInt32(obj); if (await employee_Repo.Update(newemp)) { dc = new DialogContent() { Content = "Cập Nhật Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); ListAccount = new ObservableCollection <Account>(await employee_Repo.GetAllAsync()); } else { dc = new DialogContent() { Content = "Cập Nhật Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } } } catch { dc.Content = "Có Lỗi"; dc.Tilte = "Thông Báo"; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } }
//protected System.Web.UI.WebControls.DropDownList listAccount; //protected System.Web.UI.WebControls.Label lblReceiver; //protected System.Web.UI.WebControls.Label lblMReceiver; //protected System.Web.UI.WebControls.DropDownList listDept; private void Page_Load(object sender, System.EventArgs e) { string resulttyep = Request.Params["result"]; string depid = Request.Params["dep"]; if (!Page.IsPostBack) { if (string.IsNullOrEmpty(resulttyep)) { } else { UDS.Components.Staff staff = new UDS.Components.Staff(); switch (resulttyep) { case "staff": ICollection retValue; if (string.IsNullOrEmpty(depid) || "0" == depid) { retValue = staff.GetAllStaffs().ToDataTable(true).DefaultView; } else { retValue = staff.GetStaffByPosition(Int32.Parse(depid)); } IList retList = new ArrayList(); var em = retValue as DataView; foreach (DataRow dr in em.Table.Rows) { ListAccount la = new ListAccount(); la.RealName = dr["RealName"].ToString(); la.StaffName = dr["Staff_Name"].ToString(); retList.Add(la); } var jsonSer = new Newtonsoft.Json.JsonSerializer(); StringWriter sw = new StringWriter(); using (JsonWriter jw = new JsonTextWriter(sw)) { jw.Formatting = Formatting.Indented; jsonSer.Serialize(jw, retList); } Response.ContentType = "text/json"; Response.Write(sw.ToString()); sw.Close(); Response.End(); break; case "position": DataTable ds = staff.GetPositionList(1).ToDataTable(true); List <MaiSystem.Position> retPoss = new List <MaiSystem.Position>(); foreach (DataRow dr in ds.Rows) { MaiSystem.Position p = new MaiSystem.Position(); p.PositionID = dr["Position_ID"].ToString(); p.PositionName = dr["Position_Name"].ToString(); retPoss.Add(p); } MaiSystem.Position fp = new MaiSystem.Position(); fp.PositionName = "公司所有部门"; fp.PositionID = "0"; retPoss.Insert(0, fp); var posSer = new Newtonsoft.Json.JsonSerializer(); StringWriter possw = new StringWriter(); using (JsonWriter jw = new JsonTextWriter(possw)) { jw.Formatting = Formatting.Indented; posSer.Serialize(jw, retPoss); } Response.ContentType = "text/json"; Response.Write(possw.ToString()); possw.Close(); Response.End(); break; } } } }