Пример #1
0
        public void zeichneGrid(string tabName, string csvTabFeldnamen, string csvTabFeldtypen)
        {
            _tabName         = tabName;
            _csvTabFeldnamen = csvTabFeldnamen;
            _csvTabFeldtypen = csvTabFeldtypen;
            _csvTabFeldwerte = "";

            string[] csvFeldnamen = new string[] { };
            string[] csvFeldtypen = new string[] { };

            if (!_csvTabFeldnamen.Equals(""))
            {
                csvFeldnamen = _csvTabFeldnamen.Split(';');
                csvFeldtypen = _csvTabFeldtypen.Split(';');
            }

            this.grdMain.Children.Clear();
            this.grdMain.RowDefinitions.Clear();
            this.grdMain.ColumnDefinitions.Clear();
            //Überschrift generieren
            TextBlock txtBlock1 = new TextBlock();

            txtBlock1.FontSize          = 14;
            txtBlock1.FontWeight        = FontWeights.Bold;
            txtBlock1.Text              = Dateiname;
            txtBlock1.Margin            = new Thickness(5, 0, 0, 0);
            txtBlock1.Foreground        = new SolidColorBrush(Colors.Black);
            txtBlock1.VerticalAlignment = VerticalAlignment.Top;

            //Überschrift setzen
            RowDefinition gridRow = new RowDefinition();

            gridRow.Height = new GridLength(30);
            grdMain.RowDefinitions.Add(gridRow);
            Grid.SetRow(txtBlock1, 0);
            grdMain.Children.Add(txtBlock1);

            ColumnDefinition cL1 = new ColumnDefinition();

            cL1.Width = new GridLength(150);
            grdMain.ColumnDefinitions.Add(cL1);
            ColumnDefinition cR1 = new ColumnDefinition();

            cR1.Width = new GridLength(350);
            Grid.SetColumnSpan(txtBlock1, 2);
            grdMain.ColumnDefinitions.Add(cR1);


            if (!csvFeldnamen.ElementAt(0).Equals(""))
            {
                for (int i = 0; i < csvFeldnamen.Length; i++)
                {
                    ColumnDefinition cL = new ColumnDefinition();
                    cL.Width = new GridLength(150);
                    grdMain.ColumnDefinitions.Add(cL);
                    ColumnDefinition cR = new ColumnDefinition();
                    cR.Width = new GridLength(350);
                    grdMain.ColumnDefinitions.Add(cR);

                    RowDefinition gR = new RowDefinition();
                    gR.Height = new GridLength(30);
                    grdMain.RowDefinitions.Add(gR);

                    TextBlock tbLabel = new TextBlock();

                    tbLabel.Text = (csvFeldnamen.ElementAt(i).Length > 2 && csvFeldnamen.ElementAt(i).Substring(0, 3).Equals("_x_") ? csvFeldnamen.ElementAt(i).Split('_')[2] : csvFeldnamen.ElementAt(i)) + " (" + csvFeldtypen.ElementAt(i).Substring(0, 3) + ")";

                    tbLabel.Tag                 = csvFeldnamen.ElementAt(i);
                    tbLabel.Width               = 150;
                    tbLabel.Height              = 30;
                    tbLabel.Margin              = new Thickness(5, 0, 0, 0);
                    tbLabel.Foreground          = new SolidColorBrush(Colors.Black);
                    tbLabel.VerticalAlignment   = VerticalAlignment.Top;
                    tbLabel.HorizontalAlignment = HorizontalAlignment.Left;
                    Grid.SetColumn(tbLabel, 0);
                    Grid.SetRow(tbLabel, (i + 1));
                    grdMain.Children.Add(tbLabel);

                    if (csvFeldtypen[i].Substring(0, 3).Equals("bol"))
                    {
                        CheckBox tb = new CheckBox();
                        tb.Name                = "Wert" + i;
                        tb.Width               = 20;
                        tb.Height              = 20;
                        tb.VerticalAlignment   = VerticalAlignment.Top;
                        tb.HorizontalAlignment = HorizontalAlignment.Left;
                        Grid.SetColumn(tb, 1);
                        Grid.SetRow(tb, (i + 1));
                        grdMain.Children.Add(tb);
                    }
                    else if (csvFeldtypen[i].Substring(0, 3).Equals("loo"))
                    {
                        LookupAuswahlDMS tb = new LookupAuswahlDMS(_tabName, _csvTabFeldnamen, _csvTabFeldnamen);
                        tb.Tag                          = csvFeldnamen.ElementAt(i).Split('_')[3];
                        tb.cboAuswahl.Tag               = tb;
                        tb.cboAuswahl.Name              = csvFeldnamen.ElementAt(i);
                        tb.cboAuswahl.SelectionChanged += CboAuswahl_SelectionChanged;
                        tb.Fill(csvFeldnamen.ElementAt(i));
                        tb.VerticalAlignment   = VerticalAlignment.Top;
                        tb.HorizontalAlignment = HorizontalAlignment.Left;
                        Grid.SetColumn(tb, 1);
                        Grid.SetRow(tb, (i + 1));
                        grdMain.Children.Add(tb);
                    }
                    else
                    {
                        TextBox tb = new TextBox();
                        tb.Name     = "Wert" + i;
                        tb.MinWidth = 250;
                        tb.MaxWidth = 250;
                        tb.Height   = 20;
                        //Datepicker falls benötigt
                        DatePicker dp = new DatePicker();
                        dp.Name   = "Wert" + i;
                        dp.Width  = 200;
                        dp.Height = 25;
                        //Verschiedene Eventhandler für die Feldtypen setzen
                        if (csvFeldtypen[i].Substring(0, 3).Equals("dat"))
                        {
                            //Wenn es sich um ein Datum handelt, muss ein Datepicker hinzugefügt werden
                            dp.VerticalAlignment   = VerticalAlignment.Top;
                            dp.HorizontalAlignment = HorizontalAlignment.Left;
                            Grid.SetColumn(dp, 1);
                            Grid.SetRow(dp, (i + 1));
                            grdMain.Children.Add(dp);
                        }
                        else
                        {
                            if (csvFeldtypen[i].Substring(0, 3).Equals("dec"))
                            {
                                tb.TextChanged += Tb_TextChangedDec;
                            }
                            else if (csvFeldtypen[i].Substring(0, 3).Equals("int"))
                            {
                                tb.TextChanged += Tb_TextChangedInt;
                            }
                            else if (csvFeldtypen[i].Substring(0, 3).Equals("txt"))
                            {
                                if (csvFeldtypen[i].Equals("txt50n"))
                                {
                                    tb.TextChanged += Tb_TextChangedTxt50;
                                }
                                if (csvFeldtypen[i].Equals("txt255n"))
                                {
                                    tb.TextChanged += Tb_TextChangedTxt255;
                                    tb.TextWrapping = TextWrapping.Wrap;
                                    tb.Height       = 75;
                                    grdMain.RowDefinitions[i + 1].Height = new GridLength(80);
                                }
                                if (csvFeldtypen[i].Equals("txtmn"))
                                {
                                    tb.TextChanged += Tb_TextChangedTxtm;
                                    tb.TextWrapping = TextWrapping.Wrap;
                                    tb.Height       = 115;
                                    grdMain.RowDefinitions[i + 1].Height = new GridLength(120);
                                }
                            }

                            tb.VerticalAlignment   = VerticalAlignment.Top;
                            tb.HorizontalAlignment = HorizontalAlignment.Left;
                            Grid.SetColumn(tb, 1);
                            Grid.SetRow(tb, (i + 1));
                            grdMain.Children.Add(tb);
                        }
                    }
                }
            }
        }
Пример #2
0
        public void zeichneGrid(string tabName, string csvTabFeldnamen, string csvTabFeldtypen, string csvTabFeldwerte)
        {
            //btnSpeichern.Content = "Sichern";
            _tabName         = tabName;
            _csvTabFeldnamen = csvTabFeldnamen;
            _csvTabFeldtypen = csvTabFeldtypen;
            _csvTabFeldwerte = csvTabFeldwerte;

            var csvFeldnamen = csvTabFeldnamen.Split(';');
            var csvFeldtypen = csvTabFeldtypen.Split(';');
            var csvFeldwerte = csvTabFeldwerte.Split(';');

            this.grdMain.Children.Clear();
            this.grdMain.RowDefinitions.Clear();
            this.grdMain.ColumnDefinitions.Clear();
            //Überschrift generieren
            TextBlock txtBlock1 = new TextBlock();

            txtBlock1.FontSize          = 14;
            txtBlock1.FontWeight        = FontWeights.Bold;
            txtBlock1.Text              = Dateiname;
            txtBlock1.Margin            = new Thickness(5, 0, 0, 0);
            txtBlock1.Foreground        = new SolidColorBrush(Colors.Black);
            txtBlock1.VerticalAlignment = VerticalAlignment.Top;

            //Überschrift setzen
            RowDefinition gridRow = new RowDefinition();

            gridRow.Height = new GridLength(30);
            grdMain.RowDefinitions.Add(gridRow);
            Grid.SetRow(txtBlock1, 0);
            grdMain.Children.Add(txtBlock1);

            ColumnDefinition cL1 = new ColumnDefinition();

            cL1.Width = new GridLength(150);
            grdMain.ColumnDefinitions.Add(cL1);
            ColumnDefinition cR1 = new ColumnDefinition();

            cR1.Width = new GridLength(350);
            Grid.SetColumnSpan(txtBlock1, 2);
            grdMain.ColumnDefinitions.Add(cR1);

            for (int i = 0; i < csvFeldnamen.Length; i++)
            {
                ColumnDefinition cL = new ColumnDefinition();
                cL.Width = new GridLength(150);
                grdMain.ColumnDefinitions.Add(cL);
                ColumnDefinition cR = new ColumnDefinition();
                cR.Width = new GridLength(350);
                grdMain.ColumnDefinitions.Add(cR);

                RowDefinition gR = new RowDefinition();
                gR.Height = new GridLength(30);
                grdMain.RowDefinitions.Add(gR);

                TextBlock tbLabel = new TextBlock();
                tbLabel.Text                = (csvFeldnamen.ElementAt(i).Length > 2 && csvFeldnamen.ElementAt(i).Substring(0, 3).Equals("_x_") ? csvFeldnamen.ElementAt(i).Split('_')[2] : csvFeldnamen.ElementAt(i)) + " (" + csvFeldtypen.ElementAt(i).Substring(0, 3) + ")";
                tbLabel.Tag                 = csvFeldnamen.ElementAt(i);
                tbLabel.Width               = 150;
                tbLabel.Height              = 30;
                tbLabel.Margin              = new Thickness(5, 0, 0, 0);
                tbLabel.Foreground          = new SolidColorBrush(Colors.Black);
                tbLabel.VerticalAlignment   = VerticalAlignment.Top;
                tbLabel.HorizontalAlignment = HorizontalAlignment.Left;
                Grid.SetColumn(tbLabel, 0);
                Grid.SetRow(tbLabel, (i + 1));
                grdMain.Children.Add(tbLabel);
                if (csvFeldtypen[i].Substring(0, 3).Equals("bol"))
                {
                    CheckBox tb = new CheckBox();
                    tb.Name   = "Wert" + i;
                    tb.Width  = 20;
                    tb.Height = 20;
                    var test = csvFeldwerte.ElementAt(i).ToString();
                    tb.IsChecked           = csvFeldwerte.ElementAt(i).ToString().Equals("True");
                    tb.VerticalAlignment   = VerticalAlignment.Top;
                    tb.HorizontalAlignment = HorizontalAlignment.Left;
                    Grid.SetColumn(tb, 1);
                    Grid.SetRow(tb, (i + 1));
                    grdMain.Children.Add(tb);
                }
                else if (csvFeldtypen[i].Substring(0, 3).Equals("loo"))
                {
                    LookupAuswahlDMS tb = new LookupAuswahlDMS(_tabName, _csvTabFeldnamen, _csvTabFeldtypen);
                    tb.Tag                          = csvFeldnamen.ElementAt(i).Split('_')[3];
                    tb.cboAuswahl.Tag               = tb;
                    tb.cboAuswahl.Name              = csvFeldnamen.ElementAt(i);
                    tb.cboAuswahl.SelectionChanged += CboAuswahl_SelectionChanged;
                    tb.Fill(csvFeldnamen.ElementAt(i));
                    Tuple <List <int>, List <object> > tuple = ((DbConnector)App.Current.Properties["Connector"]).ReadComboboxItems(csvFeldnamen.ElementAt(i).Split('_')[3], csvFeldnamen.ElementAt(i).Split('_')[4]);
                    if (!csvFeldwerte.ElementAt(i).ToString().Equals(""))
                    {
                        //Im Tuple sind die Bezeichnungen, ich brauch hier die id

                        //int position = tuple.Item1.IndexOf(Int32.Parse(csvFeldwerte.ElementAt(i).ToString()));
                        int position = tuple.Item2.IndexOf(csvFeldwerte.ElementAt(i).ToString());
                        tb.cboAuswahl.SelectedIndex = position;
                    }

                    tb.VerticalAlignment   = VerticalAlignment.Top;
                    tb.HorizontalAlignment = HorizontalAlignment.Left;
                    Grid.SetColumn(tb, 1);
                    Grid.SetRow(tb, (i + 1));
                    grdMain.Children.Add(tb);
                }
                else
                {
                    //Textbox erstellen
                    TextBox tb = new TextBox();
                    tb.Name     = "Wert" + i;
                    tb.Width    = 250;
                    tb.MaxWidth = 250;
                    tb.Height   = 20;

                    //Datepicker falls benötigt
                    DatePicker dp = new DatePicker();
                    dp.Name   = "Wert" + i;
                    dp.Width  = 200;
                    dp.Height = 25;

                    //Verschiedene Eventhandler für die Feldtypen setzen
                    if (csvFeldtypen[i].Substring(0, 3).Equals("dat"))
                    {
                        //Hat sich erledigt, ist jetzt Datepicker
                        //tb.TextChanged += Tb_TextChangedDat;
                        //tb.MaxLength = 10;
                    }
                    else if (csvFeldtypen[i].Substring(0, 3).Equals("dec"))
                    {
                        tb.TextChanged += Tb_TextChangedDec;
                    }
                    else if (csvFeldtypen[i].Substring(0, 3).Equals("int"))
                    {
                        tb.TextChanged += Tb_TextChangedInt;
                    }
                    else if (csvFeldtypen[i].Substring(0, 3).Equals("txt"))
                    {
                        if (csvFeldtypen[i].Equals("txt50n"))
                        {
                            tb.TextChanged += Tb_TextChangedTxt50;
                        }
                        if (csvFeldtypen[i].Equals("txt255n"))
                        {
                            tb.TextChanged += Tb_TextChangedTxt255;
                            tb.TextWrapping = TextWrapping.Wrap;
                            tb.Height       = 75;
                            grdMain.RowDefinitions[i + 1].Height = new GridLength(80);
                        }
                        if (csvFeldtypen[i].Equals("txtmn"))
                        {
                            tb.TextChanged += Tb_TextChangedTxtm;
                            tb.TextWrapping = TextWrapping.Wrap;
                            tb.Height       = 115;
                            grdMain.RowDefinitions[i + 1].Height = new GridLength(120);
                        }
                    }
                    if (csvFeldtypen[i].Substring(0, 3).Equals("dat"))
                    {
                        if (csvFeldwerte.ElementAt(i).ToString().Length > 10)
                        {
                            int tag   = Int32.Parse(csvFeldwerte.ElementAt(i).ToString().Substring(0, 2));
                            int monat = Int32.Parse(csvFeldwerte.ElementAt(i).ToString().Substring(3, 2));
                            int jahr  = Int32.Parse(csvFeldwerte.ElementAt(i).ToString().Substring(6, 4));
                            dp.SelectedDate = new DateTime(jahr, monat, tag);
                        }
                        dp.VerticalAlignment   = VerticalAlignment.Top;
                        dp.HorizontalAlignment = HorizontalAlignment.Left;
                        Grid.SetColumn(dp, 1);
                        Grid.SetRow(dp, (i + 1));
                        grdMain.Children.Add(dp);
                    }
                    else
                    {
                        tb.Text = csvFeldwerte.ElementAt(i).ToString();
                        tb.VerticalAlignment   = VerticalAlignment.Top;
                        tb.HorizontalAlignment = HorizontalAlignment.Left;
                        Grid.SetColumn(tb, 1);
                        Grid.SetRow(tb, (i + 1));
                        grdMain.Children.Add(tb);
                    }
                }
            }
        }