private void Page_Loaded(object sender, RoutedEventArgs e) { using (var db = new BookStoreManagementData.BookStoreContext()) { Categorys.ItemsSource = db.Category.ToList(); } }
private void Delete_Click(int RightID) { db = new BookStoreManagementData.BookStoreContext(); db.Remove(db.Right.ToList().Where(s => s.RightID == RightID).SingleOrDefault()); db.SaveChanges(); RightStaffs.ItemsSource = db.Right.ToList(); }
private void BookTypes_Tapped(object sender, TappedRoutedEventArgs e) { var bookTypeList = new BookStoreManagementData.BookStoreContext().BookType.ToList(); var bookTypeInfor = bookTypeList.ElementAtOrDefault(BookTypes.SelectedIndex); BookTypeName.Text = bookTypeInfor.BookTypeName; Describe.Text = bookTypeInfor.Describe; }
private void Categorys_Tapped(object sender, TappedRoutedEventArgs e) { var CategoryList = new BookStoreManagementData.BookStoreContext().Category.ToList(); var CategoryInfor = CategoryList.ElementAtOrDefault(Categorys.SelectedIndex); CategoryName.Text = CategoryInfor.CategoryName; Describe.Text = CategoryInfor.Describe; StatusCategory.Text = CategoryInfor.StatusCategory; }
private void Delete_Click(object sender, RoutedEventArgs e) { var db = new BookStoreManagementData.BookStoreContext(); //var CategoryInfor = (db.Category.ToList()).ElementAtOrDefault(); //CategoryInfor.CategoryName = CategoryName.Text; //CategoryInfor.Describe = Describe.Text; //db.SaveChanges(); //Categorys.ItemsSource = db.Category.ToList(); }
private void Edit_Click(object sender, RoutedEventArgs e) { var db = new BookStoreManagementData.BookStoreContext(); var bookTypeInfor = (db.BookType.ToList()).ElementAtOrDefault(BookTypes.SelectedIndex); bookTypeInfor.BookTypeName = BookTypeName.Text; bookTypeInfor.Describe = Describe.Text; db.SaveChanges(); BookTypes.ItemsSource = db.BookType.ToList(); }
private void ComponemtDefault() { db = new BookStoreManagementData.BookStoreContext(); RightStaffs.ItemsSource = db.Right.ToList(); Edit.Visibility = Visibility.Collapsed; RightName.Text = String.Empty; Describe.Text = String.Empty; StatusRight.IsChecked = true; }
private void Edit_Click(object sender, RoutedEventArgs e) { var db = new BookStoreManagementData.BookStoreContext(); var CategoryInfor = (db.Category.ToList()).ElementAtOrDefault(Categorys.SelectedIndex); CategoryInfor.CategoryName = CategoryName.Text; CategoryInfor.Describe = Describe.Text; CategoryInfor.StatusCategory = StatusCategory.Text; db.SaveChanges(); Categorys.ItemsSource = db.Category.ToList(); }
private void Edit_Click(object sender, RoutedEventArgs e) { db = new BookStoreManagementData.BookStoreContext(); var RightInfor = (db.Right.ToList()).ElementAtOrDefault(RightStaffs.SelectedIndex); RightInfor.RightName = RightName.Text; RightInfor.Describe = Describe.Text; RightInfor.Status = StatusRight.IsChecked.Value; db.SaveChanges(); ComponemtDefault(); }
private void Add_Click(object sender, RoutedEventArgs e) { using (var db = new BookStoreManagementData.BookStoreContext()) { BookStoreManagementData.Models.CustomModels.Category Category = new BookStoreManagementData.Models.CustomModels.Category { CategoryName = CategoryName.Text, Describe = Describe.Text, StatusCategory = StatusCategory.Text }; db.Category.Add(Category); db.SaveChanges(); Categorys.ItemsSource = db.Category.ToList(); } }
private void Add_Click(object sender, RoutedEventArgs e) { db = new BookStoreManagementData.BookStoreContext(); var RightStaff = new BookStoreManagementData.Models.CustomModels.Right { RightName = RightName.Text, Describe = Describe.Text, Status = StatusRight.IsChecked.Value }; db.Right.Add(RightStaff); db.SaveChanges(); ComponemtDefault(); }
private void Add_Click(object sender, RoutedEventArgs e) { using (var db = new BookStoreManagementData.BookStoreContext()) { BookStoreManagementData.Models.CustomModels.BookType bookType = new BookStoreManagementData.Models.CustomModels.BookType { BookTypeName = BookTypeName.Text, Describe = Describe.Text }; db.BookType.Add(bookType); db.SaveChanges(); List <BookStoreManagementData.Models.CustomModels.BookType> ls = db.BookType.ToList(); BookStoreManagementData.Models.CustomModels.BookType v = new BookStoreManagementData.Models.CustomModels.BookType(); v = ls.Last(); //BookTypes.Items.Add(v); //NTT-TODO Tai sao khong the them mot phan tu BookTypes.ItemsSource = db.BookType.ToList(); } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; bool bExistDatabase = false; using (var db = new BookStoreManagementData.BookStoreContext()) { if ((db.GetService <Microsoft.EntityFrameworkCore.Storage.IDatabaseCreator>() as Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator).Exists()) { bExistDatabase = true; } db.Database.Migrate(); if (!bExistDatabase) { Initializer.insertData(); } } }
private void RightStaffs_Tapped(object sender, TappedRoutedEventArgs e) { var RightList = new BookStoreManagementData.BookStoreContext().Right.ToList(); try { var RightStaffInfor = RightList.ElementAtOrDefault(RightStaffs.SelectedIndex); RightName.Text = RightStaffInfor.RightName; Describe.Text = RightStaffInfor.Describe; if (RightStaffInfor.Status) { StatusRight.IsChecked = true; } else { StatusRight.IsChecked = false; } } catch (Exception) {} Edit.Visibility = Visibility.Visible; }