public string InsertLearner(Person student) { try { digitalContext = new DigitalEntities(); digitalContext.People.Add(student); digitalContext.SaveChanges(); return student.FirstName + "was successfully added"; } catch (Exception ex) { return "Learner not Added" + ex.Message; } }
public string MasterRecord(AttendanceMaster master) { try { digitalContext = new DigitalEntities(); digitalContext.AttendanceMasters.Add(master); digitalContext.SaveChanges(); return "You signed"; } catch (Exception ex) { return "Register was not signed, Please try again" + ex.Message; } }
public void Window_Loaded(object sender, RoutedEventArgs e) { digitalContext = new DigitalEntities(); SignModel sign = new SignModel(); GetMentors(); datePicker.SelectedDate = DateTime.Now; cmbStudent.SelectedIndex = 1; cmbMentorList.SelectedIndex = 1; Username.Text = "Welcome ," + SessionContext.UserName; LoadData(); CustomViewModel model = new CustomViewModel(); DateTime picker = (DateTime)datePicker.SelectedDate; item.DataContext = model.LoadData(); }
public string SignRegister(AttendanceDetail detail) { try { digitalContext = new DigitalEntities(); digitalContext.AttendanceDetails.Add(detail); digitalContext.SaveChanges(); return "You signed"; } catch (Exception ) { return null; } }
public string InsertMentor( Person mentor) { try { digitalContext = new DigitalEntities(); digitalContext.People.Add(mentor); digitalContext.SaveChanges(); return mentor.FirstName + " " + " was successfully added"; } catch (Exception ex) { return "Mentor not added" + ex.Message; } }
public dynamic GetAttendance(DateTime picker) { digitalContext = new DigitalEntities(); var q = from a in digitalContext.AttendanceDetails join b in digitalContext.People on new { a.PersonID } equals new { b.PersonID } join c in digitalContext.AttendanceMasters on new { a.MasterID } equals new { c.MasterID } where c.AttendanceDate == picker select new { Name = b.FirstName, Hours = a.HoursPerDay }; return q; }
public string DeleteLearner(int id) { try { digitalContext = new DigitalEntities(); Person student = digitalContext.People.Find(id); digitalContext.People.Attach(student); digitalContext.People.Remove(student); digitalContext.SaveChanges(); return student.FirstName + "was successfully Deleted"; } catch (Exception ) { return "Learner not deleted" ; } }
public dynamic LoadData() { digitalContext = new DigitalEntities(); List<Person> person = (from x in digitalContext.People select x).ToList(); IList<AttendanceDetail> details = (from x in digitalContext.AttendanceDetails select x).ToList(); var query = person.Join(details, c => c.PersonID, ct => ct.PersonID, (c, ct) => new CustomModel { Name = c.FirstName, Hours = ct.HoursPerDay }); return query; }
private void cmbMentorList_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { int Index = cmbMentorList.SelectedIndex + 1; using (digitalContext = new DigitalEntities()) { List<Person> student = (from x in digitalContext.People where x.RoleID == 1 select x).ToList(); cmbStudent.DataContext = student; Index = cmbMentorList.SelectedIndex + 1; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void GetMentors() { try { using (digitalContext = new DigitalEntities()) { List<Person> person = (from x in digitalContext.People where x.RoleID == 2 select x).ToList(); foreach (var item in person) { cmbMentorList.Items.Add(item.FirstName + " " + item.LastName.Substring(0, 1).ToUpper()); } } } catch (Exception ex) { MessageBox.Show("mentors not found" + ex.Message); } }
private void btn_Click(object sender, RoutedEventArgs e) { using (digitalContext = new DigitalEntities()) { var mentor = (from t in digitalContext.People where String.Compare(t.Username, txtUsername.Text) == 0 && String.Compare(t.Password,txtPassword.Password) == 0 select t).FirstOrDefault(); if (mentor != null && !String.IsNullOrEmpty(mentor.Username)) { SessionContext.UserID = mentor.PersonID; SessionContext.UserRole = Role.Person; SessionContext.UserName = mentor.FirstName; SessionContext.CurrentMentor = mentor; home.Show(); home.btnManage.IsEnabled = false; this.Close(); } else { MessageBox.Show("Invalid Username or Password", "Please Try Again", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e) { listBox1.Items.Clear(); combo.Items.Clear(); DateTime picker = (DateTime)datePicker.SelectedDate; digitalContext = new DigitalEntities(); var q = from a in digitalContext.AttendanceDetails join b in digitalContext.People on new { a.PersonID } equals new { b.PersonID } join c in digitalContext.AttendanceMasters on new { a.MasterID } equals new { c.MasterID } where c.AttendanceDate == picker select new { b.FirstName, a.HoursPerDay }; listBox1.Items.Add("Name" + " "+ " " + "Hours"); foreach (var item in q) { listBox1.Items.Add(item.FirstName +" " + item.HoursPerDay); combo.Items.Add(item.FirstName + " " + item.HoursPerDay); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { using (digitalContext = new DigitalEntities()) { List<UserRole> role = (from x in digitalContext.UserRoles select x).ToList(); foreach (var item in role) { cmbStudentMentor.Items.Add(item.Name); } } } catch (Exception) { throw; } }