private void LoadDataGrid() { List <long> HomeOfficeKeyList = new List <long>(); FMainDS.PcAttendee.Clear(); FMainDS.PmGeneralApplication.Clear(); FMainDS.PmShortTermApplication.Clear(); FMainDS.PPartner.Clear(); // populate dataset TRemote.MConference.Conference.WebConnectors.GetConferenceApplications(ref FMainDS, FPartnerKey); // Add all homeofficekeys to list as this column will be removed from dataset foreach (PcAttendeeRow Row in FMainDS.PcAttendee.Rows) { if (Row.IsHomeOfficeKeyNull() || (Row.HomeOfficeKey == 0)) { HomeOfficeKeyList.Add(((int)Row.PartnerKey / 1000000) * 1000000); } else { HomeOfficeKeyList.Add(Row.HomeOfficeKey); } } FMainDS.PcAttendee.Columns.Add(PPartnerTable.GetPartnerShortNameDBName(), Type.GetType("System.String")); FMainDS.PcAttendee.Columns.Add(PmShortTermApplicationTable.GetStFieldChargedDBName(), Type.GetType("System.String")); FMainDS.PcAttendee.Columns.Add(PmShortTermApplicationTable.GetStCurrentFieldDBName(), Type.GetType("System.String")); // This column is removed and readded with a different type. This allows the partner short name to be displayed rather than the partner key. FMainDS.PcAttendee.Columns.Remove(PcAttendeeTable.GetHomeOfficeKeyDBName()); FMainDS.PcAttendee.Columns.Add(PcAttendeeTable.GetHomeOfficeKeyDBName(), Type.GetType("System.String")); FMainDS.PcAttendee.DefaultView.AllowNew = false; for (int Counter = 0; Counter < FMainDS.PcAttendee.Rows.Count; ++Counter) { long PartnerKey = ((PcAttendeeRow)FMainDS.PcAttendee.Rows[Counter]).PartnerKey; long HomeOfficeKey = HomeOfficeKeyList[Counter]; long StFieldCharged = 0; long StConfirmedOption = 0; foreach (PmShortTermApplicationRow Row in FMainDS.PmShortTermApplication.Rows) { if (Row.PartnerKey == PartnerKey) { if (Row.IsStFieldChargedNull() || (Row.StFieldCharged == 0)) { if (Row.IsStCurrentFieldNull() || (Row.StCurrentField == 0)) { StFieldCharged = HomeOfficeKey; } else { StFieldCharged = Row.StCurrentField; } } else { StFieldCharged = Row.StFieldCharged; } if (Row.IsStCurrentFieldNull() || (Row.StConfirmedOption == 0)) { FMainDS.PcAttendee.Rows[Counter][PmShortTermApplicationTable.GetStCurrentFieldDBName()] = ((PcAttendeeRow)FMainDS.PcAttendee.Rows[Counter]).OutreachType; } else { StConfirmedOption = Row.StConfirmedOption; } break; } } int PartnersFound = 0; foreach (PPartnerRow Row in FMainDS.PPartner.Rows) { if (Row.PartnerKey == PartnerKey) { FMainDS.PcAttendee.Rows[Counter][PPartnerTable.GetPartnerShortNameDBName()] = Row.PartnerShortName; if (PartnersFound == 3) { break; } else { PartnersFound++; } } // display partner short name rather than the partner key if ((StFieldCharged != 0) && (Row.PartnerKey == StFieldCharged)) { FMainDS.PcAttendee.Rows[Counter][PmShortTermApplicationTable.GetStFieldChargedDBName()] = Row.PartnerShortName; if (PartnersFound == 3) { break; } else { PartnersFound++; } } // display partner short name rather than the partner key if ((StConfirmedOption != 0) && (Row.PartnerKey == StConfirmedOption)) { FMainDS.PcAttendee.Rows[Counter][PmShortTermApplicationTable.GetStCurrentFieldDBName()] = Row.PartnerShortName; if (PartnersFound == 3) { break; } else { PartnersFound++; } } // display partner short name rather than the partner key if ((HomeOfficeKey != 0) && (Row.PartnerKey == HomeOfficeKey)) { FMainDS.PcAttendee.Rows[Counter][PcAttendeeTable.GetHomeOfficeKeyDBName()] = Row.PartnerShortName; if (!(Row.PartnerShortName.Length > 0)) { } if (PartnersFound == 3) { break; } else { PartnersFound++; } } } } // sort order for grid DataView MyDataView = FMainDS.PcAttendee.DefaultView; MyDataView.Sort = "p_partner_short_name_c ASC"; grdAttendees.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView); }
private static bool GetAllSendingFields(long AConferenceKey, ref DataTable AFieldsTable) { TDBTransaction ReadTransaction; Boolean NewTransaction = false; PUnitTable UnitTable; PcAttendeeTable AttendeeTable = new PcAttendeeTable(); TLogging.LogAtLevel(9, "TConferenceOptions.GetAllSendingFields called!"); TDataBase db = DBAccess.Connect("GetAllSendingFields"); ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, out NewTransaction); try { StringCollection FieldList = new StringCollection(); FieldList.Add(PcAttendeeTable.GetHomeOfficeKeyDBName()); AttendeeTable = PcAttendeeAccess.LoadAll(FieldList, ReadTransaction); long LastUnitKey = 0; long NewUnitKey = 0; String HomeOfficeColumnName = PcAttendeeTable.GetHomeOfficeKeyDBName(); foreach (DataRow AttendeeRow in AttendeeTable.Select("", HomeOfficeColumnName)) { if (AttendeeRow[HomeOfficeColumnName] != null) { NewUnitKey = (long)AttendeeRow[HomeOfficeColumnName]; } else { continue; } if (LastUnitKey == NewUnitKey) { continue; } UnitTable = PUnitAccess.LoadByPrimaryKey(NewUnitKey, ReadTransaction); if (UnitTable.Rows.Count > 0) { DataRow ResultRow = AFieldsTable.NewRow(); ResultRow[SELECTION] = false; ResultRow[UNIT_KEY] = NewUnitKey; ResultRow[UNIT_NAME] = UnitTable[0][PUnitTable.GetUnitNameDBName()]; ResultRow[USED_IN_CONFERENCE] = true; AFieldsTable.Rows.Add(ResultRow); LastUnitKey = NewUnitKey; } } } finally { if (NewTransaction) { ReadTransaction.Commit(); TLogging.LogAtLevel(7, "TConferenceOptions.GetAllSendingFields: committed own transaction."); } } return(true); }