예제 #1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            AddComputerForm addForm = new AddComputerForm();

            addForm.ShowDialog();
            if (addForm.DialogResult == DialogResult.OK)
            {
                string computerName = addForm.ComputerName;
                AddComputer(computerName);
                ShowComputers();
            }
        }
예제 #2
0
 private void EditButton_Click(object sender, EventArgs e)
 {
     if (ComputersDataGrid.CurrentCell != null)
     {
         int             index        = ComputersDataGrid.CurrentCell.RowIndex;
         string          computerName = Convert.ToString(ComputersDataGrid[1, index].Value);
         AddComputerForm editForm     = new AddComputerForm {
             ComputerName = computerName
         };
         editForm.ShowDialog();
         if (editForm.DialogResult == DialogResult.OK)
         {
             int ID = Convert.ToInt32(ComputersDataGrid[0, index].Value);
             computerName = editForm.ComputerName;
             EditComputer(ID, computerName);
             ShowComputers();
         }
     }
     else
     {
         MessageBox.Show("Не выбрана запись для редактирования!", "Ошибка!", MessageBoxButtons.OK);
     }
 }