예제 #1
0
        private void btnTechnicianModify_Click(object sender, EventArgs e)
        {
            try
            {
                int            i        = lstTechnician.SelectedIndex;
                TechnicianForm techForm = new TechnicianForm();

                if (i != -1)
                {
                    Technician technician = techs[i];
                    techForm.SetTechFormFields(technician);
                    technician.ID    = 0;
                    technician.Name  = null;
                    technician.Email = null;
                    technician.Phone = null;
                    MessageBox.Show("Modify the record and click save !");
                    FillTechnicianListBox();
                    technician = techForm.GetNewTechnician();
                    if (technician != null)
                    {
                        if (TechnicianDB.AddTechnician(technician))
                        {
                            MessageBox.Show("Technician added successfully !");
                            FillTechnicianListBox();
                        }
                        else
                        {
                            MessageBox.Show("Failed to add Technician");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
예제 #2
0
 private void btnTechnicianAdd_Click(object sender, EventArgs e)
 {
     try
     {
         TechnicianForm tech = new TechnicianForm();
         Technician     t    = tech.GetNewTechnician();
         if (t != null)
         {
             if (TechnicianDB.AddTechnician(t))
             {
                 MessageBox.Show("Technician added successfully !");
                 FillTechnicianListBox();
             }
             else
             {
                 MessageBox.Show("Failed to add Technician");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error");
     }
 }