Ejemplo n.º 1
0
        public result()
        {
            InitializeComponent();

            //SET Height and width to match the content of the page if it differs from
            //mainwindow
            //Application.Current.MainWindow.Height = 450;
            //Application.Current.MainWindow.Width = 450;

            List <Dictionary <string, string> > queryResult = new List <Dictionary <string, string> >();

            DataTable data = new DataTable();

            data.Columns.Add("expression", typeof(String));
            data.Columns.Add("preorder", typeof(String));
            data.Columns.Add("postorder", typeof(String));
            data.Columns.Add("decimalResult", typeof(String));
            data.Columns.Add("binaryResult", typeof(String));

            ConnectMysql conn = new ConnectMysql();

            queryResult = conn.QueryData();

            foreach (Dictionary <string, string> rowResult in queryResult)
            {
                DataRow row = data.NewRow();
                row["expression"]    = rowResult["expression"];
                row["preorder"]      = rowResult["preorder"];
                row["postorder"]     = rowResult["postorder"];
                row["decimalResult"] = rowResult["decimalResult"];
                row["binaryResult"]  = rowResult["binaryResult"];
                data.Rows.Add(row);
            }
            this.dataGrid.ItemsSource = data.DefaultView;
        }
Ejemplo n.º 2
0
        //Insert
        private void insertClick(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> input = new Dictionary <string, string>();

            input.Add("expression", inputText.Content.ToString());
            input.Add("preorder", preorderLabel.Content.ToString());
            input.Add("postorder", postorderLabel.Content.ToString());
            input.Add("decimal", decimalLabel.Content.ToString());
            input.Add("binary", binaryLabel.Content.ToString());

            ConnectMysql conn = new ConnectMysql(input);

            //expression doesn't exist
            if (conn.Check() == true)
            {
                MessageBox.Show("The expression already exists!", "Oops!");
            }
            //expression exists
            else
            {
                conn.Insert();
            }
        }