private void bntEdit_Click(object sender, RoutedEventArgs e) { int index; StockInDetails r = new StockInDetails(); DependencyObject dep = (DependencyObject)e.OriginalSource; while ((dep != null) && !(dep is ListViewItem)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) { return; } index = lvDataStockIn.ItemContainerGenerator.IndexFromContainer(dep); InputNote inputNote = new InputNote(_stockInDetailsList[index].Note); if ((_stockInDetailsList[index].Note == null || _stockInDetailsList[index].Note.Equals("") || _stockInDetailsList[index].Note.Equals(inputNote.Note))) { if (inputNote.ShowDialog() == true) { r.Note = inputNote.Note; r.Sto_id = _stockInDetailsList[index].Sto_id; r.Quan = _stockInDetailsList[index].Quan; r.ItemPrice = _stockInDetailsList[index].ItemPrice; _stockInDetailsList[index] = r; } } else { inputNote.ShowDialog(); } lvDataStockIn.Items.Refresh(); }
/********************************* * Manipulate Each Stock *********************************/ private void lvDataStock_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { Stock stock = (Stock)lvDataStock.SelectedItem; if (stock == null) { return; } StockInDetails r = new StockInDetails(); var foundIteminReceipt = _stockInDetailsList.FirstOrDefault(c => c.Sto_id.Equals(stock.StoId)); if (foundIteminReceipt == null) { r.Sto_id = stock.StoId; r.Quan = 1; r.ItemPrice = stock.StandardPrice; _stockInDetailsList.Add(r); } else { foundIteminReceipt.Quan++; } lvDataStockIn.Items.Refresh(); LoadStockInData(); }
/********************************* * Manipulate Each StockInDetails *********************************/ private void txtQuan_TextChanged(object sender, TextChangedEventArgs e) { TextBox textboxQuan = sender as TextBox; int index; StockInDetails r = new StockInDetails(); DependencyObject dep = (DependencyObject)e.OriginalSource; while ((dep != null) && !(dep is ListViewItem)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) { return; } index = lvDataStockIn.ItemContainerGenerator.IndexFromContainer(dep); try { if (textboxQuan.Text == null || textboxQuan.Text.Length == 0) { MessageBox.Show("The quantity of Input Stock can not be blank!"); if (!ErrorDetailsItem.Contains(index)) { ErrorDetailsItem.Add(index); } return; } _stockInDetailsList[index].Quan = int.Parse(textboxQuan.Text); LoadStockInData(); if (ErrorDetailsItem.Contains(index)) { ErrorDetailsItem.Remove(index); } } catch (Exception ex) { MessageBox.Show("Something went wrong when try to calculate the input data. Please check your input"); if (!ErrorDetailsItem.Contains(index)) { ErrorDetailsItem.Add(index); } } }
private void bntDelete_Click(object sender, RoutedEventArgs e) { int index; StockInDetails r = new StockInDetails(); DependencyObject dep = (DependencyObject)e.OriginalSource; while ((dep != null) && !(dep is ListViewItem)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) { return; } index = lvDataStockIn.ItemContainerGenerator.IndexFromContainer(dep); if (_stockInDetailsList[index].Quan > 1 && !ErrorDetailsItem.Contains(index)) { r.Quan = _stockInDetailsList[index].Quan - 1; r.Sto_id = _stockInDetailsList[index].Sto_id; r.ItemPrice = _stockInDetailsList[index].ItemPrice; _stockInDetailsList[index] = r; } else { _stockInDetailsList.RemoveAt(index); if (ErrorDetailsItem.Contains(index)) { ErrorDetailsItem.Remove(index); } } lvDataStockIn.Items.Refresh(); LoadStockInData(); }
private void btnDetails_Click(object sender, EventArgs e) { Form stockInDetail = new StockInDetails(); stockInDetail.ShowDialog(); }