private void intakesViewList_SelectionChanged(object sender, SelectionChangedEventArgs e) { IntakeClass intakeSelected = new IntakeClass(); intakeSelected = intakesViewList.SelectedItem as IntakeClass; Intake_NumberTextBox.Text = intakeSelected.IntakeNumber.ToString(); // intakdate.DisplayDate.Year = intakeSelected.Year; intakdate.Text = intakeSelected.Year.ToString(); }
private void AddIntake_Click(object sender, RoutedEventArgs e) { IntakeClass intakeAdd = new IntakeClass(); intakeAdd.IntakeNumber = int.Parse(Intake_NumberTextBox.Text.ToString()); intakeAdd.Year = intakdate.DisplayDate; //var counter = 1; var IntakeAddedToDataBase = new intake { IntakeNumber = intakeAdd.IntakeNumber, Year = intakdate.DisplayDate, }; context3.intakes.Add(IntakeAddedToDataBase); context3.SaveChanges(); intakesViewList.Items.Add(IntakeAddedToDataBase); }
private void RemoveIntake_Click(object sender, RoutedEventArgs e) { IntakeClass intakeselect = new IntakeClass(); intakeselect = intakesViewList.SelectedItem as IntakeClass; var query = (from intake in context3.intakes where intake.IntakeNumber == intakeselect.IntakeNumber select intake).FirstOrDefault(); intake intakesupdated = context3.intakes.Where(em => em.IntakeNo == query.IntakeNo).FirstOrDefault(); context3.intakes.Remove(intakesupdated); context3.SaveChanges(); }
private void UpdateIntake_Click(object sender, RoutedEventArgs e) { IntakeClass intakeselect = new IntakeClass(); intakeselect = intakesViewList.SelectedItem as IntakeClass; var query = (from intake in context3.intakes where intake.IntakeNumber == intakeselect.IntakeNumber select intake).FirstOrDefault(); intake intakesupdated = context3.intakes.Where(em => em.IntakeNo == query.IntakeNo).FirstOrDefault(); intakesupdated.IntakeNumber = int.Parse(Intake_NumberTextBox.Text.ToString()); intakesupdated.Year = DateTime.Now; context3.SaveChanges(); }
private void RemoveIntake_Click(object sender, RoutedEventArgs e) { try { IntakeClass intakeselect = new IntakeClass(); intakeselect = intakesViewList.SelectedItem as IntakeClass; var query = (from intake in context3.intakes where intake.IntakeNumber == intakeselect.IntakeNumber select intake).FirstOrDefault(); intake intakesupdated = context3.intakes.Where(em => em.IntakeNo == query.IntakeNo).FirstOrDefault(); context3.intakes.Remove(intakesupdated); context3.SaveChanges(); } catch (Exception f) { MessageBox.Show("invalid inputs"); } }
public ManagerDashboard() { InitializeComponent(); var query2 = (from track in context3.tracks select new { TrackId = track.TrackId, Year = track.Year, TrackName = track.TrackName, }).ToList(); var query1 = (from intake in context3.intakes select new { IntakeNo = intake.IntakeNo, IntakeNumber = intake.IntakeNumber, Year = intake.Year }).ToList(); var query3 = (from branches in context3.branches select new { BranchId = branches.BranchId, Name = branches.Name, Year = branches.Year }).ToList(); List <IntakeClass> ListOfIntakeNumber = new List <IntakeClass>(); List <TrackClass> ListOfTrackNumber = new List <TrackClass>(); List <BranchClass> ListOfBranchNumber = new List <BranchClass>(); foreach (var item in query1) { IntakeClass newIntake = new IntakeClass(); newIntake.IntakeNo = item.IntakeNo; newIntake.IntakeNumber = item.IntakeNumber; newIntake.Year = item.Year; ListOfIntakeNumber.Add(newIntake); } foreach (var item in ListOfIntakeNumber) { intakesViewList.Items.Add(item); } foreach (var item in query2) { TrackClass newTrack = new TrackClass(); newTrack.TrackId = item.TrackId; newTrack.TrackName = item.TrackName; newTrack.Year = item.Year; ListOfTrackNumber.Add(newTrack); } foreach (var item in ListOfTrackNumber) { track.Items.Add(item); } foreach (var item in query3) { BranchClass newBranch = new BranchClass(); newBranch.BranchId = item.BranchId; newBranch.Name = item.Name; newBranch.Year = item.Year; ListOfBranchNumber.Add(newBranch); } foreach (var item in ListOfBranchNumber) { branch.Items.Add(item); } //intakes.ItemsSource = query1; //branch.ItemsSource = getAllBranches(); //track.ItemsSource = query2; }