public comboboxdata Create(comboboxdata newcomboboxdata)
 {
     using (var db = new VSMSContext())
     {
         db.comboboxdatas.Add(newcomboboxdata);
         db.SaveChanges();
     }
     return(newcomboboxdata);
 }
Beispiel #2
0
 private void AddButton_Click(object sender, EventArgs e)
 {
     try {
         if (string.IsNullOrEmpty(newManufacturarTextBox.Text) || string.IsNullOrEmpty(newModelTextBox.Text))
         {
             MessageBox.Show("Insufficient Information \n Please Fill-up Both Model & Manufacturer", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             var modelregister = new comboboxdata
             {
                 vehiclebrand        = newModelTextBox.Text.Trim(),
                 vehiclemanufacturar = newManufacturarTextBox.Text.Trim()
             };
             _repousr1.Create(modelregister);
             MessageBox.Show("New Model & Manufacturar Added to the Database !!");
             this.Hide();
         }
     }
     catch {
         MessageBox.Show("Model or Manufacturer already exists in Database, \n Please Choose another model or manufacturar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }