/// <summary> /// get the number and name of the registration offices that the current user has access for /// </summary> /// <returns></returns> public static PPartnerTable GetRegistrationOffices() { bool NewTransaction; TDataBase db = DBAccess.Connect("GetRegistrationOffices"); TDBTransaction Transaction = db.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction); PPartnerTable result = new PPartnerTable(); try { List <Int64> offices = GetRegistrationOfficeKeysOfUser(Transaction); StringCollection FieldList = new StringCollection(); FieldList.Add(PPartnerTable.GetPartnerKeyDBName()); FieldList.Add(PPartnerTable.GetPartnerShortNameDBName()); // get the short names of the registration offices foreach (Int64 OfficeKey in offices) { PPartnerTable partnerTable = PPartnerAccess.LoadByPrimaryKey(OfficeKey, FieldList, Transaction); result.Merge(partnerTable); } // remove unwanted columns List <string> ColumnNames = new List <string>(); foreach (DataColumn column in result.Columns) { ColumnNames.Add(column.ColumnName); } foreach (string columnName in ColumnNames) { if (!FieldList.Contains(columnName)) { result.Columns.Remove(columnName.ToString()); } } } finally { if (NewTransaction) { Transaction.Rollback(); } } result.DefaultView.Sort = PPartnerTable.GetPartnerKeyDBName(); return(result); }
/// <summary> /// get the number and name of the registration offices that the current user has access for /// </summary> /// <returns></returns> public static PPartnerTable GetRegistrationOffices() { bool NewTransaction; TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction); PPartnerTable result = new PPartnerTable(); try { List <Int64>offices = GetRegistrationOfficeKeysOfUser(Transaction); StringCollection FieldList = new StringCollection(); FieldList.Add(PPartnerTable.GetPartnerKeyDBName()); FieldList.Add(PPartnerTable.GetPartnerShortNameDBName()); // get the short names of the registration offices foreach (Int64 OfficeKey in offices) { PPartnerTable partnerTable = PPartnerAccess.LoadByPrimaryKey(OfficeKey, FieldList, Transaction); result.Merge(partnerTable); } // remove unwanted columns List <string>ColumnNames = new List <string>(); foreach (DataColumn column in result.Columns) { ColumnNames.Add(column.ColumnName); } foreach (string columnName in ColumnNames) { if (!FieldList.Contains(columnName)) { result.Columns.Remove(columnName.ToString()); } } } finally { if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } } result.DefaultView.Sort = PPartnerTable.GetPartnerKeyDBName(); return result; }