private void PokazWszystko_Click(object sender, RoutedEventArgs e) { var con = new KolDb(); var emp = con .EMPs .Include(d => d.DEPT) .Select(o => new { o.ENAME, o.JOB, o.DEPT.DNAME }).ToList(); DataGrid.ItemsSource = emp; }
private void Odswiez() { var con = new KolDb(); var emp = con .EMPs .Include(d => d.DEPT) .Select(o => new { o.ENAME, o.JOB, o.DEPT.DNAME }).ToList(); DataGrid.ItemsSource = emp; }
private void Szukaj_Click(object sender, RoutedEventArgs e) { Szukaj.Text.ToString(); var con = new KolDb(); var emp = con .EMPs .Include(d => d.DEPT) .Where(d => d.ENAME == Szukaj.Text.ToString()) .Select(o => new { o.ENAME, o.JOB, o.DEPT.DNAME }).ToList(); DataGrid.ItemsSource = emp; }
public MainWindow() { InitializeComponent(); var con = new KolDb(); var emp = con .EMPs .Include(d => d.DEPT) .Select(o => new { o.ENAME, o.JOB, o.DEPT.DNAME }).ToList(); DataGrid.ItemsSource = emp; var deptname = con.DEPTs.ToList(); Ddname.ItemsSource = deptname.Select(x => x.DNAME); }
private void Dodaj_Click(object sender, RoutedEventArgs e) { var con = new KolDb(); var max = con.EMPs.Max(d => d.EMPNO); var deptno = con.DEPTs .Where(x => x.DNAME == Ddname.SelectedItem.ToString()) .Select(x => x.DEPTNO).First(); EMP tempemp = new EMP() { EMPNO = max + 1, ENAME = Eename.Text, JOB = Jjob.Text, DEPTNO = deptno, }; con.EMPs.Add(tempemp); con.SaveChanges(); Odswiez(); }