/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgIncomeCustomer_InitializingNewItem(object sender, InitializingNewItemEventArgs e) { FinancialIncome obj = e.NewItem as FinancialIncome; if (obj != null) { NewFinancialIncomeList.Add(obj); obj.ProductID = SelectedProduct.ProductID; UpdateLabels(); } }
private void Button_Add_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(IncomeName) || Amount <= 0) { MessageBox.Show("Please Enter an Amount & a Name"); } else { Income = new FinancialIncome(Amount); Income.SetName(IncomeName); Income.SetCategory(Category); Income.SetDescription(Description); Income.SetActionDate(Date); User.Calendar.AllFinances[Date].AddNewIncome(Income); this.Close(); } }
/// <summary> /// Delete the selected row /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, RoutedEventArgs e) { var result = MessageBox.Show("Är du säker på att du vill ta bort denna raden helt?" + Environment.NewLine + "Detta går inte att ångra.", "Ta Bort Rad", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { try { FinancialIncome fi = (FinancialIncome)dgIncomeCustomer.SelectedItem; RevenueManagement.Instance.DeleteFinancialIncome(fi); UpdateLabels(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditedCustomerName(object sender, RoutedEventArgs e) { FinancialIncome fi = (FinancialIncome)dgIncomeCustomer.SelectedItem; var autoCompleteBox = sender as AutoCompleteBox; // Check if Name is correct Customer tempCustomer = CustomerManagement.Instance.GetCustomerByName(autoCompleteBox.Text); if (tempCustomer != null) { fi.CustomerName = tempCustomer.CustomerName; fi.CustomerID = tempCustomer.CustomerID; DataGridCell cellID = GetCell(dgIncomeCustomer.SelectedIndex, 0); //Pass the row and column cellID.IsEnabled = false; DataGridCell cellName = GetCell(dgIncomeCustomer.SelectedIndex, 1); //Pass the row and column cellName.IsEnabled = false; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditedProductName(object sender, RoutedEventArgs e) { FinancialIncome fi = (FinancialIncome)dgIncomeProduct.SelectedItem; var autoCompleteBox = sender as AutoCompleteBox; // Check if Name is correct Product tempProduct = ProductManagement.Instance.GetProductByName(autoCompleteBox.Text); if (tempProduct != null) { fi.ProductName = tempProduct.ProductName; fi.ProductID = tempProduct.ProductID; DataGridCell cellID = GetCell(dgIncomeProduct.SelectedIndex, 0); //Pass the row and column cellID.IsEnabled = false; DataGridCell cellName = GetCell(dgIncomeProduct.SelectedIndex, 1); //Pass the row and column cellName.IsEnabled = false; } }