private void Update(object sender, RoutedEventArgs e) { if (Txtname.Text != "" && Txtamout.Text != "" && Txtcost.Text != "") { var product = new Product { Id = temp.Id, Name = Txtname.Text, Cost = double.Parse(Txtcost.Text), Amount = int.Parse(Txtamout.Text), IdType = _database.GetIdType(Cbidloai.SelectedItem.ToString()) }; if (check == 0) { product.Path = temp.Path; } else { product.Path = stringNewPath; if (AppHelper.CheckExistFile(stringNewPath)) { AppHelper.DeleteFile(stringNewPath); } AppHelper.CopyFile(Curpath, stringNewPath); } _data = product; Close(); } else { MessageBox.Show("Không được để trống ô!!", "Thông báo!!!"); } }
private void Add_Product(object sender, RoutedEventArgs e) { if (check != 0 && Txtname.Text != "" && Txtamout.Text != "" && Txtcost.Text != "") { var product = new Product { Name = Txtname.Text, Cost = double.Parse(Txtcost.Text), Amount = int.Parse(Txtamout.Text), IdType = _database.GetIdType(Cbtypename.SelectedItem.ToString()), Path = stringNewPath }; _database.InsertProduct(product); if (AppHelper.CheckExistFile(product.Path)) { AppHelper.DeleteFile(product.Path); } AppHelper.CopyFile(stringOldPath, product.Path); Close(); } else { MessageBox.Show("Not allow empty !!!!", "Warning!!!!"); } }