private void btnEdit_Click(object sender, RoutedEventArgs e) { InventoryImportObject row = (InventoryImportObject)dataGridImport.SelectedItem; DateTime importDate = DateTime.ParseExact(row.InventoryDate, "dd/MM/yyyy", null); BUS_Parameter busParameter = new BUS_Parameter(); int limitDay = busParameter.GetValue("DayDeleteImport"); if ((DateTime.Now - importDate) > TimeSpan.FromDays(limitDay)) { MessageBox.Show($"Không thể chỉnh sửa phiếu đã được tạo cách đây hơn {limitDay} ngày."); return; } if (row == null) { return; } var screen = new InventoryImportEDIT(row.ID, row.EmployName, row.InventoryDate, _context); if (screen != null) { this._context.StackPanelMain.Children.Clear(); this._context.StackPanelMain.Children.Add(screen); } }
private void btnWatch_Click(object sender, RoutedEventArgs e) { InventoryImportObject row = (InventoryImportObject)dataGridImport.SelectedItem; if (row != null) { System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect(); ((MainWindow)App.Current.MainWindow).Opacity = 0.5; ((MainWindow)App.Current.MainWindow).Effect = objBlur; Window window = new Window { ResizeMode = ResizeMode.NoResize, WindowStyle = WindowStyle.None, Title = "Chi tiết phiếu nhập", Height = 600, Width = 500, Content = new PopupInventoryImportDETAIL(row.ID, row.EmployName, row.InventoryDate), WindowStartupLocation = WindowStartupLocation.CenterScreen //Content = new PopupInventoryImportDETAIL("a","a","a") }; window.ShowDialog(); ((MainWindow)App.Current.MainWindow).Opacity = 1; ((MainWindow)App.Current.MainWindow).Effect = null; } }
/* * About how to check if the amount in the importDetail > the amount in stock * Step 1: Load Name & Amount have in stock into a Map (Stock Map) * Step 2: Load all name& Amount of the import Want-to-remove into a Map (Import Map) * Step 3: foreach element in Stock Map , we will comparision if Import > Stock * if(Import > Stock) it means the material have been used -> so we cant delete this import */ private void btnDelete_Click(object sender, RoutedEventArgs e) { InventoryImportObject row = (InventoryImportObject)dataGridImport.SelectedItem; DateTime importDate = DateTime.ParseExact(row.InventoryDate, "dd/MM/yyyy", null); BUS_Parameter busParameter = new BUS_Parameter(); int limitDay = busParameter.GetValue("DayDeleteImport"); if ((DateTime.Now - importDate) > TimeSpan.FromDays(limitDay)) { MessageBox.Show($"Không thể xóa do phiếu đã được tạo cách đây hơn {limitDay} ngày."); return; } if (!checkDeleteCondition(row.ID)) { MessageBox.Show("Không thể xóa phiếu do nguyên vật liệu, thiết bị trong phiếu đã được xuất khỏi kho."); return; } System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect(); ((MainWindow)App.Current.MainWindow).Opacity = 0.5; ((MainWindow)App.Current.MainWindow).Effect = objBlur; Window window = new Window { ResizeMode = ResizeMode.NoResize, WindowStyle = WindowStyle.None, Title = "xóa phiếu nhập kho! ", Content = new PopupDeleteConfirm(this, row.ID), //delete message Width = 420, Height = 210, WindowStartupLocation = WindowStartupLocation.CenterScreen }; window.ShowDialog(); this.tbNumPage.Text = "1"; this.btBack.IsEnabled = false; if ((int)lblMaxPage.Content == 1) { this.btNext.IsEnabled = false; } else { this.btNext.IsEnabled = true; } ((MainWindow)App.Current.MainWindow).Opacity = 1; ((MainWindow)App.Current.MainWindow).Effect = null; }