private void AddNew() { if (User.Current != null) { Account account = new Account(); bool check = account.CheckExists(tbxName.Text); string message = Language.Resource.Message; if (check) { MessageBox.Show(Language.Resource.NameExists, message); } else { account.Name = tbxName.Text; account.Username = tbxUsername.Text; account.Password = tbxPassword.Text; account.Description = tbxDescription.Text; int result = account.Add(); if (result == 1) { frmManager manager = (frmManager)Application.OpenForms["frmManager"]; manager.SelectTab("tabAccounts"); this.Close(); } } } }
public void DeleteAccount(string name) { Account account = new Account(); account.Name = name; bool result = account.Delete(); if (result) { LoadAccount(); } }
public frmAccountUpdate(string name) { _IsAdd = false; _name = name; InitializeComponent(); if (User.Current != null) { Account account = new Account(); var acc = account.GetBy(name); if (acc != null) { tbxName.Text = acc.Name; tbxUsername.Text = acc.Username; tbxPassword.Text = acc.Password; tbxDescription.Text = acc.Description; } } }
public void UpdateAccount(string name) { if (User.Current != null) { Account account = new Account(); var currentAccount = account.GetBy(name); if (currentAccount != null) { account.Name = tbxName.Text; account.Username = tbxUsername.Text; account.Password = tbxPassword.Text; account.Description = tbxDescription.Text; int result = account.Update(); if (result == 1) { frmManager manager = (frmManager)Application.OpenForms["frmManager"]; manager.SelectTab("tabAccounts"); this.Close(); } } } }
public string GetAccountBy(string name) { string result = ""; if (User.Current != null) { Account account = new Account(); result = account.GetByJSON(name); } return result; }
public string GetAccount(string name) { string result = ""; Account account = new Account(); result = account.GetByJSON(name); return result; }
public string GetByJSON(string name) { string result = ""; Account account = new Account(); if (User.Current != null) { Security security = new Security(); XmlDocument accounts = security.ReadAccountConfiguration(User.Current.Path); XmlNode node = accounts.SelectSingleNode("/root/accounts/account[name='" + name + "']"); if (node != null) { account.Name = node.SelectSingleNode("name").InnerText; account.Username = node.SelectSingleNode("username").InnerText; account.Password = node.SelectSingleNode("password").InnerText; account.Description = node.SelectSingleNode("description").InnerText; result = new JavaScriptSerializer().Serialize(account); } } return result; }
public Account GetBy(string name) { Account account = new Account(); if (User.Current != null) { Security security = new Security(); XmlDocument accounts = security.ReadAccountConfiguration(User.Current.Path); XmlNode node = accounts.SelectSingleNode("/root/accounts/account[name='" + name + "']"); if (node != null) { account.Name = node.SelectSingleNode("name").InnerText; account.Username = node.SelectSingleNode("username").InnerText; account.Password = node.SelectSingleNode("password").InnerText; account.Description = node.SelectSingleNode("description").InnerText; } } return account; }
public string GetAllJSON() { string result = ""; List<Account> lstAccount = new List<Account>(); if (User.Current != null) { ThangDC.Core.Securities.Security security = new ThangDC.Core.Securities.Security(); System.Xml.XmlDocument accounts = security.ReadAccountConfiguration(User.Current.Path); foreach (System.Xml.XmlNode node in accounts.SelectNodes("root/accounts/account")) { Account account = new Account(); account.Name = node.SelectSingleNode("name").InnerText; account.Username = node.SelectSingleNode("username").InnerText; account.Password = node.SelectSingleNode("password").InnerText; account.Description = node.SelectSingleNode("description").InnerText; lstAccount.Add(account); } result = new JavaScriptSerializer().Serialize(lstAccount); } return result; }
private void LoadAccount() { Account account = new Account(); List<Account> lstAccount = new List<Account>(); lstAccount = account.GetAll(); lvAccounts.Items.Clear(); Security security = new Security(); foreach (Account acc in lstAccount) { ListViewItem item = new ListViewItem(new[] { acc.Name, acc.Username, security.encrypt(User.Current.PublicKey, acc.Password), acc.Description }); lvAccounts.Items.Add(item); } }