public void Add(CashCount cashCount) { cashCountCollection.Add(cashCount); }
public void Remove(CashCount cashCount) { cashCountCollection.Remove(cashCount); }
public List <CashCount> GetCashCounts() { List <CashCount> cashCounts = new List <CashCount>(); try { FileStream file = new FileStream(RutaArchivo, FileMode.Open, FileAccess.Read); XmlTextReader reader = new XmlTextReader(file); CashCount cashCount = null; while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "CashCounts": { break; } case "CashCount": { cashCount = new CashCount(); break; } case "User": { cashCount.User = new User(); break; } case "Date": { if (reader.Read()) { cashCount.Date = Convert.ToDateTime(reader.Value); } break; } case "UserName": { if (reader.Read()) { cashCount.User.UserName = reader.Value; } break; } case "Password": { if (reader.Read()) { cashCount.User.Password = reader.Value; } break; } case "LastAccess": { if (reader.Read()) { cashCount.User.LastAcess = Convert.ToDateTime(reader.Value); } break; } case "Question": { if (reader.Read()) { cashCount.User.Question = reader.Value; } break; } case "Answer": { if (reader.Read()) { cashCount.User.Answer = reader.Value; } break; } } } else if (reader.Name == "CashCount") { cashCounts.Add(cashCount); cashCount = null; } } reader.Close(); file.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(cashCounts); }