private void FillTable()
 {
     if (SelectTreeViewItem == null)
     {
         return;
     }
     Table = ConnectBL.GetData($"Select * from [dic].[{SelectTreeViewItem.Name}]");
     ViewDictionary.DataSource = Table;
 }
예제 #2
0
        //TODO:Не могу придумать returns
        /// <summary>
        /// Заполнение Dictionary из Базы как Key=ID, Value=Name
        /// </summary>
        /// <param name="_sql">Запрос из которого заполняется заполнение Dictionary  Key=ID, Value=Name</param>
        /// <returns>  </returns>
        private List <NameAndIdTableBL> FillDictionary(string _sql)
        {
            var table = ConnectBL.GetData(_sql).DefaultView;


            List <NameAndIdTableBL> dictionary = new List <NameAndIdTableBL>();

            foreach (DataRowView item in table)
            {
                dictionary.Add(new NameAndIdTableBL((int)item.Row["ID"], (string)item.Row["Name"]));
            }
            return(dictionary);
        }
예제 #3
0
 private void AddPrinter_Loaded(object sender, RoutedEventArgs e)
 {
     AddType.ItemsSource           = ConnectBL.GetData("Select * from dic.Type").DefaultView;
     AddType.DisplayMemberPath     = "Name";
     AddModel.ItemsSource          = ConnectBL.GetData($"select * from dic.[Model]").DefaultView;
     AddModel.DisplayMemberPath    = "Name";
     AddSP.ItemsSource             = ConnectBL.GetData($"select ID, 'RegNum=' + [RegisterNumber] + '; Deal=' + [Deal] + '; Page=' + [Page] as [Name] from dic.[Sp_Si] where [IsSp] = 1").DefaultView;
     AddSP.DisplayMemberPath       = "Name";
     AddSI.ItemsSource             = ConnectBL.GetData($"select ID, 'RegNum=' + [RegisterNumber] + '; Deal=' + [Deal] + '; Page=' + [Page] as [Name] from dic.[Sp_Si] where [IsSp] = 0").DefaultView;
     AddSI.DisplayMemberPath       = "Name";
     AddLocation.ItemsSource       = ConnectBL.GetData($"select * from [dic].[Location]").DefaultView;
     AddLocation.DisplayMemberPath = "Name";
 }
        private void DictionaryType_Loaded(object sender, RoutedEventArgs e)
        {
            var data = ConnectBL.GetData("exec [dbo].[GetNameTableDevice]").Rows;

            foreach (DataRow item in data)
            {
                GadgetName.Items.Add(item[0]);
            }

            GadgetName.SelectedItem = DR["GadgetName"].ToString();
            TypeName.Text           = DR["Name"].ToString();
            if (DR["ID"] != DBNull.Value)
            {
                Add.Content = "Изменить";
            }
        }
        private void DictionaryType_Loaded(object sender, RoutedEventArgs e)
        {
            TypeName.ItemsSource       = ConnectBL.GetData("select * from [dic].[Type]").DefaultView;
            TypeName.DisplayMemberPath = "Name";

            //TODO:надо как-то переделать выбор типа по id типа
            var typeID = (int)DR["TypeID"];

            ((DataView)TypeName.ItemsSource).RowFilter = $"ID={typeID}";
            var findItem = ((DataView)TypeName.ItemsSource)[0];

            ((DataView)TypeName.ItemsSource).RowFilter = $"";
            TypeName.SelectedItem = findItem;


            ModelName.Text = DR["Name"].ToString();
            if (DR["ID"] != DBNull.Value)
            {
                Add.Content = "Изменить";
            }
        }
예제 #6
0
        /// <summary>
        /// Метод, выполняющий SQL инструкцию, и применяющий фильтры на выводимые столбцы
        /// </summary>
        /// <param name="_sql">Запрос sql</param>
        /// <param name="_dataGridView"> В какой DataGridView будет записаны данные с запроса </param>
        private void ButtonExecuteSQL(string _sql, DataGridView _dataGridView)
        {
            var table = ConnectBL.GetData(_sql).DefaultView;

            _dataGridView.DataSource = table;

            if (_dataGridView == commonDataGridView || _dataGridView == deviceDataGridView)
            {
                _dataGridView.Columns["TypeID"].Visible     = false;
                _dataGridView.Columns["ModelID"].Visible    = false;
                _dataGridView.Columns["LocationID"].Visible = false;
                _dataGridView.Columns["SPID"].Visible       = false;
                _dataGridView.Columns["SIID"].Visible       = false;

                foreach (System.Windows.Forms.DataGridViewRow item in _dataGridView.Rows)
                {
                    Grid_Filter(item, "TypeID", ComboBoxType, _dataGridView);
                    Grid_Filter(item, "ModelID", ComboBoxModel, _dataGridView);
                    Grid_Filter(item, "LocationID", ComboBoxLocation, _dataGridView);
                    Grid_Filter(item, "IsZip", ComboBoxIsZip, _dataGridView);
                    item.ReadOnly = true;
                }
            }
        }