private void CheckBoxCongViec_Check(object sender, RoutedEventArgs e) { CheckBox chkBox = sender as CheckBox; CongViecView cvv = (CongViecView)chkBox.DataContext; using (QuanLyDuLieu db = new QuanLyDuLieu()) { CongViec cvThayDoi = db.CongViec.ToList().Single(m => m.CongViecID == cvv.CongViecID); cvThayDoi.PhanLoaiCongViec = chkBox.IsChecked == null ? cvThayDoi.PhanLoaiCongViec : ((bool)chkBox.IsChecked ? "DaHoanThanh" : "DangThucHien"); db.SaveChanges(); } LoadCongViec(); }
private void LoadCongViec() { using (QuanLyDuLieu db = new QuanLyDuLieu()) { List <CongViec> cv = db.CongViec.ToList().FindAll(m => m.NguoiDungID == NguoiDungING.NguoiDungID); List <CongViecView> cvv = new List <CongViecView>(); foreach (CongViec i in cv) { CongViecView v = new CongViecView(i); cvv.Add(v); } ; lvCongViec.ItemsSource = cvv; } }
private void lvCongViec_MouseDoubleClick(object sender, MouseButtonEventArgs e) { CongViecView cvv = (CongViecView)lvCongViec.SelectedItem; if (cvv != null) { using (QuanLyDuLieu db = new QuanLyDuLieu()) { CongViec cv = db.CongViec.ToList().Find(m => m.CongViecID == cvv.CongViecID); ThaoTacCongViec ttcv = new ThaoTacCongViec(cv); ttcv.ShowDialog(); LoadCongViec(); } } }