private void LoadGrid() { databaseEntities db = new databaseEntities(); List <attendance> tableData = db.attendances.ToList(); dataGrid.ItemsSource = tableData; }
private void SaveToDatabase(string name, DateTime now) { databaseEntities db = new databaseEntities(); attendance at = new attendance(); at.studentid = Convert.ToInt32(name); db.attendances.Add(at); at.dateandtime = now; db.attendances.Add(at); db.SaveChanges(); }
private void BtnLogin_Click(object sender, RoutedEventArgs e) { try { databaseEntities db = new databaseEntities(); if (TBx_User.Text != string.Empty || PBx_Password.Password != string.Empty) { int username = Convert.ToInt32(TBx_User.Text); var user = db.logins.FirstOrDefault(a => a.Id.Equals(username)); if (user != null) { if (user.pass.Equals(PBx_Password.Password)) { MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Hide(); } else { LBl_Login_Message.Content = "Login id or password is incorrect"; } } else { LBl_Login_Message.Content = "Login id or password is incorrect"; } } else { LBl_Login_Message.Content = "Enter login id and password"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }