Пример #1
0
        private void list_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) //pick
        {
            ListView lv   = sender as ListView;
            Border   item = (Border)lv.SelectedItem;

            if (item != null && lv.SelectedIndex != 0)
            {
                if (!refresh())
                {
                    return;
                }

                TextBlock idcontainer = (TextBlock)((Border)((StackPanel)item.Child).Children[0]).Child;
                string    id          = idcontainer.Text;

                if (mode == "loan")
                {
                    App.Current.Properties["loanaid"] = id;

                    LoanFactory window = new LoanFactory();
                    window.Show();
                    this.Hide();
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("INSERT INTO CLIENT_ACCOUNTS (aid, cid) VALUES (" + id + ", " + editing.ID.ToString() + ")");
                    cmd.Connection = cn;
                    cmd.ExecuteNonQuery();

                    ClientDetails window = new ClientDetails();
                    window.Show();
                    this.Hide();
                }
            }
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            ClientDetails window = new ClientDetails();

            window.Show();
            this.Hide();
        }
Пример #3
0
        private void list_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) //details
        {
            ListView lv   = sender as ListView;
            Border   item = (Border)lv.SelectedItem;

            if (item != null && lv.SelectedIndex != 0)
            {
                if (!refresh())
                {
                    return;
                }

                TextBlock idcontainer = (TextBlock)((Border)((StackPanel)item.Child).Children[0]).Child;
                string    id          = idcontainer.Text;

                SqlCommand cmd = new SqlCommand("SELECT * FROM CLIENTS WHERE id=" + id);
                cmd.Connection = cn;

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

                Client useredit;

                useredit = new Client((int)dataSet.Tables[0].Rows[0]["id"],
                                      (string)dataSet.Tables[0].Rows[0]["name"]);
                useredit.Address = (string)dataSet.Tables[0].Rows[0]["addr"];
                useredit.Postal  = (string)dataSet.Tables[0].Rows[0]["postal"];
                useredit.CID     = (string)dataSet.Tables[0].Rows[0]["citid"];
                useredit.Gender  = (string)dataSet.Tables[0].Rows[0]["gender"];
                useredit.NIF     = (int)dataSet.Tables[0].Rows[0]["nif"];

                cmd            = new SqlCommand("SELECT id, amt FROM CLIENTS JOIN SHARES ON cid=id and id=" + id);
                cmd.Connection = cn;

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

                if (dataSet.Tables[0].Rows.Count == 0)
                {
                    useredit.Shares = 0; //no data
                }
                else
                {
                    useredit.Shares = (int)dataSet.Tables[0].Rows[0]["amt"];
                }


                App.Current.Properties["useredit"] = useredit;
                ClientDetails window = new ClientDetails();
                window.Show();
                this.Hide();
                return;
            }
        }
Пример #4
0
 private void button1_Click(object sender, RoutedEventArgs e) //go back
 {
     if (mode == "loan")
     {
         ChooseClient window = new ChooseClient();
         window.Show();
         this.Hide();
     }
     else
     {
         ClientDetails window = new ClientDetails();
         window.Show();
         this.Hide();
     }
 }
Пример #5
0
 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();
     }
 }
Пример #6
0
        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."); }
        }