private void buttonSubmit_Click(object sender, EventArgs e) { bool newCustCreated = false; var partyId = string.Empty; var custNumber = string.Empty; bool updatePhysData = false; if (isFormValid()) { getFormData(); if (string.IsNullOrEmpty(CustToView.PartyId) || physDescDataChanged()) { _strUserId = GlobalDataAccessor.Instance.DesktopSession.UserName; _strStoreNumber = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber; _strCustNumber = CustToView.CustomerNumber; DateTime noteDate = ShopDateTime.Instance.ShopDate; DialogResult dgr = DialogResult.Retry; bool retVal = false; var errorDesc = string.Empty; //The following is true when this form is called in the Manage customer use case if (CustToView.PartyId == string.Empty) { do { retVal = CustomerProcedures.AddCustomer(GlobalDataAccessor.Instance.DesktopSession, CustToView, _strUserId, _strStoreNumber, out custNumber, out partyId, out errorDesc); if (retVal) { break; } else { dgr = MessageBox.Show(Commons.GetMessageString("CustDataAddFailure"), "Error", MessageBoxButtons.RetryCancel); } }while (dgr == DialogResult.Retry); if (retVal) { newCustCreated = true; _strCustNumber = custNumber; CustToView.CustomerNumber = _strCustNumber; CustToView.PartyId = partyId; do { retVal = CustomerProcedures.AddCustomerAddress(GlobalDataAccessor.Instance.DesktopSession, CustToView, _strUserId, _strStoreNumber); if (retVal) { break; } else { dgr = MessageBox.Show(Commons.GetMessageString("CustDataAddFailure"), "Error", MessageBoxButtons.RetryCancel); } }while (dgr == DialogResult.Retry); } else { //the call to add customer failed and the user pressed cancel when asked //if they would like to keep trying so go to desktop //CashlinxDesktopSession.Instance.FormState = CashlinxDesktopSession.CustomerFormStates.CANCEL; //CustomerController.NavigateUser(ownerFrm); NavControlBox.Action = NavBox.NavAction.CANCEL; } } else { retVal = true; } if (retVal) { do { updatePhysData = new CustomerDBProcedures(GlobalDataAccessor.Instance.DesktopSession).UpdateCustPhysicalDescription(_strRace, _strGender, _strHairColor, _strEyeColor, _strHeight, _strWeight, _strUserId, CustToView.PartyId, _strCustNumber, _strOthers, _strContactProductNoteId, _strStoreNumber, out _strNewContactProductNoteId, out _errorCode, out _errorMsg); if (updatePhysData) { Form ownerForm = this.Owner; if (ownerForm.GetType() == typeof(ViewCustomerInformation)) { CustomerVO updatedCustomer = new CustomerVO(); updatedCustomer.addNotes(CustToView.getPhysicalDescNote()); updatedCustomer.Race = _strRace; updatedCustomer.Gender = _strGender; updatedCustomer.HairColor = _strHairColor; updatedCustomer.EyeColor = _strEyeColor; updatedCustomer.Height = _strHeight; if (_strNewContactProductNoteId.Equals(string.Empty)) { _strNewContactProductNoteId = _strContactProductNoteId; } try { updatedCustomer.Weight = Convert.ToInt32(_strWeight); } catch (Exception) { updatedCustomer.Weight = 0; } updatedCustomer.updatePhysicalDescNote(_strOthers, _strStoreNumber, noteDate, _strUserId, _strNewContactProductNoteId); ((ViewCustomerInformation)ownerForm).UpdatedCustomerToView = updatedCustomer; ((ViewCustomerInformation)ownerForm).ShowUpdates = true; } break; } else { dgr = MessageBox.Show(Commons.GetMessageString("CustPhysicalDescUpdateFailure"), "Error", MessageBoxButtons.RetryCancel); } }while (dgr == DialogResult.Retry); } else { //Adding customer address was a failure and the user pressed cancel when asked //if they would like to retry so take them to desktop //CashlinxDesktopSession.Instance.FormState = CashlinxDesktopSession.CustomerFormStates.CANCEL; //CustomerController.NavigateUser(ownerFrm); NavControlBox.Action = NavBox.NavAction.CANCEL; } } else if (CustToView.PartyId != string.Empty) { MessageBox.Show(Commons.GetMessageString("NoChangesInForm")); } } else { MessageBox.Show(Commons.GetMessageString("FormRequiredFieldsFilledError")); return; } if (newCustCreated) { MessageBox.Show(Commons.GetMessageString("CustCreationSuccess") + " " + custNumber); CustomerVO customerObj = CustomerProcedures.getCustomerDataByCustomerNumber(GlobalDataAccessor.Instance.DesktopSession, custNumber); if (customerObj != null) { GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer = customerObj; } //CashlinxDesktopSession.Instance.FormState = CashlinxDesktopSession.CustomerFormStates.ADDCUSTOMERCOMPLETE; //CustomerController.NavigateUser(ownerFrm); NavControlBox.Action = NavBox.NavAction.BACKANDSUBMIT; } else { if (updatePhysData) { MessageBox.Show("Physical details updated"); } this.Close(); this.Dispose(true); } }