private void btnLend_Click(object sender, RoutedEventArgs e)
        {
            if (isValid())
            {
                DateTime d  = dpDate.Date.DateTime;
                double   a  = Convert.ToDouble(tbxAmmount.Text);
                string   to = tbxTo.Text;

                lm = new LendMod();

                lm.date    = d;
                lm.ammount = a;
                lm.to      = to;
                lm.accid   = myApp._accountId;

                if (dc.addLend(lm) == 1)
                {
                    dpDate.Date     = DateTime.Now;
                    tbxAmmount.Text = "";
                    tbxTo.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 = "Saved successfully.";
                        spMsg.Children.Add(tb);
                    }
                }
            }
        }
示例#2
0
        public int addLend(LendMod lm)
        {
            int rows = conn.Insert(lm);

            return(rows);
        }