Exemplo n.º 1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            TsEntity db = new TsEntity();

            var supportRedactorForm = new SupportRedactorForm();

            supportRedactorForm.Text = "Добавить устройство";

            var devices     = db.devices.ToList();
            var accessories = db.device_accessories.ToList();

            FillSupportComboBoxes(devices, accessories, supportRedactorForm);

            supportRedactorForm.Show();
            supportRedactorForm.Text = "Добавить устройство";
            if (Text == "Администратор отдела МТО")
            {
                supportRedactorForm.label5.Visible             = false;
                supportRedactorForm.label6.Visible             = false;
                supportRedactorForm.label7.Visible             = false;
                supportRedactorForm.ipTextBox.Visible          = false;
                supportRedactorForm.networkNameTextBox.Visible = false;
                supportRedactorForm.subnetMaskTextBox.Visible  = false;
            }

            supportRedactorForm.FormClosed += (sen, even) =>
            {
                this.Refresh_Click(sender, e);
            };
        }
Exemplo n.º 2
0
        private void editButton_Click(object sender, EventArgs e)
        {
            var supportRedactorForm = new SupportRedactorForm();

            TsEntity db = new TsEntity();

            supportRedactorForm.nameTextBox.Enabled         = false;
            supportRedactorForm.serialNumberTextBox.Enabled = false;
            supportRedactorForm.entryDateTextBox.Enabled    = false;
            supportRedactorForm.guaranteeTextBox.Enabled    = false;
            supportRedactorForm.sellerComboBox.Enabled      = false;
            supportRedactorForm.typeComboBox.Enabled        = false;
            supportRedactorForm.globalTypeComboBox.Enabled  = false;
            supportRedactorForm.priceTextBox.Enabled        = false;



            if (devicesDGV.SelectedRows.Count == 0 && accessoriesDGV.SelectedRows.Count == 0)
            {
                MessageBox.Show(" Сначала выберите строчку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (devicesDGV.SelectedRows.Count >= 1 && accessoriesDGV.SelectedRows.Count >= 1)
            {
                MessageBox.Show(" Выбрано слишком много строк", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Text == "Администратор отдела МТО")
            {
                supportRedactorForm.label5.Visible             = false;
                supportRedactorForm.label6.Visible             = false;
                supportRedactorForm.label7.Visible             = false;
                supportRedactorForm.ipTextBox.Visible          = false;
                supportRedactorForm.networkNameTextBox.Visible = false;
                supportRedactorForm.subnetMaskTextBox.Visible  = false;
            }


            var row = devicesDGV.SelectedRows.Count > 0 ? devicesDGV.SelectedRows[0] : accessoriesDGV.SelectedRows[0];


            if (devicesDGV.SelectedRows.Count > 0)
            {
                var devices = db.devices.ToList();
                supportRedactorForm.Text                     = "Редактировать устройство";
                supportRedactorForm.nameTextBox.Text         = row.Cells["deviceName"].Value.ToString();
                supportRedactorForm.serialNumberTextBox.Text = row.Cells["serialNumber"].Value.ToString();
                supportRedactorForm.guaranteeTextBox.Text    = row.Cells["guaranteeEnd"].Value.ToString();
                supportRedactorForm.sellerComboBox.Text      = row.Cells["seller"].Value.ToString();
                supportRedactorForm.typeComboBox.Text        = row.Cells["type"].Value.ToString();
                supportRedactorForm.entryDateTextBox.Text    = row.Cells["entryDate"].Value.ToString();
                supportRedactorForm.priceTextBox.Text        = row.Cells["price"].Value.ToString();
                supportRedactorForm.placementComboBox.Text   = row.Cells["placement"].Value.ToString();
                supportRedactorForm.responsibleComboBox.Text = row.Cells["responsible"].Value.ToString();
                supportRedactorForm.globalTypeComboBox.Text  = "Устройство";
                if (Text == "Администратор отдела тестировки")
                {
                    supportRedactorForm.networkNameTextBox.Text = row.Cells["networkName"].Value.ToString();
                    supportRedactorForm.ipTextBox.Text          = row.Cells["ip"].Value.ToString();
                    supportRedactorForm.subnetMaskTextBox.Text  = row.Cells["subnetMask"].Value.ToString();
                }
                FillSupportComboBoxes(devices, null, supportRedactorForm);
            }

            if (accessoriesDGV.SelectedRows.Count > 0)
            {
                var accessories = db.device_accessories.ToList();
                supportRedactorForm.Text                       = "Редактировать комплекктующее к устройству";
                supportRedactorForm.nameTextBox.Text           = row.Cells["accessoryName"].Value.ToString();
                supportRedactorForm.serialNumberTextBox.Text   = row.Cells["serialNumber"].Value.ToString();
                supportRedactorForm.guaranteeTextBox.Text      = row.Cells["guaranteeEnd"].Value.ToString();
                supportRedactorForm.sellerComboBox.Text        = row.Cells["seller"].Value.ToString();
                supportRedactorForm.typeComboBox.Text          = row.Cells["type"].Value.ToString();
                supportRedactorForm.entryDateTextBox.Text      = row.Cells["entryDate"].Value.ToString();
                supportRedactorForm.priceTextBox.Text          = row.Cells["price"].Value.ToString();
                supportRedactorForm.placementComboBox.Text     = row.Cells["placement"].Value.ToString();
                supportRedactorForm.responsibleComboBox.Text   = row.Cells["responsible"].Value.ToString();
                supportRedactorForm.label5.Visible             = false;
                supportRedactorForm.label6.Visible             = false;
                supportRedactorForm.label7.Visible             = false;
                supportRedactorForm.ipTextBox.Visible          = false;
                supportRedactorForm.networkNameTextBox.Visible = false;
                supportRedactorForm.subnetMaskTextBox.Visible  = false;
                supportRedactorForm.globalTypeComboBox.Text    = "Комплектующее";
                FillSupportComboBoxes(null, accessories, supportRedactorForm);
            }
            supportRedactorForm.Show();

            supportRedactorForm.FormClosed += (sen, even) =>
            {
                this.Refresh_Click(sender, e);
            };
        }