private void btnW_Click(object sender, RoutedEventArgs e) {

            if(isValid()){
                // Instance of transactionmod
                tr = new TransactionMod();

                string t = "w";
                DateTime d = dpDate.Date.DateTime;
                double a = Convert.ToDouble(tbxAmmount.Text);
                int aid = myApp._accountId;

                // setting up fields
                tr.type = t;
                tr.date = d;
                tr.ammount = a;
                tr.accid = aid;
                if (cbCategory.SelectedIndex != -1) {
                    var item = (Categories)cbCategory.SelectedItem;
                    tr.categoryid = item.id;
                }
                if (tbxDescription.Text != null) {
                    tr.description = tbxDescription.Text;
                }

                if (dc.addNewTransaction(tr) == 1) {

                    dpDate.Date = DateTime.Now;
                    tbxAmmount.Text = "";
                    cbCategory.SelectedIndex = -1;
                    tbxDescription.Text = "";

                    Account acc = dc.getAccount(myApp._accountId);
                    double current = acc.current;
                    double newCurrent = current - a;
                    acc.current = newCurrent;

                    if (dc.updateAccount(acc) == 1) {
                        TextBox tb = new TextBox();
                        tb.Text = "New transaction was saved.";
                        spMsg.Children.Add(tb);
                    }
                }
            }
        }
 public int addNewTransaction(TransactionMod tr) {
     int rows = conn.Insert(tr);
     return rows;
 }