コード例 #1
0
        public DeviceNetworksWindow(NetworkBaseEntities db, DeviceNetworks deviceNetworks)
        {
            InitializeComponent();

            uNetwork = deviceNetworks;
            entities = db;
            insertButton.IsEnabled = false;
            updateButton.IsEnabled = true;
            numberBox.IsReadOnly   = true;
            ShowData();
        }
コード例 #2
0
        /// <summary>
        /// Удаление сетей устройства
        /// </summary>
        private void DeleteDeviceNetworks()
        {
            try
            {
                DeviceNetworks network  = tablesGrid.SelectedItem as DeviceNetworks;
                var            dNetwork = db.DeviceNetworks.Where(n => n.networkID == network.networkID && n.deviceID == network.deviceID).FirstOrDefault();


                db.DeviceNetworks.Remove(dNetwork);
                db.SaveChanges();
            }
            catch
            {
                MessageBox.Show("Ошибка удаления данных из базы");
            }
        }
コード例 #3
0
        private void InsertButton_Click(object sender, RoutedEventArgs e)
        {
            if (CheckInput())
            {
                try
                {
                    DeviceNetworks network = new DeviceNetworks();

                    network.Number    = Int32.Parse(numberBox.Text);
                    network.deviceID  = Int32.Parse(deviceID.Text);
                    network.networkID = Int32.Parse(networkID.Text);

                    entities.DeviceNetworks.Add(network);
                    entities.SaveChanges();

                    this.Close();
                }
                catch
                {
                    MessageBox.Show("Ошибка добавления данных в базу.");
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Реализация Update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            //Устройства
            if (shownTable == Table.device)
            {
                Devices device  = tablesGrid.SelectedItem as Devices;
                var     uDevice = db.Devices.Where(d => d.deviceID == device.deviceID).FirstOrDefault();

                DevicesWin window = new DevicesWin(db, uDevice);

                window.ShowDialog();

                SelectDevices();
            }

            //Отделы
            if (shownTable == Table.department)
            {
                Departments department  = tablesGrid.SelectedItem as Departments;
                var         udepartment = db.Departments.Where(d => d.departmentID == department.departmentID).FirstOrDefault();

                DepartmentWindow window = new DepartmentWindow(db, udepartment);

                window.ShowDialog();

                SelectDeparments();
            }

            //Пользователи
            if (shownTable == Table.user)
            {
                Users user  = tablesGrid.SelectedItem as Users;
                var   uUser = db.Users.Where(u => u.userID == user.userID).FirstOrDefault();

                UsersWindow window = new UsersWindow(db, uUser);

                window.ShowDialog();

                SelectUsers();
            }

            //Сети устройства
            if (shownTable == Table.deviceNateworks)
            {
                DeviceNetworks network  = tablesGrid.SelectedItem as DeviceNetworks;
                var            uNetwork = db.DeviceNetworks.Where(n => n.networkID == network.networkID && n.deviceID == network.deviceID).FirstOrDefault();

                DeviceNetworksWindow window = new DeviceNetworksWindow(db, uNetwork);

                window.ShowDialog();

                SelectDeviceNetworks();
            }

            //Сети
            if (shownTable == Table.network)
            {
                Networks network  = tablesGrid.SelectedItem as Networks;
                var      uNetwork = db.Networks.Where(n => n.networkID == network.networkID).FirstOrDefault();

                NetworksWindow window = new NetworksWindow(db, uNetwork);

                window.ShowDialog();

                SelectNetworks();
            }
        }