private void SubmitPaymentButton_Click(object sender, RoutedEventArgs e)
        {
            string connectionString;

            connectionString =
                "Data Source=(local);Initial Catalog=ML635064021;"
                + "Integrated Security=true";
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    payments   = connection.CreateCommand();

            payments.CommandText = "INSERT INTO PAYMENTS (Lease_Terms_ID, Date, Amount)" +
                                   " VALUES (@LeaseId, @DateEntry, @AmountEntry)";
            payments.Parameters.AddWithValue("@LeaseId", LeaseIDBox.Text);
            payments.Parameters.AddWithValue("@DateEntry", DateBox.Text);
            payments.Parameters.AddWithValue("@AmountEntry", AmountBox.Text);
            try
            {
                connection.Open();
                payments.ExecuteNonQuery();
                MessageBox.Show("Payment Successfuly Added!");
            }
            catch
            {
                MessageBox.Show("Something went wrong!");
            }
            finally
            {
                connection.Close();

                DateBox.Clear();
                AmountBox.Clear();
                LeaseIDBox.Clear();
            }
        }
Example #2
0
 private void InitialiseTextBoxes()
 {
     DateBox.Clear();
     DateBox.Enabled = false;
     CostBox.Clear();
     CostBox.Enabled = false;
     NameBox.Clear();
     NameBox.Enabled = false;
 }
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            string ItemName   = ItemBox.Text;
            string DateOfSale = DateBox.Text;
            string Country    = CountryBox.Text;
            string Currency   = CurrencyBox.Text;

            if (!float.TryParse(PriceBox.Text, out float NetPrice) & float.TryParse(VATbox.Text, out float VAT))
            {
                MessageBox.Show("Net Price and VAT fields can only contain numbers!");
            }
            con.InsertSales(ItemName, Country, Currency, DateOfSale, NetPrice, VAT);
            MessageBox.Show("Sale has been added.");
            ItemBox.Clear();
            DateBox.Clear();
            CountryBox.Clear();
            CurrencyBox.Clear();
            PriceBox.Clear();
            VATbox.Clear();
        }