private void SavePerson() { person.ResetValidationError(); person.Name = txtName.Text.Trim(); person.Address = txtAddress.Text.Trim(); person.Mobile = txtMobile.Text.Trim(); person.Email = txtEmail.Text.Trim(); person.Remarks = txtRemarks.Text.Trim(); person.Validate(); if (person.EntityState.State != ValidationState.SUCCESS) { MessageBox.Show(person.EntityState.StateMessage, "Error"); return; } if (_personType == PersonBase.DEALER) { if (SharedRepo.DBRepo.DoesDealerNameExists((Dealer)person)) { MessageBox.Show("Dealer name already exists", "Error"); return; } SharedRepo.DBRepo.SaveDealer((Dealer)person); } else { if (SharedRepo.DBRepo.DoesCustomerNameExists((Customer)person)) { MessageBox.Show("Customer name already exists", "Error"); return; } SharedRepo.DBRepo.SaveCustomer((Customer)person); } if (CallerForm == null && CallerForm.Name == null) { return; } else if (CallerForm.Name == "PersonListForm") { ((PersonListForm)CallerForm).LoadPersonList(); } Close(); }