Диаграмма классов C#

Подскажите, пожалуйста, верно ли смоделирована диаграмма? Если нет, то как исправить? введите сюда описание изображения

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MySql.Data.MySqlClient;

namespace tax_calculator
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    /// 
    public class List_Mysql: MySql
    {
        
        public struct Tax
        {
            public string name { get; set; }
            public int age { get; set; }
        }
        public List<Tax> tax = new List<Tax>();

    }

    public class MySql
    {
       
        string connString = @"server=127.0.0.1;port=3306;user=root;database=tax_calculator;charset=utf8";
        public struct Tax
        {
            public string id { get; set; }
            public string ndfl_rate { get; set; }
            public string amount_ndfl { get; set; }
            public string amount_tax { get; set; }
            public string amount_no_ndfl { get; set; }
            public string face_type { get; set; }
        }
        public struct Tax_type
        {
            public string id { get; set; }
            public string name { get; set; }
            public string bid { get; set; }
            public string face_type { get; set; }
            public object NULL { get; internal set; }
        }
        public List<Tax> tax = new List<Tax>();
        public List<Tax_type> tax_type = new List<Tax_type>();
        public List<string> combobox = new List<string>();
        public Dictionary<string, string> tax_combobox = new Dictionary<string, string>();
        public void Insert(string ndfl_rate, string amount_ndfl, string amount_tax, string amount_no_ndfl,string face_type)
        {
            MySqlConnection connection = new MySqlConnection(connString);
            // открываем соединение
            connection.Open();
            // запросы
            // запрос вставки данных
            string query = "INSERT INTO tax (ndfl_rate, amount_ndfl, amount_tax, amount_no_ndfl,face_type) " +
                "VALUES ('"+ ndfl_rate + "', '" + amount_ndfl + "', '" + amount_tax + "', '" + amount_no_ndfl + "', '" + face_type + "')";
            MySqlCommand command = new MySqlCommand(query, connection);
            // выполняем запрос
            command.ExecuteNonQuery();
            // закрываем подключение к БД
            connection.Close();
        }
        public void Insert_tax_type(string name, string bid, string face_type)
        {
            MySqlConnection connection = new MySqlConnection(connString);
            // открываем соединение
            connection.Open();
            // запросы
            // запрос вставки данных
            string query = "INSERT INTO tax_type (name, bid, face_type) " +
                "VALUES ('" + name + "', '" + bid + "', '" + face_type + "')";
            MySqlCommand command = new MySqlCommand(query, connection);
            // выполняем запрос
            command.ExecuteNonQuery();
            // закрываем подключение к БД
            connection.Close();
        }
        public void Select()
        {
            List_Mysql list_Mysql = new List_Mysql();
            MySqlConnection conn = new MySqlConnection(connString);
            conn.Open();
            string sql = "SELECT * FROM tax";

            MySqlCommand command = new MySqlCommand(sql, conn);
            DbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                string empNo = reader.GetString(1);
                tax.Add(
                    new Tax
                    {
                        id = reader.GetString(0),
                        ndfl_rate = reader.GetString(1),
                        amount_ndfl = reader.GetString(2),
                        amount_tax = reader.GetString(3),
                        amount_no_ndfl = reader.GetString(4),
                        face_type = reader.GetString(5)
                    }
                );
            }
            conn.Close();
            //Error.Content = tax[0].name.ToString();
        }
        public void Select_tax_type()
        {
            List_Mysql list_Mysql = new List_Mysql();
            MySqlConnection conn = new MySqlConnection(connString);
            conn.Open();
            string sql = "SELECT * FROM tax_type";

            MySqlCommand command = new MySqlCommand(sql, conn);
            DbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {

                tax_type.Add(
                    new Tax_type
                    {
                        id = reader.GetString(0),
                        name = reader.GetString(1),
                        bid = reader.GetString(2),
                        face_type = reader.GetString(3),
                        NULL = null
                    }
                ); 
            }
            conn.Close();
            //Error.Content = tax[0].name.ToString();
        }
        public void Select_tax_type_id(string id)
        {
            List_Mysql list_Mysql = new List_Mysql();
            MySqlConnection conn = new MySqlConnection(connString);
            conn.Open();
            string sql = "SELECT * FROM tax_type WHERE id = "+ id ;

            MySqlCommand command = new MySqlCommand(sql, conn);
            DbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {

                tax_type.Add(
                    new Tax_type
                    {
                        id = reader.GetString(0),
                        name = reader.GetString(1),
                        bid = reader.GetString(2),
                        face_type = reader.GetString(3),
                    }
                );
            }
            conn.Close();
            //Error.Content = tax[0].name.ToString();
        }
        public void Update_tax_type(string id, string name, string bid, string face_type)
        {
            MySqlConnection connection = new MySqlConnection(connString);
            // открываем соединение
            connection.Open();
            // запросы
            // запрос вставки данных
            string query = "UPDATE tax_type SET name=@name,bid=@bid, face_type =@face_type WHERE id =@id";
            MySqlCommand cmd = new MySqlCommand();
            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@id", Convert.ToInt16(id));
            cmd.Parameters.AddWithValue("@name", name);
            cmd.Parameters.AddWithValue("@bid", bid);
            cmd.Parameters.AddWithValue("@face_type", face_type);
            cmd.Connection = connection;
            cmd.ExecuteNonQuery();
            connection.Close();
        }
        public void Delete_tax_type(string id)
        {
            MySqlConnection connection = new MySqlConnection(connString);
            // открываем соединение
            connection.Open();
            // запросы
            // запрос вставки данных
            string query = "delete from tax_type where id =@id";
            MySqlCommand cmd = new MySqlCommand();
            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@id", Convert.ToInt16(id));
           
            cmd.Connection = connection;
            cmd.ExecuteNonQuery();
            connection.Close();
        }
        public void Select_Combobox()
        {
            List_Mysql list_Mysql = new List_Mysql();
            MySqlConnection conn = new MySqlConnection(connString);
            conn.Open();
            string sql = "SELECT name FROM tax_type";

            MySqlCommand command = new MySqlCommand(sql, conn);
            DbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                combobox.Add(reader.GetString(0));
            }
            conn.Close();
        }
        public void Select_Combobox(string name)
        {
            
            List_Mysql list_Mysql = new List_Mysql();

            MySqlConnection conn = new MySqlConnection(connString);
            conn.Open();
            string sql = "SELECT bid,face_type FROM tax_type WHERE name = '"+ name + "'";

            MySqlCommand command = new MySqlCommand(sql, conn);
            DbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                tax_combobox.Add("bid", reader.GetString(0));
                tax_combobox.Add("face_type", reader.GetString(1));
            }
            conn.Close();

            
        }


    }
    public partial class MainWindow : Window
    {
       
       
        string view_summ = "NULL";
        public MainWindow()
        {
            InitializeComponent();
            MySql mySql = new MySql();
            mySql.Select();mySql.Select_tax_type(); 
            tax_table.ItemsSource = mySql.tax;tax_type_table.ItemsSource = mySql.tax_type;
            mySql.Select_Combobox();
            combobox_tax.ItemsSource = mySql.combobox;
        }

        private void Calculate_Click(object sender, RoutedEventArgs e)
        {
            MySql mySql = new MySql();
            string amount_ndfl_, amount_tax_, amount_no_ndfl_;
            if (ndfl_rate.Text.Length == 0)
            {
                Error.Content = "Заполните поле Ставка НДФЛ(%):";
            }
            else if (tax_amount.Text.Length == 0)
            {
                Error.Content = "Заполните поле Сумма налога:";
            }
            else if(view_summ == "NULL")
            {
                Error.Content = "Заполните поле Я знаю сумму:";
            }
            else if (view_summ == "с НДФЛ")
            {
                int percentage_total = 100 + Convert.ToInt32(ndfl_rate.Text.ToString());
                float one_percentage = Convert.ToInt32(tax_amount.Text.ToString()) / percentage_total;
                amount_ndfl_ = tax_amount.Text;
                amount_ndfl.Content += amount_ndfl_;
                amount_tax_ = (Convert.ToInt32(ndfl_rate.Text.ToString()) * one_percentage).ToString();
                amount_tax.Content += amount_tax_;
                amount_no_ndfl_= (100 * one_percentage).ToString();
                amount_no_ndfl.Content += amount_no_ndfl_;
                mySql.Insert("Сумма с НДФЛ", amount_ndfl_,
                    amount_tax_, amount_no_ndfl_, face_type_.Text);
            }
            else if (view_summ == "налога")
            {
                //Сумма 1%
                float one_percentage = Convert.ToInt32(tax_amount.Text.ToString()) / Convert.ToInt32(ndfl_rate.Text.ToString());
                amount_ndfl_ = ((Convert.ToInt32(ndfl_rate.Text.ToString()) + 100) * one_percentage).ToString();
                amount_ndfl.Content += amount_ndfl_;
                amount_tax_= tax_amount.Text;
                amount_tax.Content += amount_tax_;
                amount_no_ndfl_ = (100 * one_percentage).ToString();
                amount_no_ndfl.Content += amount_no_ndfl_;
                mySql.Insert("Сумма налога", amount_ndfl_,amount_tax_, amount_no_ndfl_, face_type_.Text);
                     
            }
            else if (view_summ == "без НДФЛ")
            {
                //Сумма 1%
                float one_percentage = Convert.ToInt32(tax_amount.Text.ToString()) / 100;
                amount_ndfl_ = ((Convert.ToInt32(ndfl_rate.Text.ToString()) + 100) * one_percentage).ToString();
                amount_ndfl.Content += amount_ndfl_;
                amount_tax_ = (Convert.ToInt32(ndfl_rate.Text.ToString()) * one_percentage).ToString();
                amount_tax.Content += amount_tax_;
                amount_no_ndfl_= tax_amount.Text;
                amount_no_ndfl.Content += amount_no_ndfl_;
                mySql.Insert("Сумма без НДФЛ", amount_ndfl_, amount_tax_, amount_no_ndfl_, face_type_.Text);
            }

            mySql.Select();
            tax_table.ItemsSource = null;
            tax_table.ItemsSource = mySql.tax;

        }

        private void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            RadioButton rb = sender as RadioButton;
            view_summ = rb.Content.ToString();
            //ndfl_rate.Text = ""; tax_amount.Text = "";
            amount_ndfl.Content = "Сумма с НДФЛ: ";
            amount_tax.Content = "Сумма налога: ";
            amount_no_ndfl.Content = "Сумма без НДФЛ: ";

        }

        private void tax_type_add_Click(object sender, RoutedEventArgs e)
        {
            MySql mySql = new MySql();
            mySql.Insert_tax_type(add_tax_type_name.Text, add_bid_name.Text, add_face_type.Text);
            mySql.Select_tax_type();
            tax_type_table.ItemsSource = null;
            tax_type_table.ItemsSource = mySql.tax_type;
            mySql.Select_Combobox();
            combobox_tax.ItemsSource = mySql.combobox;
        }

        public void tax_type_change_Click(object sender, RoutedEventArgs e)
        {
            MySql mySql = new MySql();
            mySql.Update_tax_type(tax_type_id.Content.ToString(), tax_type_name.Text, bid_name.Text, face_type.Text);
            mySql.Select_tax_type();
            
            MySql.Tax_type rowView = (MySql.Tax_type)tax_type_table.SelectedItem;
            tax_type_table.ItemsSource = null;
            tax_type_table.ItemsSource = mySql.tax_type;
            tax_type_change.IsEnabled = false;
            tax_type_delete.IsEnabled = false;
            mySql.Select_Combobox();
            combobox_tax.ItemsSource = mySql.combobox;
        }

        public void tax_type_table_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
           
            
        }

        private void tax_type_table_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            MySql mySql = new MySql();

            if(tax_type_table.SelectedIndex != -1)
            {
                MySql.Tax_type n = (MySql.Tax_type)tax_type_table.Items[tax_type_table.SelectedIndex];
                tax_type_id.Content = n.id;
                tax_type_name.Text = n.name;
                bid_name.Text = n.bid;
                face_type.Text = n.face_type;
            }
            tax_type_change.IsEnabled = true;
            tax_type_delete.IsEnabled = true;
        }

        private void tax_type_delete_Click(object sender, RoutedEventArgs e)
        {
            
            MySql mySql = new MySql();
            mySql.Delete_tax_type(tax_type_id.Content.ToString());
            mySql.Select_tax_type();

            MySql.Tax_type rowView = (MySql.Tax_type)tax_type_table.SelectedItem;
            tax_type_table.ItemsSource = null;
            tax_type_table.ItemsSource = mySql.tax_type;
            tax_type_change.IsEnabled = false;
            tax_type_delete.IsEnabled = false;
           
        }

        private void combobox_tax_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Object selectedItem = combobox_tax.SelectedItem;
            //ndfl_rate.Text = selectedItem.ToString();
            MySql mySql = new MySql();
            mySql.Select_Combobox(selectedItem.ToString());
            ndfl_rate.Text = mySql.tax_combobox["bid"];
            face_type_.Text = mySql.tax_combobox["face_type"];
        }

        private void tax_type_delete_Click_1(object sender, RoutedEventArgs e)
        {
            MySql mySql = new MySql();
            mySql.Delete_tax_type(tax_type_id.Content.ToString());
            mySql.Select_tax_type();

            MySql.Tax_type rowView = (MySql.Tax_type)tax_type_table.SelectedItem;
            tax_type_table.ItemsSource = null;
            tax_type_table.ItemsSource = mySql.tax_type;
            tax_type_change.IsEnabled = false;
            tax_type_delete.IsEnabled = false;
            mySql.Select_Combobox();
            combobox_tax.ItemsSource = mySql.combobox;
        }
    }
    
}

Ответы (0 шт):