public static Boolean GetMotivationGroupAndDetailForPartner(Int64 APartnerKey, ref String AMotivationGroup, ref String AMotivationDetail) { Boolean PartnerKeyIsValid = false; if (APartnerKey != 0) { string motivationGroup = MFinanceConstants.MOTIVATION_GROUP_GIFT; string motivationDetail = AMotivationDetail; TDBTransaction readTransaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref readTransaction, delegate { PPartnerTable myPPartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (myPPartnerTable.Rows.Count == 1) { // partnerKey is valid PartnerKeyIsValid = true; PPartnerRow partnerRow = myPPartnerTable[0]; // Change motivationDetail if PartnerClass is UNIT if (partnerRow.PartnerClass.Equals(MPartnerConstants.PARTNERCLASS_UNIT)) { // AND KEY-MIN bool KeyMinFound = false; // first check if a specific motivation detail is linked to this partner AMotivationDetailTable MotivationDetailTable = AMotivationDetailAccess.LoadViaPPartner(APartnerKey, readTransaction); if ((MotivationDetailTable != null) && (MotivationDetailTable.Rows.Count > 0)) { foreach (AMotivationDetailRow Row in MotivationDetailTable.Rows) { if (Row.MotivationStatus) { motivationGroup = MotivationDetailTable[0].MotivationGroupCode; motivationDetail = MotivationDetailTable[0].MotivationDetailCode; KeyMinFound = true; break; // Go with the first entry found. } } } if (!KeyMinFound) { // Is this is a key min, or a field? PUnitTable pUnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (pUnitTable.Rows.Count == 1) { PUnitRow unitRow = pUnitTable[0]; switch (unitRow.UnitTypeCode) { case MPartnerConstants.UNIT_TYPE_AREA: case MPartnerConstants.UNIT_TYPE_FUND: case MPartnerConstants.UNIT_TYPE_FIELD: motivationDetail = MFinanceConstants.GROUP_DETAIL_FIELD; break; case MPartnerConstants.UNIT_TYPE_KEYMIN: motivationDetail = MFinanceConstants.GROUP_DETAIL_KEY_MIN; break; case MPartnerConstants.UNIT_TYPE_COUNTRY: case MPartnerConstants.UNIT_TYPE_CONFERENCE: case MPartnerConstants.UNIT_TYPE_OTHER: case MPartnerConstants.UNIT_TYPE_ROOT: case MPartnerConstants.UNIT_TYPE_TEAM: case MPartnerConstants.UNIT_TYPE_WORKING_GROUP: default: motivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT; break; } } } } else { motivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT; } } }); AMotivationGroup = motivationGroup; AMotivationDetail = motivationDetail; } return(PartnerKeyIsValid); }
public static Boolean GetMotivationGroupAndDetail(Int64 APartnerKey, ref String AMotivationGroup, ref String AMotivationDetail) { Boolean PartnerKeyIsValid = false; if (APartnerKey != 0) { string MotivationGroup = MFinanceConstants.MOTIVATION_GROUP_GIFT; string MotivationDetail = AMotivationDetail; TDBTransaction readTransaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref readTransaction, delegate { PPartnerTable myPPartnerTable = null; myPPartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (myPPartnerTable.Rows.Count == 1) { // Entry for partnerKey is valid PartnerKeyIsValid = true; PPartnerRow partnerRow = null; partnerRow = (PPartnerRow)myPPartnerTable.Rows[0]; // Change motivationDetail if ColumnPartnerClass is UNIT if (partnerRow.PartnerClass.Equals(MPartnerConstants.PARTNERCLASS_UNIT)) { // AND KEY-MIN bool KeyMinFound = false; // first check if a motivation detail is linked to this potential key min AMotivationDetailTable MotivationDetailTable = null; MotivationDetailTable = AMotivationDetailAccess.LoadViaPPartner(APartnerKey, readTransaction); if ((MotivationDetailTable != null) && (MotivationDetailTable.Rows.Count > 0)) { foreach (AMotivationDetailRow Row in MotivationDetailTable.Rows) { if (Row.MotivationStatus) { MotivationGroup = MotivationDetailTable[0].MotivationGroupCode; MotivationDetail = MotivationDetailTable[0].MotivationDetailCode; KeyMinFound = true; break; } } } // second check to see if this is a key min if (!KeyMinFound) { PUnitTable pUnitTable = null; pUnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (pUnitTable.Rows.Count == 1) { PUnitRow unitRow = null; unitRow = (PUnitRow)pUnitTable.Rows[0]; if (unitRow.UnitTypeCode.Equals(MPartnerConstants.UNIT_TYPE_KEYMIN)) { MotivationDetail = MFinanceConstants.GROUP_DETAIL_KEY_MIN; } else { MotivationDetail = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_DEFAULTFIELDMOTIVATION, MFinanceConstants.GROUP_DETAIL_FIELD); // if system default is empty then set to FIELD if (string.IsNullOrEmpty(MotivationDetail)) { MotivationDetail = MFinanceConstants.GROUP_DETAIL_FIELD; } } } } } else { MotivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT; } } }); AMotivationGroup = MotivationGroup; AMotivationDetail = MotivationDetail; } return(PartnerKeyIsValid); }