Пример #1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            var verification = Verification();

            if (SpecificDevice != null)
            {
                verification.AddRange(SpecificDevice.Verification());
                if (verification.Count == 0)
                {
                    var sqlParameters = GetSqlParameters();
                    sqlParameters.AddRange(SpecificDevice.GetSqlParameters());

                    string gadgetName = ((DataRowView)AddType.SelectedItem).Row["GadgetName"].ToString();
                    string exeption   = ConnectBL.ExecuteProcedure($"[dev].[Add_{gadgetName}]", sqlParameters.ToArray());
                    if (exeption != null)
                    {
                        MessageBox.Show(exeption, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    Close();
                    return;
                }
            }
            string str = "";

            foreach (var item in verification)
            {
                str += item + "\n";
            }
            MessageBox.Show(str, "Внимание!Неправильно заполнены поля!", MessageBoxButton.OK, MessageBoxImage.Warning);
        }
Пример #2
0
        public void ConnectOpen_IsOpen_True()
        {
            ConnectBL.NameConnectionString = "Test";

            ConnectBL.ConnectOpen();

            Assert.IsTrue(ConnectBL._IsOpen, $"Это успешное соединение поэтому IsOpen должно быть true, а у нас [{ConnectBL._IsOpen}].");
        }
 private void FillTable()
 {
     if (SelectTreeViewItem == null)
     {
         return;
     }
     Table = ConnectBL.GetData($"Select * from [dic].[{SelectTreeViewItem.Name}]");
     ViewDictionary.DataSource = Table;
 }
Пример #4
0
        public void ConnectOpen_resultConnection_ConnectComplited()
        {
            //arrange
            string res = "Подключение установлено \nDatabase:Test_Action \n";

            //act
            ConnectBL.NameConnectionString = "Test";
            ConnectBL.ConnectOpen();
            //assert
            Assert.AreEqual(ConnectBL._resultConnection, res, $"Наше значение _resultConnection = [{ConnectBL._resultConnection}], а должно быть [{res}]. Это успешное соединение!!!");
        }
Пример #5
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);
        }
Пример #6
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 = "Изменить";
            }
        }
Пример #8
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string exeption;

            if (DR["ID"] == DBNull.Value)
            {
                exeption = ConnectBL.ExecAction($"INSERT INTO [dic].[Location] ([Name]) VALUES (N'{LocationName.Text}')");
            }
            else
            {
                exeption = ConnectBL.ExecAction($"Update [dic].[Location] set [Name] = N'{LocationName.Text}' where ID = {DR["ID"]}");
            }
            if (exeption != null)
            {
                MessageBox.Show(exeption, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            DialogResult = true;
            Close();
        }
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string exeption;
            bool   isSp = TypeCheckName.SelectedItem.Equals("СП");

            if (DR["ID"] == DBNull.Value)
            {
                exeption = ConnectBL.ExecAction($"INSERT INTO [dic].[Sp_Si] ([RegisterNumber],[Deal],[Page],[IsSp]) VALUES (N'{RegisterNumberName.Text}',N'{DealName.Text}',N'{PageName.Text}',{isSp.ToString().ToLower()})");
            }
            else
            {
                exeption = ConnectBL.ExecAction($"Update [dic].[Sp_Si] set [RegisterNumber] = N'{RegisterNumberName.Text}', [Deal] = N'{DealName.Text}', [Page] = N'{PageName.Text}', [IsSp] = '{isSp.ToString().ToLower()}' where ID = {DR["ID"]}");
            }
            if (exeption != null)
            {
                MessageBox.Show(exeption, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            DialogResult = true;
            Close();
        }
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string exeption;
            var    typeId = ((DataRowView)TypeName.SelectedItem).Row["ID"];

            if (DR["ID"] == DBNull.Value)
            {
                exeption = ConnectBL.ExecAction($"INSERT INTO [dic].[Model] ([TypeId],[Name]) VALUES ({typeId},N'{ModelName.Text}')");
            }
            else
            {
                exeption = ConnectBL.ExecAction($"Update [dic].[Model] set [TypeId] = {typeId}, [Name] = N'{ModelName.Text}' where ID = {DR["ID"]}");
            }
            if (exeption != null)
            {
                MessageBox.Show(exeption, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            DialogResult = true;
            Close();
        }
        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 = "Изменить";
            }
        }
Пример #12
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;
                }
            }
        }
Пример #13
0
 /// <summary>
 /// Просто закрывает соединение
 /// </summary>
 public void CloseConnected()
 {
     ConnectBL.ConnectClose();
 }
Пример #14
0
 /// <summary>
 /// Открывает соединение с SQL, и если удалось выводит true
 /// </summary>
 /// <returns>Если соединение открылось вывод true, иначе false</returns>
 public bool OpenConnected()
 {
     ConnectBL.ConnectOpen();
     ResultConnect = ConnectBL._resultConnection;
     return(ConnectBL._IsOpen);
 }