public bool ValidateCUSelection(CUAction cuAction, bool p_SignificantAncillary, bool p_SignificantAncillaryFound) { m_SignificantAncillary = p_SignificantAncillary; m_SignificantRecordFound = p_SignificantAncillaryFound; return(ValidateFeature(cuAction)); }
private bool ValidateFeature(CUAction cuAction) { bool bReturnValue = true; try { if (!IsCorrectionJob() && IsEditedByDifferentWR(false)) { MessageBox.Show("This CU is being edited by another WR.", "CU Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (!IsCorrectionJob() && (GetFeatureState().Equals("PPI") || GetFeatureState().Equals("ABI")) && IsEditedByDifferentWR(true)) { MessageBox.Show("Proposed install features must be transitioned to INI before they can be modified; contact Support for assistance.", "CU Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (!IsCorrectionJob() && (!GetFeatureState().Equals("PPI") && !GetFeatureState().Equals("ABI") && !GetFeatureState().Equals("INI") && !GetFeatureState().Equals("CLS") && !GetFeatureState().Equals("PPX") && !GetFeatureState().Equals("ABX"))) { MessageBox.Show("Cannot edit the CU code for a feature in this state", "CU Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (!IsCorrectionJob() && cuAction == CUAction.Changeout && !m_isAggregateFeature) { MessageBox.Show("Changeouts are only valid on aggregate features", "CU Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (IsCorrectionJob()) { MessageBox.Show("CUs may only be modified in a WR job", "CU Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (string.IsNullOrEmpty(m_category) && m_cuType.Equals("PRIMARY")) { MessageBox.Show("Primary CU selection must be configured to be filtered by category; notify system administrator.", "CU Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } catch (Exception ex) { throw ex; } return(bReturnValue); }
public CUAction GetCUAction(string p_existingCU) { CUAction bReturn = CUAction.Changeout; try { if (string.IsNullOrEmpty(p_existingCU)) { bReturn = CUAction.Selection; } else if (m_oKeyObject.CID <= 0 || (m_oKeyObject.Components[m_ComponentName].Recordset.RecordCount == 0)) { bReturn = CUAction.Selection; } else if (Convert.ToString(m_oKeyObject.Components[m_ComponentName].Recordset.Fields["ACTIVITY_C"].Value).Equals("I") || Convert.ToString(m_oKeyObject.Components[m_ComponentName].Recordset.Fields["ACTIVITY_C"].Value).Equals("IC")) { if ((Convert.ToString(m_oKeyObject.Components[m_ComponentName].Recordset.Fields["WR_ID"].Value).Equals(m_odataContext.ActiveJob) == true) || (Convert.ToString(m_oKeyObject.Components[m_ComponentName].Recordset.Fields["WR_ID"].Value).Equals("0") == true) || (m_oKeyObject.Components[m_ComponentName].Recordset.Fields["WR_ID"].Value.IsDBNull() == true)) //Need to change this field { bReturn = CUAction.Selection; } else { bReturn = CUAction.NoActionWRMismatches; } } else if (m_isAggregateFeature && m_ComponentName != "COMP_UNIT_ANCIL_N") { bReturn = CUAction.Changeout; } else { bReturn = CUAction.NoAction; } m_CuAction = bReturn; } catch (Exception ex) { throw ex; } return(bReturn); }
public bool Execute(object InputValue) { Int16 nCompNO = 0; string sFilterFieldName = ""; string sCUKeyfield = ""; string sCUKeyValue = ""; Boolean flagCUModified = false; Boolean flagPrimaryCU = true; string sExistingCU = string.Empty; string sExistingActivity = string.Empty; string sUnitCNO = string.Empty; string sUnitCID = string.Empty; string sCNoFieldName = string.Empty; bool bSignificantRecordFound = false; // Implement this method. // This method will call CUService to set the CU values try { m_oCUService = new CUService(m_iANO, m_bSignificantAncillary); m_oCUService.DataContext = m_oDataContext; m_oCUService.KeyObject = m_oFeature; if (m_sCUTypeConfigured == "PRIMARY") { flagPrimaryCU = true; m_sCUType = "CU"; m_sCUano = Convert.ToString(m_oCUService.CompUnitANO); m_CUCno = (short)m_oCUService.CUComponentCNO; if (!m_bSignificantAncillary) { m_componentName = "COMP_UNIT_N"; } } if (m_sCUTypeConfigured == "ANCILLARY") { flagPrimaryCU = false; m_sCUType = "ACU"; m_sCUano = Convert.ToString(m_oCUService.AncCompUnitANO); m_CUCno = (short)m_oCUService.AncillaryCUComponentCNO; m_componentName = "COMP_UNIT_ANCIL_N"; } sCNoFieldName = m_oCUService.CUField; sCUKeyfield = "CU_TYPE"; sCUKeyValue = m_sCUType; if (m_bReadOnly) { if (m_oFeature.CID <= 0) { MessageBox.Show("Nothing to review at this time.", "GTechnology", MessageBoxButtons.OK); } else { //Show More Info Form here CuCommonForms CuComomonForm = new CuCommonForms(m_oApp); CuComomonForm.ShowMoreInfoForm(Convert.ToString(m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields[sCNoFieldName].Value), true, true); } return(ProcessCUUpdate(flagCUModified, ref nCompNO, ref sFilterFieldName));; } ValidationConditions oValidateCUConditions = new ValidationConditions(m_oFeature, m_oDataContext, m_sCategoryFilter, m_sCUTypeConfigured, m_sIsAggregateFeature, m_componentName); CUAction CuActionSelected = CUAction.Selection; if (m_bSignificantAncillary) { bSignificantRecordFound = MoveSignificantAncillaryRecordset(); } CuActionSelected = oValidateCUConditions.GetCUAction(m_oFeature.Components.GetComponent(m_CUCno).Recordset.RecordCount > 0 ? Convert.ToString(m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields[sCNoFieldName].Value) : ""); //Identify the CU Action based on the conditions if (m_oFeature.Components.GetComponent(m_CUCno).Recordset.RecordCount > 0) { sExistingCU = Convert.ToString(m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields[sCNoFieldName].Value); } RemovalActivity removalActivitySelectedOnChageOutForm = RemovalActivity.NoValue; InstallActivity installActivitySelectedOnChageOutForm = InstallActivity.Novalue; if (CuActionSelected.Equals(CUAction.NoActionWRMismatches)) { m_oApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Cannot alter a CU installed by a different WR"); // MessageBox.Show("Cannot alter a CU installed by a different WR", "GTechnology", MessageBoxButtons.OK); return(true); } else if (CuActionSelected.Equals(CUAction.NoAction)) { m_oApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Cannot edit this CU code."); //MessageBox.Show("Cannot edit this CU code.", "GTechnology", MessageBoxButtons.OK); return(true); } if (!oValidateCUConditions.ValidateCUSelection(CuActionSelected, m_bSignificantAncillary, bSignificantRecordFound)) { return(true); //Validation conditions do not match and therefore return from here } if (CuActionSelected.Equals(CUAction.Changeout)) //This is a changeout operation { //ALM-1592-- Added a method to disable the "Replace with same CU" option if the CU is not found bool bReplacewithSameCU = ReplacewithSameCU(sExistingCU, m_sCategoryFilter); CuCommonForms CuComomonForm = new CuCommonForms(m_oApp, bReplacewithSameCU); CuComomonForm.ShowChangeOutForm(); removalActivitySelectedOnChageOutForm = CuComomonForm.RemovalActivitySelected; installActivitySelectedOnChageOutForm = CuComomonForm.InstallActivitySelected; if (CuComomonForm.CancelClicked) { return(true); //Cancel is clicked on Changeout Form so No Action required } if (installActivitySelectedOnChageOutForm == InstallActivity.DoNotInstall) { //Handle the setting of Removal Activity and return as there is no new installation needed m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields["ACTIVITY_C"].Value = (removalActivitySelectedOnChageOutForm == RemovalActivity.Remove ? "R" : "S"); m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields["WR_EDITED"].Value = m_oApp.DataContext.ActiveJob; return(ProcessCUUpdate(flagCUModified, ref nCompNO, ref sFilterFieldName)); } if (installActivitySelectedOnChageOutForm == InstallActivity.Replace || installActivitySelectedOnChageOutForm == InstallActivity.Select) { sExistingCU = Convert.ToString(m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields[sCNoFieldName].Value); sUnitCID = Convert.ToString(m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields["UNIT_CID"].Value); sUnitCNO = Convert.ToString(m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields["UNIT_CNO"].Value); m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields["WR_EDITED"].Value = m_oApp.DataContext.ActiveJob; sExistingActivity = Convert.ToString(m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields["ACTIVITY_C"].Value); m_oFeature.Components.GetComponent(m_CUCno).Recordset.Fields["ACTIVITY_C"].Value = (removalActivitySelectedOnChageOutForm == RemovalActivity.Remove ? "R" : "S"); } } if (m_oFeature.CID <= 0) //This is a clear case of Selection, Proceed as usual { if (DialogResult.OK == m_oCUService.Selection(flagPrimaryCU, sCUKeyfield, sCUKeyValue, m_sCategoryFilter)) { flagCUModified = true; } } else { if (DialogResult.OK == m_oCUService.Selection(flagPrimaryCU, m_oFeature.CID, sCUKeyfield, sCUKeyValue, m_sCategoryFilter, removalActivitySelectedOnChageOutForm, installActivitySelectedOnChageOutForm, sExistingCU, sExistingActivity, sUnitCID, sUnitCNO)) { flagCUModified = true; } } return(ProcessCUUpdate(flagCUModified, ref nCompNO, ref sFilterFieldName)); } catch (Exception ex) { MessageBox.Show("Error occured in CU Selection Foreign Query " + ex.Message, "G/Technology"); return(false); } }