コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Yvv95/DBList
 private void tableBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     //загружаем все поля выбранной таблицы
     if (tableBox.SelectedItem != null)
     {
         fieldLabel.Visibility  = Visibility.Visible;
         fieldBox.Visibility    = Visibility.Visible;
         labelBinary.Visibility = Visibility.Visible;
         binList.Visibility     = Visibility.Visible;
         string _table = tableBox.SelectedItem.ToString();
         _tableName = _table;
         string _catalog = dbListBox.SelectedItem.ToString();
         FieldsClass.ClearList();
         condGrid.Items.Refresh();
         using (SqlConnection conn = new SqlConnection(connectionBox.Text + "Initial Catalog =" + _catalog))
         {
             try
             {
                 conn.Open();
                 string[] restrictions = new string[4];
                 restrictions[2] = _table;
                 DataTable     table  = conn.GetSchema("Tables", restrictions);
                 string        sql    = "SELECT * FROM " + _table + " WHERE 1 = 0";
                 SqlCommand    cmd    = new SqlCommand(sql, conn);
                 SqlDataReader reader = cmd.ExecuteReader();
                 DataTable     schema = reader.GetSchemaTable();
                 fieldBox.Items.Clear();
                 binList.Items.Clear();
                 for (int i = 0; i < schema.Rows.Count; i++)
                 {
                     if (schema.Rows[i][0] != null)
                     {
                         FieldsClass.AddValue(schema.Rows[i][0].ToString(), "");
                         fieldBox.Items.Add(schema.Rows[i][0].ToString());
                         binList.Items.Add(schema.Rows[i][0].ToString());
                     }
                 }
             }
             catch (Exception error)
             {
                 MessageBox.Show(error.ToString());
             }
             finally
             {
                 conn.Close();
             }
         }
     }
     else
     {
         fieldLabel.Visibility  = Visibility.Hidden;
         labelBinary.Visibility = Visibility.Hidden;
         fieldBox.Visibility    = Visibility.Hidden;
         binList.Visibility     = Visibility.Hidden;
     }
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: Yvv95/DBList
 private void extraFields_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (fieldBox.SelectedItem != null)
     {
         if (!FieldsClass.IsField(fieldBox.SelectedItem.ToString()))
         {
             FieldsClass.AddValue(fieldBox.SelectedItem.ToString(), "");
         }
         UpdateWindow a = new UpdateWindow(fieldBox.SelectedItem.ToString());
         a.Show();
         a.Closed += A_Closed;//для обновления таблицы
     }
 }
コード例 #3
0
ファイル: UpdateWindow.xaml.cs プロジェクト: Yvv95/DBList
 private void saveBtn_Click(object sender, RoutedEventArgs e)
 {
     FieldsClass.AddValue(fName, fieldValue.Text);
     this.Close();
 }