private void SkaitytojoLangas_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'libraryDataDataSet.Knygos' table. You can move, or remove it, as needed. //knygosTableAdapter.Fill(libraryDataDataSet.Knygos); using (LibraryDataEntities2 dataEntities = new LibraryDataEntities2()) { Knygo[] knygo = (from c in dataEntities.Knygos where !c.Zmogus.HasValue select c).ToArray(); knygosDataGridView.DataSource = knygo; } using (LibraryDataEntities2 dataEntities = new LibraryDataEntities2()) { Knygo[] knygo = (from c in dataEntities.Knygos from b in dataEntities.Vartotojais where c.Zmogus == b.Id select c).ToArray(); knygosDataGridView1.DataSource = knygo; } }
public static int GetID(string username) { int id; using (LibraryDataEntities2 contex = new LibraryDataEntities2()) { Vartotojai vartotojass = contex.Vartotojais.FirstOrDefault(r => r.Prisijungimo_vardas == username); id = (int)vartotojass.Id; } return(id); }
public void FillData(String username, String password, int vartotojas) { using (LibraryDataEntities2 contex = new LibraryDataEntities2()) { Vartotojai vartotojass = new Vartotojai() { Prisijungimo_vardas = username, Slaptazodis = password, Vartotojas = vartotojas, }; contex.Vartotojais.Add(vartotojass); contex.SaveChanges(); } }
public void delete(KnygosDataSet1 dataSet, int n) { //dataSet.Table.Rows.Remove(dataSet.Table[n]); using (LibraryDataEntities2 dataEntities = new LibraryDataEntities2()) { Knygo knygo = (from c in dataEntities.Knygos where c.Id == n select c).FirstOrDefault(); dataEntities.Knygos.Remove(knygo); dataEntities.SaveChanges(); } }
public bool CheckData(String username, String password, int vartotojas) { bool exists = false; using (LibraryDataEntities2 contex = new LibraryDataEntities2()) { Vartotojai vartotojass = contex.Vartotojais.FirstOrDefault(r => r.Prisijungimo_vardas == username && r.Slaptazodis == password && r.Vartotojas == vartotojas); if (vartotojass != null) { exists = true; } } return(exists); }
public void AddBook(String autorius, String pavadinimas) { using (LibraryDataEntities2 dataEntities = new LibraryDataEntities2()) { List <int> idList = dataEntities.Knygos.Select(x => x.Id).ToList(); Knygo knygo = new Knygo() { Id = idList.Last() + 1, Autorius = autorius, Pavadinimas = pavadinimas }; dataEntities.Knygos.Add(knygo); dataEntities.SaveChanges(); } }