private void button1_Click(object sender, EventArgs e) { Kolcsonzott newdata = new Kolcsonzott(); newdata.ember = emberek[comboBox1.SelectedIndex]; newdata.konyv = konyvek[comboBox2.SelectedIndex]; newdata.kikolcsonzesIdeje = DateTime.Today; newdata.lejarat = monthCalendar1.SelectionStart; kikolcsonzesek.Add(newdata); }
public void loadDB() { string pathToBookDB = "..\\..\\bookdb.txt"; string pathToPersonDB = "..\\..\\persondb.txt"; string pathToKolcsonzesekDB = "..\\..\\kolcsonzesekdb.txt"; PersonDB = new FileStream(pathToPersonDB, FileMode.OpenOrCreate); BookDB = new FileStream(pathToBookDB, FileMode.OpenOrCreate); BorrowDB = new FileStream(pathToKolcsonzesekDB, FileMode.OpenOrCreate); //load persons PersonDB.Position = 0; StreamReader read = new StreamReader(PersonDB); string sor; while ((sor = read.ReadLine()) != null) { Person input = new Person(); string[] data = sor.Split('\t'); input.keresztNev = data[0]; input.vezetekNev = data[1]; input.levelezesiCim = data[2]; input.telefonszam = data[3]; input.tartozas = Convert.ToDouble(data[4].Remove(data[4].Length - 1)); input.ID = Convert.ToInt32(data[5]); emberek.Add(input); } BookDB.Position = 0; read = new StreamReader(BookDB); while ((sor = read.ReadLine()) != null) { Book input = new Book(); string[] data = sor.Split('\t'); input.Name = data[0]; input.Szerzo = data[1]; input.KiadasiEv = data[2]; input.leltariSzam = data[3].Remove(data[3].Length - 1); input.ID = Convert.ToInt32(data[4]); konyvek.Add(input); } BorrowDB.Position = 0; read = new StreamReader(BorrowDB); while ((sor = read.ReadLine()) != null) { Kolcsonzott input = new Kolcsonzott(); string[] data = sor.Split('\t'); int emberid = Convert.ToInt32(data[0]); int konyvid = Convert.ToInt32(data[1]); for (int i = 0; i < emberek.Count; ++i) { if (emberek[i].ID == emberid) { input.ember = emberek[i]; break; } } for (int i = 0; i < konyvek.Count; ++i) { if (konyvek[i].ID == konyvid) { input.konyv = konyvek[i]; break; } } input.kikolcsonzesIdeje = DateTime.Parse(data[2]); input.lejarat = DateTime.Parse(data[3]); } }