public ProductView() { InitializeComponent(); SqlProductRepository colRecord = new SqlProductRepository(); txtColRecord.Text = Convert.ToString(colRecord.CountRecords()); }
private void btnCopy_Click(object sender, RoutedEventArgs e) { int numRecord = ListRecord.SelectedIndex + 1; if (numRecord == 0) { MessageBox.Show("Виберіть рядок для операції 'По зразку'"); } else { SqlProductRepository idRecord = new SqlProductRepository(); int _idRecord = idRecord.GetId(numRecord); Product product = new Product(); product = idRecord.GetRowById(_idRecord); AddEditRecord addEditRecord = new AddEditRecord(); addEditRecord.NumberOperation = 5; addEditRecord._Id = product.Id; addEditRecord.txtName.Text = product.Name; addEditRecord.txtArticle.Text = product.Article; addEditRecord.txtDescription.Text = product.Description; addEditRecord.Show(); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { int numRecord = ListRecord.SelectedIndex + 1; if (numRecord == 0) { MessageBox.Show("Виберіть рядок для операції 'Видалення'"); } else { SqlProductRepository idRecord = new SqlProductRepository(); int _idRecord = idRecord.GetId(numRecord); Product product = new Product(); product = idRecord.GetRowById(_idRecord); AddEditRecord addEditRecord = new AddEditRecord(); string __name = product.Name; string __article = product.Article; string __description = product.Description; string message = string.Format("Ви дійсно бажаєте видалити запис? \nНазва: {0} \nАртикул: {1} \nОпис: {2}", __name, __article, __description); if (MessageBox.Show(message, "Видалення запису", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { idRecord.DeleteRecord(_idRecord); } } }
private void btnOk_Click(object sender, RoutedEventArgs e) { SqlProductRepository sqlProductRepository = new SqlProductRepository(); if (NumberOperation == 7) { _Name = txtName.Text; _Article = txtArticle.Text; _Description = txtDescription.Text; Product newProduct = new Product(); newProduct.Name = _Name; newProduct.Article = _Article; newProduct.Description = _Description; sqlProductRepository.AddRecord(newProduct); } if (NumberOperation == 4) { Product editProduct = new Product(); _Name = txtName.Text; _Article = txtArticle.Text; _Description = txtDescription.Text; editProduct.Id = _Id; editProduct.Name = _Name; editProduct.Article = _Article; editProduct.Description = _Description; sqlProductRepository.EditRecord(editProduct); } if (NumberOperation == 5) { Product copyProduct = new Product(); _Name = txtName.Text; _Article = txtArticle.Text; _Description = txtDescription.Text; //copyProduct.Id = _Id; copyProduct.Name = _Name; copyProduct.Article = _Article; copyProduct.Description = _Description; sqlProductRepository.AddRecord(copyProduct); } Close(); }
private void btnRefresh_Click(object sender, RoutedEventArgs e) { SqlProductRepository listProduct = new SqlProductRepository(); List<Product> list = new List<Product>(); list = listProduct.SelectAll(); this.ListRecord.ItemsSource = list; txtColRecord.Text = listProduct.CountRecords().ToString(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { IProductRepository productRepository = new SqlProductRepository(); ProductViewModel viewModel = new ProductViewModel(productRepository); this.ucProducts.DataContext = viewModel; }