private void button_Click(object sender, RoutedEventArgs e) //return
 {
     if (goback == "client")
     {
         ClientExtra window = new ClientExtra();
         window.Show();
         this.Hide();
     }
     else if (goback == "account")
     {
         AccountExtra window = new AccountExtra();
         window.Show();
         this.Hide();
     }
     else
     {
         if (editing.Approved)
         {
             Loans window = new Loans();
             window.Show();
             this.Hide();
         }
         else
         {
             LoansApprove window = new LoansApprove();
             window.Show();
             this.Hide();
         }
     }
 }
Exemple #2
0
        private void button10_Click(object sender, RoutedEventArgs e)
        {
            decimal balance = -1;

            try
            {
                if (decimal.TryParse(t3.Text, out balance))
                {
                    if (!refresh())
                    {
                        return;
                    }

                    SqlCommand cmd = new SqlCommand("SELECT * FROM ACCOUNT_TYPE WHERE descr='" + comboBox.SelectedItem.ToString() + "'");
                    cmd.Connection = cn;

                    SqlDataAdapter adapter = new SqlDataAdapter();
                    adapter.SelectCommand = cmd;
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet);

                    int    atype = (int)dataSet.Tables[0].Rows[0]["atype"];
                    string b     = balance.ToString().Replace(",", ".");

                    try
                    {
                        cmd            = new SqlCommand("UPDATE ACCOUNTS SET balance=" + b + ", atype=" + atype + " WHERE id=" + editing.ID.ToString());
                        cmd.Connection = cn;
                        cmd.ExecuteNonQuery();

                        editing.Balance = (double)balance;


                        AccountExtra window = new AccountExtra();
                        window.Show();
                        this.Hide();
                    }
                    catch (SqlException) { MessageBox.Show("In an attempt to save your changes, there was an error updating the database: the balance might be too high."); }
                }
                else
                {
                    MessageBox.Show("In an attempt to save your changes, an invalid balance was detected.");
                }
            }
            catch (OverflowException) { MessageBox.Show("In an attempt to save your changes, an error ocurred: the balance might be too high."); }
        }