Exemplo n.º 1
0
        private void AddCase_Click(object sender, RoutedEventArgs e)
        {
            int numberOfStackPanel = computedGrid.Children.Count;
            int i = 2;

            this.InitializeComponent();

            Label   lblWhen = new Label();
            TextBox txtWhen = new TextBox();
            Label   lblThen = new Label();
            TextBox txtThen = new TextBox();
            Label   lblElse = new Label();
            TextBox txtElse = new TextBox();

            var lblW = (UIElement)this.FindName("lblWhen" + Convert.ToString(totalCaseCondition));
            var txtW = (UIElement)this.FindName("txtWhen" + Convert.ToString(totalCaseCondition));

            var lblT = (UIElement)this.FindName("lblThen" + Convert.ToString(totalCaseCondition));
            var txtT = (UIElement)this.FindName("txtThen" + Convert.ToString(totalCaseCondition));

            var lblE = (UIElement)this.FindName("lblElse");
            var txtE = (UIElement)this.FindName("txtElse");

            this.computedGrid.Children.Remove(lblE);
            this.computedGrid.Children.Remove(txtE);

            if (lblW != null)
            {
                this.UnregisterName("lblWhen" + Convert.ToString(totalCaseCondition));
                this.UnregisterName("txtWhen" + Convert.ToString(totalCaseCondition));

                this.UnregisterName("lblThen" + Convert.ToString(totalCaseCondition));
                this.UnregisterName("txtThen" + Convert.ToString(totalCaseCondition));
            }

            this.UnregisterName("lblElse");
            this.UnregisterName("txtElse");

            lblWhen.Name                = "lblWhen" + Convert.ToString(totalCaseCondition);
            lblWhen.Content             = "When";
            lblWhen.Visibility          = System.Windows.Visibility.Visible;
            lblWhen.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            lblWhen.Margin              = new Thickness(7);
            lblWhen.SetValue(Grid.RowProperty, totalRow);
            lblWhen.SetValue(Grid.ColumnProperty, 0);
            this.RegisterName("lblWhen" + Convert.ToString(totalCaseCondition), lblWhen);

            txtWhen.Text        = "";
            txtWhen.Name        = "txtWhen" + Convert.ToString(totalCaseCondition);
            txtWhen.Height      = 20;
            txtWhen.Width       = 120;
            txtWhen.BorderBrush = System.Windows.Media.Brushes.SteelBlue;
            txtWhen.Visibility  = System.Windows.Visibility.Visible;
            txtWhen.Margin      = new Thickness(0, 0, 5, 5);
            txtWhen.SetValue(Grid.RowProperty, totalRow);
            txtWhen.SetValue(Grid.ColumnProperty, 1);
            this.RegisterName("txtWhen" + Convert.ToString(totalCaseCondition), txtWhen);

            totalRow                    = totalRow + 2;
            lblThen.Name                = "lblThen" + Convert.ToString(i);
            lblThen.Content             = "Then";
            lblThen.Visibility          = System.Windows.Visibility.Visible;
            lblThen.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            lblThen.Margin              = new Thickness(7);
            lblThen.SetValue(Grid.RowProperty, totalRow);
            lblThen.SetValue(Grid.ColumnProperty, 0);
            this.RegisterName("lblThen" + Convert.ToString(totalCaseCondition), lblThen);

            txtThen.Text        = "";
            txtThen.Name        = "txtThen" + Convert.ToString(totalCaseCondition);
            txtThen.Height      = 20;
            txtThen.Width       = 120;
            txtThen.BorderBrush = System.Windows.Media.Brushes.SteelBlue;
            txtThen.Visibility  = System.Windows.Visibility.Visible;
            txtThen.Margin      = new Thickness(0, 0, 5, 5);
            txtThen.SetValue(Grid.RowProperty, totalRow);
            txtThen.SetValue(Grid.ColumnProperty, 1);
            this.RegisterName("txtThen" + Convert.ToString(totalCaseCondition), txtThen);

            this.computedGrid.Children.Add(lblWhen);
            this.computedGrid.Children.Add(txtWhen);
            this.computedGrid.Children.Add(lblThen);
            this.computedGrid.Children.Add(txtThen);

            totalRow = totalRow + 2;

            lblElse.Content             = "Else";
            lblElse.Name                = "lblElse";
            lblElse.Visibility          = System.Windows.Visibility.Visible;
            lblElse.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            lblElse.Margin              = new Thickness(7);
            lblElse.SetValue(Grid.RowProperty, totalRow);
            lblElse.SetValue(Grid.ColumnProperty, 0);
            this.RegisterName("lblElse", lblElse);

            txtElse.Text        = "";
            txtElse.Name        = "txtElse";
            txtElse.Height      = 20;
            txtElse.Width       = 120;
            txtElse.BorderBrush = System.Windows.Media.Brushes.SteelBlue;
            txtElse.Visibility  = System.Windows.Visibility.Visible;
            txtElse.Margin      = new Thickness(0, 0, 5, 5);
            txtElse.SetValue(Grid.RowProperty, totalRow);
            txtElse.SetValue(Grid.ColumnProperty, 1);
            this.RegisterName("txtElse", txtElse);

            this.computedGrid.Children.Add(lblElse);
            this.computedGrid.Children.Add(txtElse);

            AddCompCol.SetValue(Grid.RowProperty, totalRow + 2);

            totalCaseCondition = totalCaseCondition + 1;
        }
Exemplo n.º 2
0
        private void ComputedColFunctionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.ComputedColFunctionComboBox.Style = ComboboxOriginalStyle;

            ComputedColComboBox1.Visibility    = System.Windows.Visibility.Hidden;
            ComputedColComboBox2.Visibility    = System.Windows.Visibility.Hidden;
            ComputedColComboBox3.Visibility    = System.Windows.Visibility.Hidden;
            ComputedColComboBox4.Visibility    = System.Windows.Visibility.Hidden;
            ComputedColName1.Visibility        = System.Windows.Visibility.Hidden;
            ComputedColName2.Visibility        = System.Windows.Visibility.Hidden;
            ComputedColName3.Visibility        = System.Windows.Visibility.Hidden;
            ComputedColName4.Visibility        = System.Windows.Visibility.Hidden;
            ComputedColifnullTxtBox.Visibility = System.Windows.Visibility.Hidden;
            AddCaseCondition.Visibility        = System.Windows.Visibility.Hidden;
            RemoveCaseCondition.Visibility     = System.Windows.Visibility.Hidden;

            Label   lblWhen = new Label();
            TextBox txtWhen = new TextBox();
            Label   lblThen = new Label();
            TextBox txtThen = new TextBox();
            Label   lblElse = new Label();
            TextBox txtElse = new TextBox();

            for (int i = 1; i < totalCaseCondition; i++)
            {
                var lblW = (UIElement)this.FindName("lblWhen" + Convert.ToString(i));
                var txtW = (UIElement)this.FindName("txtWhen" + Convert.ToString(i));

                var lblT = (UIElement)this.FindName("lblThen" + Convert.ToString(i));
                var txtT = (UIElement)this.FindName("txtThen" + Convert.ToString(i));

                var lblE = (UIElement)this.FindName("lblElse");
                var txtE = (UIElement)this.FindName("txtElse");

                this.computedGrid.Children.Remove(lblW);
                this.computedGrid.Children.Remove(txtW);

                this.computedGrid.Children.Remove(lblT);
                this.computedGrid.Children.Remove(txtT);

                this.computedGrid.Children.Remove(lblE);
                this.computedGrid.Children.Remove(txtE);

                if (lblW != null)
                {
                    this.UnregisterName("lblWhen" + Convert.ToString(i));
                    this.UnregisterName("txtWhen" + Convert.ToString(i));

                    this.UnregisterName("lblThen" + Convert.ToString(i));
                    this.UnregisterName("txtThen" + Convert.ToString(i));

                    if (i == 1)
                    {
                        this.UnregisterName("lblElse");
                        this.UnregisterName("txtElse");
                    }
                }
            }
            this.ComputedColFunctionComboBox.ItemsSource = Functions.getFunctionNames();
            if (ComputedColFunctionComboBox.SelectedItem != null)
            {
                Function function = Functions.getFunction(ComputedColFunctionComboBox.SelectedItem.ToString());
                if (function != null)
                {
                    List <string> columnNames = GetColumnsFromAllFromTabTable();
                    List <string> formatType  = Common.GetDateFormatList();
                    switch (function.NumParameters)
                    {
                    case 1:
                        ComputedColComboBox1.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColName1.Visibility           = System.Windows.Visibility.Visible;
                        this.ComputedColComboBox1.ItemsSource = columnNames;
                        this.ComputedColName1.Content         = "Column Name";
                        break;

                    case 2:
                        ComputedColComboBox1.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColComboBox2.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColName1.Visibility           = System.Windows.Visibility.Visible;
                        ComputedColName2.Visibility           = System.Windows.Visibility.Visible;
                        this.ComputedColComboBox1.ItemsSource = columnNames;
                        this.ComputedColName1.Content         = "Column Name";
                        if (function.Name == "DATE_FORMAT")
                        {
                            this.ComputedColName2.Content         = "Format Type";
                            this.ComputedColComboBox2.ItemsSource = formatType;
                            break;
                        }
                        else if (function.Name == "IFNULL")
                        {
                            this.ComputedColName2.Content           = "Value";
                            this.ComputedColifnullTxtBox.Visibility = System.Windows.Visibility.Visible;
                            this.ComputedColComboBox2.Visibility    = System.Windows.Visibility.Hidden;
                            this.ComputedColifnullTxtBox.Text       = "0";
                            break;
                        }
                        else
                        {
                            this.ComputedColName2.Content         = "Value";
                            this.ComputedColComboBox2.ItemsSource = columnNames;
                            break;
                        }

                    case 3:
                        ComputedColComboBox1.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColComboBox2.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColComboBox3.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColName1.Visibility           = System.Windows.Visibility.Visible;
                        ComputedColName2.Visibility           = System.Windows.Visibility.Visible;
                        ComputedColName3.Visibility           = System.Windows.Visibility.Visible;
                        this.ComputedColComboBox1.ItemsSource = columnNames;
                        this.ComputedColComboBox2.ItemsSource = columnNames;
                        this.ComputedColComboBox3.ItemsSource = columnNames;
                        this.ComputedColName1.Content         = "Group Column";
                        this.ComputedColName2.Content         = "Order Column";
                        this.ComputedColName3.Content         = "Ref Column";
                        break;

                    case 4:
                        ComputedColComboBox1.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColComboBox2.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColComboBox3.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColComboBox4.Visibility       = System.Windows.Visibility.Visible;
                        ComputedColName1.Visibility           = System.Windows.Visibility.Visible;
                        ComputedColName2.Visibility           = System.Windows.Visibility.Visible;
                        ComputedColName3.Visibility           = System.Windows.Visibility.Visible;
                        this.ComputedColComboBox1.ItemsSource = columnNames;
                        this.ComputedColComboBox2.ItemsSource = columnNames;
                        this.ComputedColComboBox3.ItemsSource = columnNames;
                        this.ComputedColComboBox4.ItemsSource = columnNames;
                        this.ComputedColName1.Content         = "Group Column";
                        this.ComputedColName2.Content         = "Order Column";
                        this.ComputedColName3.Content         = "Ref Column";
                        break;

                    case 5:
                        AddCaseCondition.Visibility    = System.Windows.Visibility.Visible;
                        RemoveCaseCondition.Visibility = System.Windows.Visibility.Visible;

                        totalRow = 13;

                        lblWhen.Name                = "lblWhen1";
                        lblWhen.Content             = "When";
                        lblWhen.Visibility          = System.Windows.Visibility.Visible;
                        lblWhen.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        lblWhen.Margin              = new Thickness(7);
                        lblWhen.SetValue(Grid.RowProperty, totalRow);
                        lblWhen.SetValue(Grid.ColumnProperty, 0);
                        this.RegisterName("lblWhen1", lblWhen);

                        txtWhen.Text        = "";
                        txtWhen.Name        = "txtWhen1";
                        txtWhen.Height      = 20;
                        txtWhen.Width       = 120;
                        txtWhen.BorderBrush = System.Windows.Media.Brushes.SteelBlue;
                        txtWhen.Visibility  = System.Windows.Visibility.Visible;
                        txtWhen.Margin      = new Thickness(0, 0, 5, 5);
                        txtWhen.SetValue(Grid.RowProperty, totalRow);
                        txtWhen.SetValue(Grid.ColumnProperty, 1);
                        this.RegisterName("txtWhen1", txtWhen);

                        totalRow                    = totalRow + 2;
                        lblThen.Name                = "lblThen1";
                        lblThen.Content             = "Then";
                        lblThen.Visibility          = System.Windows.Visibility.Visible;
                        lblThen.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        lblThen.Margin              = new Thickness(7);
                        lblThen.SetValue(Grid.RowProperty, totalRow);
                        lblThen.SetValue(Grid.ColumnProperty, 0);
                        this.RegisterName("lblThen1", lblThen);

                        txtThen.Text        = "";
                        txtThen.Name        = "txtThen1";
                        txtThen.Height      = 20;
                        txtThen.Width       = 120;
                        txtThen.BorderBrush = System.Windows.Media.Brushes.SteelBlue;
                        txtThen.Visibility  = System.Windows.Visibility.Visible;
                        txtThen.Margin      = new Thickness(0, 0, 5, 5);
                        txtThen.SetValue(Grid.RowProperty, totalRow);
                        txtThen.SetValue(Grid.ColumnProperty, 1);
                        this.RegisterName("txtThen1", txtThen);

                        this.computedGrid.Children.Add(lblWhen);
                        this.computedGrid.Children.Add(txtWhen);
                        this.computedGrid.Children.Add(lblThen);
                        this.computedGrid.Children.Add(txtThen);

                        totalRow = totalRow + 2;

                        lblElse.Content             = "Else";
                        lblElse.Name                = "lblElse";
                        lblElse.Visibility          = System.Windows.Visibility.Visible;
                        lblElse.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        lblElse.Margin              = new Thickness(7);
                        lblElse.SetValue(Grid.RowProperty, totalRow);
                        lblElse.SetValue(Grid.ColumnProperty, 0);
                        this.RegisterName("lblElse", lblElse);

                        txtElse.Text        = "";
                        txtElse.Name        = "txtElse";
                        txtElse.Height      = 20;
                        txtElse.Width       = 120;
                        txtElse.BorderBrush = System.Windows.Media.Brushes.SteelBlue;
                        txtElse.Visibility  = System.Windows.Visibility.Visible;
                        txtElse.Margin      = new Thickness(0, 0, 5, 5);
                        txtElse.SetValue(Grid.RowProperty, totalRow);
                        txtElse.SetValue(Grid.ColumnProperty, 1);
                        this.RegisterName("txtElse", txtElse);

                        this.computedGrid.Children.Add(lblElse);
                        this.computedGrid.Children.Add(txtElse);

                        AddCompCol.SetValue(Grid.RowProperty, totalRow + 2);

                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void RemoveCase_Click(object sender, RoutedEventArgs e)
        {
            Label   lblWhen = new Label();
            TextBox txtWhen = new TextBox();
            Label   lblThen = new Label();
            TextBox txtThen = new TextBox();
            Label   lblElse = new Label();
            TextBox txtElse = new TextBox();

            if (totalCaseCondition > 2)
            {
                var lblw = (UIElement)this.FindName("lblWhen" + Convert.ToString(totalCaseCondition - 1));
                var txtw = (UIElement)this.FindName("txtWhen" + Convert.ToString(totalCaseCondition - 1));

                var lblt = (UIElement)this.FindName("lblThen" + Convert.ToString(totalCaseCondition - 1));
                var txtt = (UIElement)this.FindName("txtThen" + Convert.ToString(totalCaseCondition - 1));

                var lble = (UIElement)this.FindName("lblElse");
                var txte = (UIElement)this.FindName("txtElse");

                totalRow = totalRow - 2;

                this.computedGrid.Children.Remove(lblw);
                this.computedGrid.Children.Remove(txtw);

                totalRow = totalRow - 2;

                this.computedGrid.Children.Remove(lblt);
                this.computedGrid.Children.Remove(txtt);

                this.computedGrid.Children.Remove(lble);
                this.computedGrid.Children.Remove(txte);

                this.UnregisterName("lblElse");
                this.UnregisterName("txtElse");

                lblElse.Content             = "Else";
                lblElse.Name                = "lblElse";
                lblElse.Visibility          = System.Windows.Visibility.Visible;
                lblElse.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                lblElse.Margin              = new Thickness(7);
                lblElse.SetValue(Grid.RowProperty, totalRow);
                lblElse.SetValue(Grid.ColumnProperty, 0);
                this.RegisterName("lblElse", lblElse);

                txtElse.Text        = "";
                txtElse.Name        = "txtElse";
                txtElse.Height      = 20;
                txtElse.Width       = 120;
                txtElse.BorderBrush = System.Windows.Media.Brushes.SteelBlue;
                txtElse.Visibility  = System.Windows.Visibility.Visible;
                txtElse.Margin      = new Thickness(0, 0, 5, 5);
                txtElse.SetValue(Grid.RowProperty, totalRow);
                txtElse.SetValue(Grid.ColumnProperty, 1);
                this.RegisterName("txtElse", txtElse);

                this.computedGrid.Children.Add(lblElse);
                this.computedGrid.Children.Add(txtElse);

                AddCompCol.SetValue(Grid.RowProperty, totalRow + 2);

                totalCaseCondition = totalCaseCondition - 1;
            }
        }