private void Add_Click(object sender, RoutedEventArgs e) { Visibility = Visibility.Collapsed; AddClient DI = new AddClient(card); if (DI.ShowDialog() == true) { if (DI.DialogResult == true) { card = DI.tmp; try { sqb = new SqlCommandBuilder(sca); sca.Update(card); Sale.Text = card.Rows[card.Rows.Count - 1][4].ToString(); } catch (SqlException ex) { MessageBox.Show(ex.Message.ToString()); } } } Visibility = Visibility.Visible; }
private void Check_Click(object sender, RoutedEventArgs e) { if (result == 0) { return; } if (Sale.Text == "") { Visibility = Visibility.Collapsed; AddClient DI = new AddClient(card); if (DI.ShowDialog() == true) { if (DI.DialogResult == true) { card = DI.tmp; try { sqb = new SqlCommandBuilder(sca); sca.Update(card); Sale.Text = card.Rows[card.Rows.Count - 1][4].ToString(); } catch (SqlException ex) { MessageBox.Show(ex.Message.ToString()); } } } } else { for (int i = 0; i < card.Rows.Count; i++) { if (Sale.Text == card.Rows[i][4].ToString()) { DataTable tmp1 = new DataTable(); tmp1 = card; tmp1.Rows[i][3] = Convert.ToDouble(tmp1.Rows[i][3]) + (result / 50); card = tmp1; try { sqb = new SqlCommandBuilder(sca); sca.Update(card); ID.SelectedIndex = -1; Check.Items.Clear(); Num.Value = 1; result = 0; Sale.Text = ""; Result.Text = "TOTAL: " + result.ToString() + " grn"; } catch (SqlException ex) { MessageBox.Show(ex.Message.ToString()); } break; } } } Visibility = Visibility.Visible; }