public static void DeleteAccount(MetroFramework.Controls.MetroTile tile) { if (tile == null) { return; } for (int index = 0; index < List_PlasticCards.Count; index++) { if (List_PlasticCards[index].Name == tile.Text) { List_PlasticCards.RemoveAt(index); for (int XmlChildIndex = 0; XmlChildIndex < XmlAccountsDocument.DocumentElement.ChildNodes.Count; XmlChildIndex++) { if (XmlAccountsDocument.DocumentElement.ChildNodes[XmlChildIndex].Attributes["type"].Value == "PlasticCard" && XmlAccountsDocument.DocumentElement.ChildNodes[XmlChildIndex].ChildNodes[0].InnerText == tile.Text) { XmlAccountsDocument.DocumentElement.RemoveChild(XmlAccountsDocument.DocumentElement.ChildNodes[XmlChildIndex]); break; } } break; } } TileManager.PlasticCardsTab.DeleteTile(tile); }
public static void AddPlasticCard(string name, string BankAccount, string CardHolder, string CardNumber, string Date, CurrencyType currency, decimal Amount) { PlasticCard newPlasticCard = new PlasticCard() { Name = name, BankAccount = BankAccount, CardHolder = CardHolder, CardNumber = CardNumber, Date = Date, Currency = currency, AccountAmount = Amount }; { //Добавление в XML файл XmlElement xmlAccount = XmlAccountsDocument.CreateElement("account"); XmlAttribute attributeType = XmlAccountsDocument.CreateAttribute("type"); attributeType.Value = "PlasticCard"; xmlAccount.Attributes.Append(attributeType); XmlElement XmlName = XmlAccountsDocument.CreateElement("name"); XmlName.InnerText = newPlasticCard.Name; XmlElement XmlBankAccount = XmlAccountsDocument.CreateElement("BankAccount"); XmlBankAccount.InnerText = newPlasticCard.BankAccount; XmlElement XmlCardHolder = XmlAccountsDocument.CreateElement("CardHolder"); XmlCardHolder.InnerText = newPlasticCard.CardHolder; XmlElement XmlCardNumber = XmlAccountsDocument.CreateElement("CardNumber"); XmlCardNumber.InnerText = newPlasticCard.CardNumber; XmlElement XmlDate = XmlAccountsDocument.CreateElement("date"); XmlDate.InnerText = newPlasticCard.Date; XmlElement XmlCurrency = XmlAccountsDocument.CreateElement("currency"); XmlCurrency.InnerText = newPlasticCard.Currency.ToString(); XmlElement XmlAmount = XmlAccountsDocument.CreateElement("Amount"); XmlAmount.InnerText = newPlasticCard.AccountAmount.ToString(); xmlAccount.AppendChild(XmlName); xmlAccount.AppendChild(XmlBankAccount); xmlAccount.AppendChild(XmlCardHolder); xmlAccount.AppendChild(XmlCardNumber); xmlAccount.AppendChild(XmlDate); xmlAccount.AppendChild(XmlCurrency); xmlAccount.AppendChild(XmlAmount); XmlAccountsDocument.DocumentElement.AppendChild(xmlAccount); //Добавление ссылки на представление карты в XML в структуру newPlasticCard.PlasticCardInXml = xmlAccount; } List_PlasticCards.Add(newPlasticCard); }