private void button5_Click(object sender, RoutedEventArgs e) { Accounts window = new Accounts(); window.Show(); this.Hide(); }
private void button_Click(object sender, RoutedEventArgs e) { if (goback == "client") { ClientDetails window = new ClientDetails(); window.Show(); this.Hide(); } else { Accounts window = new Accounts(); window.Show(); this.Hide(); } }
private void button_Click(object sender, RoutedEventArgs e) { if (mode == "loan") { Loans window = new Loans(); window.Show(); this.Hide(); } else { Accounts window = new Accounts(); window.Show(); this.Hide(); } }
private void button1_Click(object sender, RoutedEventArgs e) //save { 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(); Accounts window = new Accounts(); window.Show(); this.Hide(); } catch (SqlException) { MessageBox.Show("Error updating database: the balance might be too high."); } } else { MessageBox.Show("Invalid balance."); } } catch (OverflowException) { MessageBox.Show("The number is too big."); } }
private void buttondel_Click(object sender, RoutedEventArgs e) { if (!refresh()) { return; } MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to delete this account?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { try { SqlCommand cmd = new SqlCommand("EXEC DeleteAccount " + editing.ID); cmd.Connection = cn; cmd.ExecuteNonQuery(); Accounts window = new Accounts(); window.Show(); this.Hide(); } catch (SqlException) { MessageBox.Show("Error deleting account."); } } }
private void button_Click_1(object sender, RoutedEventArgs e) { double aux = -1; try { if (double.TryParse(textBoxc.Text, out aux)) { if (comboBox.Text == "Ordem") { atype = 0; } else if (comboBox.Text == "Prazo 6M") { atype = 1; } else if (comboBox.Text == "Prazo 1A") { atype = 2; } else if (comboBox.Text == "Prazo 3A") { atype = 3; } if (!refresh()) { return; } SqlCommand cmd = new SqlCommand("SELECT interest from account_type where atype=" + atype); cmd.Connection = cn; double baseInterest = (double)(decimal)cmd.ExecuteScalar() * 100; double interest = 0; if (atype == 1) { double capital = Convert.ToDouble(textBoxc.Text); double jurofinal = ((capital * baseInterest) / 180) / 365; double pormes = capital * jurofinal; interest = pormes / 6; } else if (atype == 2) { double capital = Convert.ToDouble(textBoxc.Text); double jurofinal = ((capital * baseInterest) / 365) / 365; double pormes = capital * jurofinal; interest = pormes / (1 * 12); } else if (atype == 3) { double capital = Convert.ToDouble(textBoxc.Text); double jurofinal = ((capital * baseInterest) / 1095) / 365; double pormes = capital * jurofinal; interest = pormes / (3 * 12); } //make sure unique IDs are used when creating things cmd = new SqlCommand("SELECT max(id) FROM ACCOUNTS"); cmd.Connection = cn; int newID = (int)cmd.ExecuteScalar() + 1; string b = aux.ToString().Replace(",", "."); string i = interest.ToString().Replace(",", "."); try { cmd = new SqlCommand("EXEC InsertAccount " + newID + ", " + b + ", " + atype + ", " + i); cmd.Connection = cn; cmd.ExecuteNonQuery(); if (goback == "client" && autolinkid != -1) { cmd = new SqlCommand("INSERT INTO CLIENT_ACCOUNTS (aid, cid) VALUES (" + newID + ", " + autolinkid + ")"); cmd.Connection = cn; cmd.ExecuteNonQuery(); ClientDetails window = new ClientDetails(); window.Show(); this.Hide(); } else { Accounts window = new Accounts(); window.Show(); this.Hide(); } } catch (SqlException) { MessageBox.Show("Error updating database: the balance might be too high."); } } else { MessageBox.Show("Invalid amount."); } } catch (OverflowException) { MessageBox.Show("The number is too big."); } }