public AddDiscount() { InitializeComponent(); DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption); technicComboBox.ItemsSource = dataBase.OutputAllTechnic(); currentDiscountComboBox.ItemsSource = dataBase.OutputAllDiscount(); dataBase.OutputTableDiscount(discountDataGrid); }
private void DeleteDiscountButton_Click(object sender, RoutedEventArgs e) { if (CheckFullProductDelete()) { DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption); dataBase.DeleteDiscount(currentDiscountComboBox.SelectedItem.ToString()); currentDiscountComboBox.SelectedIndex = -1; discountDataGrid.Items.Clear(); currentDiscountComboBox.ItemsSource = null; currentDiscountComboBox.ItemsSource = dataBase.OutputAllDiscount(); dataBase.OutputTableDiscount(discountDataGrid); MessageBox.Show(" Удаление прошло успешно"); } }
private void AddDiscountButton_Click(object sender, RoutedEventArgs e) { if (CheckFullDiscount()) { DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption); if (dataBase.AddDiscount(technicComboBox.SelectedItem.ToString(), discountTextBox.Text)) { Tuple <string, int> tuple = new Tuple <string, int> (technicComboBox.SelectedItem.ToString(), Convert.ToInt32(discountTextBox.Text)); currentDiscountComboBox.SelectedIndex = -1; discountDataGrid.Items.Clear(); currentDiscountComboBox.ItemsSource = null; dataBase.OutputTableDiscount(discountDataGrid); currentDiscountComboBox.ItemsSource = dataBase.OutputAllDiscount(); technicComboBox.SelectedIndex = -1; discountTextBox.Text = ""; } else { bool isMessageResultAgree = MessageBox.Show ("Скидка на этот товар существует. Изменить существующую скидку?", "Изменнение скидки", MessageBoxButton.YesNo) == MessageBoxResult.Yes; if (isMessageResultAgree) { dataBase.UpdateDiscount(technicComboBox.SelectedItem.ToString(), discountTextBox.Text); discountDataGrid.Items.Clear(); dataBase.OutputTableDiscount(discountDataGrid); } technicComboBox.SelectedIndex = -1; discountTextBox.Text = ""; } } }
private void DeleteAllDiscountButton_Click(object sender, RoutedEventArgs e) { bool isMessageResultAgree = MessageBox.Show (" Удалить всё?", "Подтверждение операции", MessageBoxButton.YesNo) == MessageBoxResult.Yes; if (isMessageResultAgree) { DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption); dataBase.DeleteDiscount(); currentDiscountComboBox.SelectedIndex = -1; currentDiscountComboBox.ItemsSource = null; discountDataGrid.Items.Clear(); currentDiscountComboBox.ItemsSource = dataBase.OutputAllDiscount(); dataBase.OutputTableDiscount(discountDataGrid); MessageBox.Show(" Удаление прошло успешно"); } }