private void btnCompanyCreate_Click(object sender, EventArgs e) { try { String tempId = txtCompanyId.Text; tempId = tempId.Trim(); if (String.IsNullOrEmpty(tempId)) { lblresponse.Text = "Id box is empty"; return; } Registered_Company rc = new Registered_Company(); rc.RegComp_Id = Int32.Parse(tempId); rc.Name = txtCompanyName.Text; rc.BranschId = Int32.Parse(cmbCompanyBranch.SelectedItem.ToString()); if (rc.BranschId < 0) { lblresponse.Text = "Id is less than 0"; return; } if (String.IsNullOrEmpty(rc.Name)) { lblresponse.Text = "You need to write a name"; return; } bool success = CompanyController.CreateRegistered_Company(rc); if (success) { lblresponse.Text = "Company Created"; } else { lblresponse.Text = "Failed to create company"; } } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } FillListWithAllCompanies(); }