private void LoadData()
 {
     try
     {
         var list = softwareLogic.Read(null);
         if (list != null)
         {
             dataGridView.DataSource         = list;
             dataGridView.Columns[0].Visible = false;
             dataGridView.Columns[1].Width   = 410;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void FormEquipmentSoftwareCreateUpd_Load(object sender, EventArgs e)
        {
            try
            {
                List <EquipmentViewModel> listEquipment = equipmentLogic.Read(null);
                List <SoftwareViewModel>  listSoftware  = softwareLogic.Read(null);

                if (listEquipment != null)
                {
                    comboBoxEquipment.DisplayMember = "Name";
                    comboBoxEquipment.ValueMember   = "Id";
                    comboBoxEquipment.DataSource    = listEquipment;
                    comboBoxEquipment.SelectedItem  = null;
                }

                if (listSoftware != null)
                {
                    comboBoxSoft.DisplayMember = "Name";
                    comboBoxSoft.ValueMember   = "Id";
                    comboBoxSoft.DataSource    = listSoftware;
                    comboBoxSoft.SelectedItem  = null;
                }

                if (id.HasValue)
                {
                    try
                    {
                        EquipmentSoftwareViewModel view = eqSoftLogic.Read(new EquipmentSoftwareBindingModel {
                            Id = id.Value
                        })?[0];

                        if (view != null)
                        {
                            comboBoxEquipment.SelectedValue = view.EquipmentId;
                            comboBoxSoft.SelectedValue      = view.SoftwareId;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void FormSoftwareCreateUpd_Load(object sender, EventArgs e)
        {
            if (id.HasValue)
            {
                try
                {
                    SoftwareViewModel view = softwareLogic.Read(new SoftwareBindingModel {
                        Id = id.Value
                    })?[0];

                    if (view != null)
                    {
                        textBoxName.Text    = view.Name;
                        textBoxLicense.Text = view.License_type;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }