예제 #1
0
        private void Add_new_category(object sender, RoutedEventArgs e)
        {
            string category_name = AddCategoryDialogCategoryName.Text;

            if (DatabaseHandler.Sanitize_string(category_name))
            {
                if (category_name == "Category")
                {
                    InvalidInputDialog invalid_input_dialog = new InvalidInputDialog();
                    invalid_input_dialog.Set_msg("Invalid category name");
                    invalid_input_dialog.ShowDialog();
                    return;
                }
                if (DatabaseHandler.Category_exists(GlobalVariables.temporary_file_path, category_name) != true)
                {
                    this.category_name = category_name;
                    this.success       = true;
                    this.Close();
                }
            }
            else
            {
                InvalidInputDialog invalid_input_dialog = new InvalidInputDialog();
                invalid_input_dialog.Set_msg("Are you using any ilegal chars ('!@#$%^&*()_+=,./\";:[]{}\\|)?");
                invalid_input_dialog.ShowDialog();
            }
        }
        private void Add_new_currency(object sender, RoutedEventArgs e)
        {
            string currency_name = AddCurrencyDialogCurrencyNameBox.Text;

            if (DatabaseHandler.Sanitize_string(currency_name))
            {
                if (DatabaseHandler.Currency_exists(GlobalVariables.temporary_file_path, currency_name) != true)
                {
                    double vs_usd_rate;
                    try
                    {
                        vs_usd_rate = Convert.ToDouble(AddCurrencyDialogCurrencyRateBox.Text);
                    }
                    catch
                    {
                        return;
                    }
                    if (vs_usd_rate > 0)
                    {
                        DatabaseHandler.Add_currency(GlobalVariables.temporary_file_path, currency_name, vs_usd_rate);
                        this.correcly_created = true;
                        this.Close();
                    }
                    else
                    {
                        InvalidInputDialog invalid_input_dialog = new InvalidInputDialog();
                        invalid_input_dialog.Set_msg("The Currency rate can't be negative");
                        invalid_input_dialog.ShowDialog();
                    }
                }
            }
            else
            {
                InvalidInputDialog invalid_input_dialog = new InvalidInputDialog();
                invalid_input_dialog.Set_msg("Are you using any ilegal chars ('!@#$%^&*()_+=,./\";:[]{}\\|)?");
                invalid_input_dialog.ShowDialog();
            }
        }