Пример #1
0
        private void Button_Click_Redagavimas(object sender, RoutedEventArgs e)
        {
            Redagavimas red = new Redagavimas();

            this.NavigationService.Navigate(red);
        }
Пример #2
0
        public void createRow()
        {
            ComboBox cbOne = new ComboBox();

            using (StreamReader sr = new StreamReader(System.AppDomain.CurrentDomain.BaseDirectory + "Kabinetai.txt"))
            {
                String[] line = sr.ReadToEnd().Split(';');
                foreach (String ln in line)
                {
                    cbOne.Items.Add(ln);
                }
            }


            int count = 0;

            using (var context = new PrincipalContext(ContextType.Domain, "TEISMAS.AD"))
            {
                using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
                {
                    foreach (var result in searcher.FindAll())
                    {
                        count++;
                        DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry;
                        //Debug.WriteLine("Last Name : " + de.Properties["sn"].Value);
                        //Debug.WriteLine("SAM account name   : " + de.Properties["samAccountName"].Value);
                        //Debug.WriteLine("User principal name: " + de.Properties["userPrincipalName"].Value);

                        RowDefinition gridRow1 = new RowDefinition();

                        gridRow1.Height = new GridLength(30);

                        DynamicGrid.RowDefinitions.Add(gridRow1);

                        TextBox authorText = new TextBox();

                        authorText.Text = de.Properties["samAccountName"].Value.ToString();

                        authorText.FontSize = 12;

                        authorText.FontWeight = FontWeights.Bold;

                        Grid.SetRow(authorText, count);

                        Grid.SetColumn(authorText, 0);



                        TextBox mailText = new TextBox();

                        if (de.Properties["mail"].Value == null)
                        {
                            mailText.Text = " ";
                        }

                        else
                        {
                            mailText.Text = de.Properties["mail"].Value.ToString();
                        }

                        mailText.FontSize = 12;

                        mailText.FontWeight = FontWeights.Bold;

                        Grid.SetRow(mailText, count);

                        Grid.SetColumn(mailText, 1);



                        TextBox kabText = new TextBox();

                        if (de.Properties["physicalDeliveryOfficeName"].Value == null)
                        {
                            kabText.Text = "";
                        }

                        else
                        {
                            kabText.Text = de.Properties["physicalDeliveryOfficeName"].Value.ToString();
                        }

                        kabText.FontSize = 12;

                        kabText.FontWeight = FontWeights.Bold;

                        Grid.SetRow(kabText, count);

                        Grid.SetColumn(kabText, 2);

                        Button button = new Button();

                        button.Content = "Update";

                        Grid.SetRow(button, count);
                        Grid.SetColumn(button, 4);

                        TextBox padText = new TextBox();

                        if (de.Properties["description"].Value == null)
                        {
                            padText.Text = "";
                        }

                        else
                        {
                            padText.Text = de.Properties["description"].Value.ToString();
                        }

                        padText.FontSize = 12;

                        padText.FontWeight = FontWeights.Bold;

                        Grid.SetRow(padText, count);
                        Grid.SetColumn(padText, 3);
                        // Add first row to Grid

                        button.Click += (sender, e) =>
                        {
                            if (kabText.Text.Length > 1)
                            {
                                de.Properties["physicalDeliveryOfficeName"].Value = kabText.Text;
                            }

                            else
                            {
                                de.Properties["physicalDeliveryOfficeName"].Value = " ";
                            }

                            if (mailText.Text.Length > 1)
                            {
                                de.Properties["mail"].Value = mailText.Text;
                            }

                            else
                            {
                                de.Properties["mail"].Value = " ";
                            }

                            if (padText.Text.Length > 1)
                            {
                                de.Properties["description"].Value = padText.Text;
                            }
                            else
                            {
                                de.Properties["description"].Value = " ";
                            }

                            de.CommitChanges();
                            Redagavimas redagavimas = new Redagavimas();
                            this.NavigationService.Navigate(redagavimas);
                            MessageBox.Show("Informacija pakeista sekmingai.");
                        };

                        DynamicGrid.Children.Add(authorText);

                        DynamicGrid.Children.Add(mailText);

                        DynamicGrid.Children.Add(kabText);

                        DynamicGrid.Children.Add(button);

                        DynamicGrid.Children.Add(padText);
                    }
                }
            }
        }