Пример #1
0
        private void removeBanch_Click(object sender, RoutedEventArgs e)
        {
            BranchClass brancheselect = new BranchClass();

            brancheselect = branch.SelectedItem as BranchClass;


            var query =
                (from branch in context3.branches
                 where branch.Name == brancheselect.Name
                 select branch).FirstOrDefault();


            branch branchesupdated = context3.branches.Where(em => em.Name == query.Name).FirstOrDefault();

            context3.branches.Remove(branchesupdated);
            context3.SaveChanges();
        }
Пример #2
0
        private void AddBranch_Click(object sender, RoutedEventArgs e)
        {
            BranchClass newBracnh = new BranchClass();

            newBracnh.Name = BranchLocation_textbox.Text.ToString();
            newBracnh.Year = branchdate.DisplayDate;
            var counter = 1;
            var BranchAddedToDataBase = new branch
            {
                BranchId = (++counter),
                Name     = newBracnh.Name,
                Year     = newBracnh.Year,
            };

            context3.branches.Add(BranchAddedToDataBase);
            context3.SaveChanges();
            branch.Items.Add(BranchAddedToDataBase);
        }
Пример #3
0
        private void updateBranch_Click(object sender, RoutedEventArgs e)
        {
            BranchClass branchselect = new BranchClass();

            branchselect = branch.SelectedItem as BranchClass;


            var query =
                (from branch in context3.branches
                 where branch.Name == branchselect.Name
                 select branch).FirstOrDefault();


            branch branchesupdated = context3.branches.Where(em => em.Name == query.Name).FirstOrDefault();

            branchesupdated.Name = (BranchLocation_textbox.Text.ToString());
            branchesupdated.Year = DateTime.Now;
            context3.SaveChanges();
        }
        private void removeBanch_Click(object sender, RoutedEventArgs e)
        {
            try {
                BranchClass brancheselect = new BranchClass();
                brancheselect = branch.SelectedItem as BranchClass;


                var query =
                    (from branch in context3.branches
                     where branch.Name == brancheselect.Name
                     select branch).FirstOrDefault();


                branch branchesupdated = context3.branches.Where(em => em.Name == query.Name).FirstOrDefault();
                context3.branches.Remove(branchesupdated);
                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;
        }