public bool isUserInDB(string usn, string pw) { using (e1 = new M120Entities()) { g1 = e1.GUIUSERs.FirstOrDefault(r => r.Gu_Benutzername == usn); g2 = e1.GUIUSERs.FirstOrDefault(p => p.GU_Password == pw); try { if (g1.Gu_Benutzername == usn && g2.GU_Password == pw) { m1 = new Menu2(); m1.Show(); return(true); } else { return(false); } } catch (Exception e) { MessageBox.Show("No User found in Database"); } return(false); } }
public void saveUserToDB(string anrede, string vorname, string name, string namezusatz, string strassennr, short plz, string ort, string telefon, string mobile, string email, string web, DateTime geburtsdatum, string passnr, long nationalität, string usn, string pw) { using (e1 = new M120Entities()) { Kunde k1 = new Kunde { Anrede = anrede, Vorname = vorname, Name = name, NameZusatz = namezusatz, StrasseNr = strassennr, PLZ = plz, Ort = ort, Telefon = telefon, Mobile = mobile, Email = email, Web = web, Geburtsdatum = geburtsdatum, PassNr = passnr, Nationalitaet = nationalität }; GUIUSER g1 = new GUIUSER { Gu_Benutzername = usn, GU_Password = pw, }; m1 = new Menu2(); m1.Show(); e1.GUIUSERs.Add(g1); e1.Kundes.Add(k1); e1.SaveChanges(); } }