private void PartnerStatusCodeChangePromotion(System.Object sender, EventArgs e) { string PartnerStatus = cmbPartnerStatus.GetSelectedString(); // Business Rule: if the Partner's StatusCode changes, give the user the // option to promote the change to all Family Members (if the Partner is // a FAMILY and has Family Members). if ((FMainDS != null) && (!FIgnorePartnerStatusChange) && (FPartnerClass == SharedTypes.PartnerClassEnumToString(TPartnerClass.FAMILY))) { if (PartnerStatus != SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscMERGED)) { if (PartnerStatusCodeChangePromotion(PartnerStatus)) { // Set the StatusChange date (this would be done on the server side // automatically, but we want to display it now for immediate user feedback) FMainDS.PPartner[0].StatusChange = DateTime.Today; } else { // User wants to cancel the change of the Partner StatusCode // Undo the change in the DataColumn FIgnorePartnerStatusChange = true; UndoData(FMainDS.PPartner[0], cmbPartnerStatus); cmbPartnerStatus.SelectNextControl(cmbPartnerStatus, true, true, true, true); FIgnorePartnerStatusChange = false; } } } }
private static SponsorshipTDS CreateNewChild() { Int64 SiteKey = DomainManager.GSiteKey; SponsorshipTDS MainDS = new SponsorshipTDS(); Int64 PartnerKey = NewPartnerKey(); DateTime CreationDate = DateTime.Today; string CreationUserID = UserInfo.GetUserInfo().UserID; // Create DataRow for Partner using the default values for all DataColumns // and then modify some. PPartnerRow PartnerRow = MainDS.PPartner.NewRowTyped(true); PartnerRow.PartnerKey = PartnerKey; PartnerRow.DateCreated = CreationDate; PartnerRow.CreatedBy = CreationUserID; PartnerRow.PartnerClass = SharedTypes.PartnerClassEnumToString(TPartnerClass.FAMILY); PartnerRow.StatusCode = SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE); PartnerRow.UserId = CreationUserID; MainDS.PPartner.Rows.Add(PartnerRow); PFamilyRow FamilyRow = MainDS.PFamily.NewRowTyped(true); FamilyRow.PartnerKey = PartnerKey; FamilyRow.DateCreated = CreationDate; FamilyRow.CreatedBy = CreationUserID; MainDS.PFamily.Rows.Add(FamilyRow); PPartnerTypeRow PartnerTypeRow = MainDS.PPartnerType.NewRowTyped(true); PartnerTypeRow.PartnerKey = PartnerKey; PartnerTypeRow.TypeCode = TYPE_SPONSOREDCHILD; MainDS.PPartnerType.Rows.Add(PartnerTypeRow); return(MainDS); }
public static BankTDS GetPBankRecords() { BankTDS ReturnValue = new BankTDS(); TDBTransaction ReadTransaction = new TDBTransaction(); DBAccess.ReadTransaction( ref ReadTransaction, delegate { const string QUERY_BANKRECORDS = "SELECT PUB_p_bank.*, PUB_p_partner.p_status_code_c, PUB_p_location.* " + "FROM PUB_p_bank JOIN PUB_p_partner ON PUB_p_partner.p_partner_key_n = PUB_p_bank.p_partner_key_n " + "LEFT OUTER JOIN PUB_p_partner_location ON PUB_p_bank.p_partner_key_n = PUB_p_partner_location.p_partner_key_n " + "AND (PUB_p_partner_location.p_date_good_until_d IS NULL OR PUB_p_partner_location.p_date_good_until_d >= DATE(NOW())) " + "JOIN PUB_p_location ON PUB_p_partner_location.p_site_key_n = PUB_p_location.p_site_key_n " + "AND PUB_p_partner_location.p_location_key_i = PUB_p_location.p_location_key_i"; ReadTransaction.DataBaseObj.Select(ReturnValue, QUERY_BANKRECORDS, ReturnValue.PBank.TableName, ReadTransaction, null); foreach (BankTDSPBankRow Row in ReturnValue.PBank.Rows) { // mark inactive bank accounts if (Row.StatusCode != SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE)) { Row.BranchCode = SharedConstants.INACTIVE_VALUE_WITH_QUALIFIERS + " " + Row.BranchCode; } } }); return(ReturnValue); }
/// <summary> /// Returns the Family Members of a Family. /// </summary> /// <param name="AFamilyPartnerKey">PartnerKey of the FAMILY.</param> /// <param name="AReadTransaction">Open DB Transaction.</param> /// <returns>An Instance of <see cref="PartnerInfoTDSFamilyMembersTable" />. /// If there were Family Members, there will be one DataRow for each Family Member.</returns> private static PartnerInfoTDSFamilyMembersTable GetFamilyMembers(Int64 AFamilyPartnerKey, TDBTransaction AReadTransaction) { OdbcParameter[] ParametersArray; DataSet TmpDS; PPersonTable FamilyPersonsDT; PartnerInfoTDSFamilyMembersRow NewRow; PartnerInfoTDSFamilyMembersTable FamilyMembersDT; FamilyMembersDT = new PartnerInfoTDSFamilyMembersTable(); ParametersArray = new OdbcParameter[1]; ParametersArray[0] = new OdbcParameter("", OdbcType.Decimal, 10); ParametersArray[0].Value = (System.Object)AFamilyPartnerKey; TmpDS = new DataSet(); FamilyPersonsDT = new PPersonTable(); TmpDS.Tables.Add(FamilyPersonsDT); AReadTransaction.DataBaseObj.Select(TmpDS, "SELECT " + "PUB_" + PPartnerTable.GetTableDBName() + '.' + PPartnerTable.GetPartnerKeyDBName() + ", " + PPersonTable.GetFamilyNameDBName() + ", " + PPersonTable.GetTitleDBName() + ", " + PPersonTable.GetFirstNameDBName() + ", " + PPersonTable.GetMiddleName1DBName() + ", " + PPersonTable.GetFamilyIdDBName() + ' ' + "FROM PUB_" + PPersonTable.GetTableDBName() + " INNER JOIN " + "PUB_" + PPartnerTable.GetTableDBName() + " ON " + "PUB_" + PPersonTable.GetTableDBName() + '.' + PPartnerTable.GetPartnerKeyDBName() + " = " + "PUB_" + PPartnerTable.GetTableDBName() + '.' + PPartnerTable.GetPartnerKeyDBName() + ' ' + "WHERE " + PPersonTable.GetFamilyKeyDBName() + " = ? " + "AND " + PPartnerTable.GetStatusCodeDBName() + " <> '" + SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscMERGED) + "' " + // Make sure we don't load MERGED Partners (shouldn't have a p_family_key_n, but just in case.) "ORDER BY " + PPersonTable.GetFamilyIdDBName() + " ASC", PPersonTable.GetTableName(), AReadTransaction, ParametersArray, 0, 0); // Add Persons to Table for (Int32 Counter = 0; Counter <= FamilyPersonsDT.Rows.Count - 1; Counter += 1) { NewRow = FamilyMembersDT.NewRowTyped(false); NewRow.PartnerKey = FamilyPersonsDT[Counter].PartnerKey; NewRow.PartnerShortName = Calculations.DeterminePartnerShortName(TSaveConvert.StringColumnToString(FamilyPersonsDT.ColumnFamilyName, FamilyPersonsDT[Counter]), TSaveConvert.StringColumnToString(FamilyPersonsDT.ColumnTitle, FamilyPersonsDT[Counter]), TSaveConvert.StringColumnToString(FamilyPersonsDT.ColumnFirstName, FamilyPersonsDT[Counter]), TSaveConvert.StringColumnToString(FamilyPersonsDT.ColumnMiddleName1, FamilyPersonsDT[Counter])); NewRow.FamilyId = FamilyPersonsDT[Counter].FamilyId; FamilyMembersDT.Rows.Add(NewRow); } return(FamilyMembersDT); }
public static BankTDS GetPBankRecords() { TDBTransaction ReadTransaction; Boolean NewTransaction; BankTDS ReturnValue = new BankTDS(); ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { string QueryBankRecords = "SELECT PUB_p_bank.*, PUB_p_partner.p_status_code_c, PUB_p_location.* " + "FROM PUB_p_bank JOIN PUB_p_partner ON PUB_p_partner.p_partner_key_n = PUB_p_bank.p_partner_key_n " + "LEFT OUTER JOIN PUB_p_partner_location ON PUB_p_bank.p_partner_key_n = PUB_p_partner_location.p_partner_key_n " + "AND (PUB_p_partner_location.p_date_good_until_d IS NULL OR PUB_p_partner_location.p_date_good_until_d >= DATE(NOW())) " + "JOIN PUB_p_location ON PUB_p_partner_location.p_site_key_n = PUB_p_location.p_site_key_n " + "AND PUB_p_partner_location.p_location_key_i = PUB_p_location.p_location_key_i"; DBAccess.GDBAccessObj.Select(ReturnValue, QueryBankRecords, ReturnValue.PBank.TableName, ReadTransaction, null); foreach (BankTDSPBankRow Row in ReturnValue.PBank.Rows) { // mark inactive bank accounts if (Row.StatusCode != SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE)) { Row.BranchCode = SharedConstants.INACTIVE_VALUE_WITH_QUALIFIERS + " " + Row.BranchCode; } } } finally { if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); TLogging.LogAtLevel(7, "TPartnerDataReaderWebConnector.GetPBankRecords: committed own transaction."); } } return(ReturnValue); }
public static BankTDS GetPBankRecords() { BankTDS ReturnValue = new BankTDS(); TDBTransaction ReadTransaction = null; // Need to use 'GetNewOrExistingAutoReadTransaction' rather than 'BeginAutoReadTransaction' to allow // switching to the 'Find by Bank Details' on Partner Find while a Report is calculating (Bug #3877). DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction( IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref ReadTransaction, delegate { const string QUERY_BANKRECORDS = "SELECT PUB_p_bank.*, PUB_p_partner.p_status_code_c, PUB_p_location.* " + "FROM PUB_p_bank JOIN PUB_p_partner ON PUB_p_partner.p_partner_key_n = PUB_p_bank.p_partner_key_n " + "LEFT OUTER JOIN PUB_p_partner_location ON PUB_p_bank.p_partner_key_n = PUB_p_partner_location.p_partner_key_n " + "AND (PUB_p_partner_location.p_date_good_until_d IS NULL OR PUB_p_partner_location.p_date_good_until_d >= DATE(NOW())) " + "JOIN PUB_p_location ON PUB_p_partner_location.p_site_key_n = PUB_p_location.p_site_key_n " + "AND PUB_p_partner_location.p_location_key_i = PUB_p_location.p_location_key_i"; DBAccess.GDBAccessObj.Select(ReturnValue, QUERY_BANKRECORDS, ReturnValue.PBank.TableName, ReadTransaction, null); foreach (BankTDSPBankRow Row in ReturnValue.PBank.Rows) { // mark inactive bank accounts if (Row.StatusCode != SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE)) { Row.BranchCode = SharedConstants.INACTIVE_VALUE_WITH_QUALIFIERS + " " + Row.BranchCode; } } }); return(ReturnValue); }
public static BankTDS GetPBankRecords() { BankTDS ReturnValue = new BankTDS(); TDBTransaction ReadTransaction = null; // Automatic handling of a Read-only DB Transaction - and also the automatic establishment and closing of a DB // Connection where a DB Transaction can be exectued (only if that should be needed). DBAccess.SimpleAutoReadTransactionWrapper( IsolationLevel.ReadCommitted, "TPartnerDataReaderWebConnector.GetPBankRecords", out ReadTransaction, delegate { const string QUERY_BANKRECORDS = "SELECT PUB_p_bank.*, PUB_p_partner.p_status_code_c, PUB_p_location.* " + "FROM PUB_p_bank JOIN PUB_p_partner ON PUB_p_partner.p_partner_key_n = PUB_p_bank.p_partner_key_n " + "LEFT OUTER JOIN PUB_p_partner_location ON PUB_p_bank.p_partner_key_n = PUB_p_partner_location.p_partner_key_n " + "AND (PUB_p_partner_location.p_date_good_until_d IS NULL OR PUB_p_partner_location.p_date_good_until_d >= DATE(NOW())) " + "JOIN PUB_p_location ON PUB_p_partner_location.p_site_key_n = PUB_p_location.p_site_key_n " + "AND PUB_p_partner_location.p_location_key_i = PUB_p_location.p_location_key_i"; DBAccess.GetDBAccessObj(ReadTransaction).Select(ReturnValue, QUERY_BANKRECORDS, ReturnValue.PBank.TableName, ReadTransaction, null); foreach (BankTDSPBankRow Row in ReturnValue.PBank.Rows) { // mark inactive bank accounts if (Row.StatusCode != SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE)) { Row.BranchCode = SharedConstants.INACTIVE_VALUE_WITH_QUALIFIERS + " " + Row.BranchCode; } } }); return(ReturnValue); }
// A new row is selected in the grid private void FocusedRowChanged(System.Object sender, EventArgs e) { if (grdDetails.SelectedDataRows.Length == 1) { DataRowView RowDataRowView = (DataRowView)grdDetails.SelectedDataRows[0]; if (RowDataRowView.Row[BankTDSPBankTable.GetStatusCodeDBName()].ToString() != SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE)) { chkShowInactive.Enabled = false; } else { chkShowInactive.Enabled = true; } // Update property with a new selected bank's partner key FBankPartnerKey = Convert.ToInt64(RowDataRowView.Row[BankTDSPBankTable.GetPartnerKeyDBName()]); btnAccept.Enabled = true; btnEdit.Enabled = true; } }
/// <summary> /// Sets the Partner's PartnerStatus to 'ACTIVE'. /// </summary> public void SetPartnerStatusToActive() { cmbPartnerStatus.SetSelectedString(SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE)); }
private void Filter(System.Object sender, EventArgs e) { // Apply filter to the grid DataView MyDataView = FCriteriaData.DefaultView; String Filter = ""; if (!string.IsNullOrEmpty(txtBranchName.Text)) { Filter += FCriteriaData.Columns[PBankTable.GetBranchNameDBName()] + " LIKE '" + txtBranchName.Text + "%'"; } if (!string.IsNullOrEmpty(txtBranchCode.Text)) { if (Filter != "") { Filter += " AND "; } Filter += FCriteriaData.Columns[PBankTable.GetBranchCodeDBName()] + " LIKE '" + txtBranchCode.Text + "%'"; } if (!string.IsNullOrEmpty(txtBicCode.Text)) { if (Filter != "") { Filter += " AND "; } Filter += FCriteriaData.Columns[PBankTable.GetBicDBName()] + " LIKE '" + txtBicCode.Text + "%'"; } if (!string.IsNullOrEmpty(txtCity.Text)) { if (Filter != "") { Filter += " AND "; } Filter += FCriteriaData.Columns[PLocationTable.GetCityDBName()] + " LIKE '" + txtCity.Text + "%'"; } if (!string.IsNullOrEmpty(txtCountry.Text)) { if (Filter != "") { Filter += " AND "; } Filter += FCriteriaData.Columns[PLocationTable.GetCountryCodeDBName()] + " LIKE '" + txtCountry.Text + "%'"; } if (!chkShowInactive.Checked) { if (Filter != "") { Filter += " AND "; } Filter += FCriteriaData.Columns[BankTDSPBankTable.GetStatusCodeDBName()] + " = '" + SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE) + "'"; } MyDataView.RowFilter = Filter; grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView); UpdateRecordNumberDisplay(); SelectRowInGrid(); FocusedRowChanged(this, null); }
// automatically select the currently selected Bank (if it exists) private void SelectRowInGrid() { int RowPos = 1; // if no bank is selected then no row should be selected if ((grdDetails.Rows.Count <= 1) || (FBankPartnerKey == 0)) { // select the first row in the grid if (grdDetails.Rows.Count > 1) { grdDetails.SelectRowWithoutFocus(1); } else { btnAccept.Enabled = false; btnEdit.Enabled = false; } return; } BankTDSPBankRow BankRow = null; // Multiple rows could have the same partner keys but different locations. // We just want the first row. foreach (BankTDSPBankRow Row in FMainDS.PBank.Rows) { if (Row.PartnerKey == FBankPartnerKey) { BankRow = Row; break; } } // if current bank is 'inactive' then make sure chkShowInactive is checked (unchecked by default) if ((BankRow != null) && (BankRow.StatusCode != SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE)) && (chkShowInactive.Checked == false)) { chkShowInactive.Checked = true; } if (BankRow == null) { grdDetails.SelectRowWithoutFocus(1); } else { // look through each row in the grid foreach (DataRowView RowView in FCriteriaData.DefaultView) { // if current grid row is the row we are looking for the select it if (Convert.ToInt64(RowView[PBankTable.GetPartnerKeyDBName()]) == FBankPartnerKey) { grdDetails.SelectRowWithoutFocus(RowPos); btnAccept.Enabled = true; btnEdit.Enabled = true; return; } // account for grid rows being filtered by being inactive if (chkShowInactive.Checked || (!chkShowInactive.Checked && (RowView[BankTDSPBankTable.GetStatusCodeDBName()].ToString() == SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE)))) { RowPos++; } } } }