void _recordContext_Saving(object sender, System.ComponentModel.CancelEventArgs e) { this._repairOrderControl.LeaveFocusWhenSaving(); string logMessage, logNote; Contact = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; if (Contact == null) { _repairOrderControl.tbSerialNo.Enabled = true; DialogResult result = MessageBox.Show("Contact is empty. Cannot do the serial number validation. ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { logMessage = "Contact is empty. Cannot do the serial number validation. "; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); e.Cancel = true; return; } } current_serial_num = _repairOrderControl.tbSerialNo.Text; //Validate serial number bool isValidSerial; if (current_serial_num != "") { try { isValidSerial = this.validateSerialNumber(current_serial_num); } catch (Exception ex) { logMessage = "Incident saving is cancelled, because error: " + ex.Message; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); e.Cancel = true; return; } currentInventoryItemID = _repairOrderControl.inputInventoryItemID; if (!isValidSerial) { //Invalid Error logMessage = "The serial number (" + current_serial_num + ") is invalid. It does not belong to current contact's organization."; logNote = ""; _log.NoticeLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); string message = "The serial number is invalid. It does not belong to current contact's organization."; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; // Show message box to mention the assigned contact party id result = MessageBox.Show(this, message, "Error", buttons, MessageBoxIcon.Error); if (result == DialogResult.OK) { //current_serial_num = ebsStoredSerialNum; //currentInstanceID = ebsStoredInstanceID; e.Cancel = true; return; } } } else { currentInventoryItemID = 6761; } // get current selected repair status id switch (_repairOrderControl.SelectedRepairStatus) { case "Open": selected_status = "Open"; selected_status_id = 1002; break; case "Hold": selected_status = "Hold"; selected_status_id = 1001; break; case "Close": selected_status = "Close"; selected_status_id = 1000; break; case "Item Received": selected_status = "Item Received"; selected_status_id = 1140; break; case "Item Shipped": selected_status = "Item Shipped"; selected_status_id = 1141; break; case "Awaiting Estimate Approval": selected_status = "Awaiting Estimate Approval"; selected_status_id = 1142; break; case "Awaiting QA": selected_status = "Awaiting QA"; selected_status_id = 1143; break; case "Awaiting Repair": selected_status = "Awaiting Repair"; selected_status_id = 1144; break; case "Awaiting Shipping": selected_status = "Awaiting Shipping"; selected_status_id = 1145; break; case "Estimate Approved": selected_status = "Estimate Approved"; selected_status_id = 1146; break; case "Estimate Rejected": selected_status = "Estimate Rejected"; selected_status_id = 1147; break; case "Exchange and Refurbish": selected_status = "Exchange and Refurbish"; selected_status_id = 1148; break; case "Repair Complete": selected_status = "Repair Complete"; selected_status_id = 1149; break; case "Repair In Progress": selected_status = "Repair In Progress"; selected_status_id = 1150; break; case "Awaiting Receipt": selected_status = "Awaiting Receipt"; selected_status_id = 1151; break; default: selected_status = "Open"; selected_status_id = 1002; break; } // get EBS stored repair status id switch (_repairOrderControl.StoredRepairStatus) { case "Open": stored_status = "Open"; stored_status_id = 1002; break; case "Hold": stored_status = "Hold"; stored_status_id = 1001; break; case "Close": stored_status = "Close"; stored_status_id = 1000; break; case "Item Received": stored_status = "Item Received"; stored_status_id = 1140; break; case "Item Shipped": stored_status = "Item Shipped"; stored_status_id = 1141; break; case "Awaiting Estimate Approval": stored_status = "Awaiting Estimate Approval"; stored_status_id = 1142; break; case "Awaiting QA": stored_status = "Awaiting QA"; stored_status_id = 1143; break; case "Awaiting Repair": stored_status = "Awaiting Repair"; stored_status_id = 1144; break; case "Awaiting Shipping": stored_status = "Awaiting Shipping"; stored_status_id = 1145; break; case "Estimate Approved": stored_status = "Estimate Approved"; stored_status_id = 1146; break; case "Estimate Rejected": stored_status = "Estimate Rejected"; stored_status_id = 1147; break; case "Exchange and Refurbish": stored_status = "Exchange and Refurbish"; stored_status_id = 1148; break; case "Repair Complete": stored_status = "Repair Complete"; stored_status_id = 1149; break; case "Repair In Progress": stored_status = "Repair In Progress"; stored_status_id = 1150; break; case "Awaiting Receipt": stored_status = "Awaiting Receipt"; stored_status_id = 1151; break; default: stored_status = "Open"; stored_status_id = 1002; break; } }