private void LoadListData()
        {
            string CheckedMember = "CHECKED";
            string ValueMember   = PUnitTable.GetPartnerKeyDBName();
            string DisplayMember = PUnitTable.GetUnitNameDBName();

            // retrieve data from server
            PUnitTable UnitTable = TRemote.MPartner.Partner.WebConnectors.GetLedgerUnits();

            DataView view = new DataView(UnitTable);

            FFieldTable = view.ToTable(true, new string[] { ValueMember, DisplayMember });
            FFieldTable.Columns.Add(new DataColumn(CheckedMember, typeof(bool)));

            clbLedger.Columns.Clear();
            clbLedger.AddCheckBoxColumn("", FFieldTable.Columns[CheckedMember], 17, false);
            clbLedger.AddTextColumn(Catalog.GetString("Ledger Name"), FFieldTable.Columns[DisplayMember]);
            clbLedger.AddPartnerKeyColumn(Catalog.GetString("Partner Key"), FFieldTable.Columns[ValueMember]);

            clbLedger.DataBindGrid(FFieldTable, DisplayMember, CheckedMember, ValueMember, false, true, false);
            clbLedger.AutoStretchColumnsToFitWidth = true;

            //TODO: only temporarily until settings file exists
            clbLedger.SetCheckedStringList("");
        }
        /// <summary>
        /// Initialisation
        /// </summary>
        public void InitUserControlsManually()
        {
            FUnitTable = TRemote.MConference.WebConnectors.GetOutreachOptions(FUnitKey);
            FUnitTable.Columns.Add("Is Selected", Type.GetType("System.Boolean"));

            for (int Counter = 0; Counter < FUnitTable.Rows.Count; ++Counter)
            {
                FUnitTable.Rows[Counter]["Is Selected"] = false;
            }

            grdOutreachOption.AddCheckBoxColumn("", FUnitTable.Columns["Is Selected"]);
            grdOutreachOption.AddTextColumn("Outreach Code", FUnitTable.ColumnOutreachCode);
            grdOutreachOption.AddTextColumn("Unit Name", FUnitTable.ColumnUnitName);
            grdOutreachOption.AddTextColumn("Unit Key", FUnitTable.ColumnPartnerKey);

            FUnitTable.DefaultView.AllowNew = false;
            FUnitTable.DefaultView.AllowEdit = true;
            FUnitTable.DefaultView.AllowDelete = false;

            // automatically check all options
            SelectOutreachOptions(true);

            grdOutreachOption.DataSource = new DevAge.ComponentModel.BoundDataView(FUnitTable.DefaultView);
            grdOutreachOption.DoubleClickCell += new TDoubleClickCellEventHandler(grdOutreachOptionDoubleClick);
        }
        /// <summary>
        /// load data for sites grid from server
        /// </summary>
        private void LoadSitesData()
        {
            string CheckedMember = SharedConstants.SYSMAN_AVAILABLE_SITES_COLUMN_IS_PARTNER_LEDGER;
            string SiteKey       = PUnitTable.GetPartnerKeyDBName();
            string SiteShortName = PUnitTable.GetUnitNameDBName();

            AvailableSitesTable = TRemote.MSysMan.WebConnectors.GetAvailableSites();

            clbSites.Columns.Clear();
            clbSites.AddCheckBoxColumn("", AvailableSitesTable.Columns[CheckedMember], 17, false);
            clbSites.AddPartnerKeyColumn(Catalog.GetString("Partner Key"), AvailableSitesTable.Columns[SiteKey], 100);
            clbSites.AddTextColumn(Catalog.GetString("Site Name"), AvailableSitesTable.Columns[SiteShortName], 400);

            clbSites.DataBindGrid(AvailableSitesTable, "", CheckedMember, SiteKey, false, true, false);

            // create list of site keys that have been checked when screen opens
            OriginallyCheckedSites = new List <Int64>();
            OriginallyCheckedSites.Clear();

            foreach (DataRow SiteRow in AvailableSitesTable.Rows)
            {
                if (Convert.ToBoolean(SiteRow[SharedConstants.SYSMAN_AVAILABLE_SITES_COLUMN_IS_PARTNER_LEDGER]))
                {
                    OriginallyCheckedSites.Add(Convert.ToInt64(SiteRow[PUnitTable.GetPartnerKeyDBName()]));
                }
            }
        }
예제 #4
0
        public static string GetOutreachCode(Int64 APartnerKey)
        {
            string         ReturnValue;
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction;

            ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                                                TEnforceIsolationLevel.eilMinimum,
                                                                                out NewTransaction);

            PUnitTable UnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

            if (UnitTable.Count > 0)
            {
                ReturnValue = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;
            }
            else
            {
                ReturnValue = "";
            }

            if (NewTransaction)
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TIndividualDataWebConnector.GetOutreachCode: rollback own transaction.");
            }

            return(ReturnValue);
        }
        private void InitUserControlsManually()
        {
            // set controls in filter to default values
            ucoFilter.InitialiseUserControl();

            // Hook up EventFilterChanged Event to be able to react to changed filter
            ucoFilter.EventFilterChanged += new TEventHandlerEventFilterChanged(this.EventFilterChanged);

            //grdEvent.AutoSizeCells();

            // now the filter is initialized we can load the initial data
            LoadEventListData();

            grdEvent.Columns.Clear();

            grdEvent.AddTextColumn("Event Name", FEventTable.Columns[PPartnerTable.GetPartnerShortNameDBName()]);
            grdEvent.AddTextColumn("Event Code", FEventTable.Columns[PUnitTable.GetOutreachCodeDBName()]);
            grdEvent.AddTextColumn("Country", FEventTable.Columns[PCountryTable.GetCountryNameDBName()]);
            grdEvent.AddDateColumn("Start Date", FEventTable.Columns[PPartnerLocationTable.GetDateEffectiveDBName()]);
            grdEvent.AddDateColumn("End Date", FEventTable.Columns[PPartnerLocationTable.GetDateGoodUntilDBName()]);
            grdEvent.AddPartnerKeyColumn("Event Key", FEventTable.Columns[PPartnerTable.GetPartnerKeyDBName()]);
            grdEvent.AddTextColumn("Event Type", FEventTable.Columns[PUnitTable.GetUnitTypeCodeDBName()]);

            FEventTable.DefaultView.AllowDelete = false;
            FEventTable.DefaultView.AllowEdit   = false;
            FEventTable.DefaultView.AllowNew    = false;

            grdEvent.Selection.EnableMultiSelection = false;
            grdEvent.AutoResizeGrid();
            grdEvent.Selection.SelectRow(1, true);
        }
예제 #6
0
        public static DataTable GetOutreachTypes(long APartnerKey)
        {
            TDBTransaction ReadTransaction = null;

            DataTable Table = new PUnitTable();

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref ReadTransaction,
                                                           delegate
            {
                string OutreachPrefixCode =
                    ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix;

                string Query = "SELECT" +
                               " p_unit.p_partner_key_n," +
                               " SUBSTRING (p_unit.p_outreach_code_c,6,6) AS p_outreach_code_c," +
                               " p_unit.p_unit_name_c" +

                               " FROM p_unit" +

                               " WHERE LENGTH(p_unit.p_outreach_code_c) = 13" +
                               " AND SUBSTRING(p_unit.p_outreach_code_c,1,5) = '" + OutreachPrefixCode + "'";

                DBAccess.GDBAccessObj.SelectDT(Table, Query, ReadTransaction);
            });

            return(Table);
        }
예제 #7
0
        private void LoadListData(string AFilter)
        {
            string     CheckedMember = "CHECKED";
            string     ValueMember   = PUnitTable.GetPartnerKeyDBName();
            string     DisplayMember = PUnitTable.GetUnitNameDBName();
            PUnitTable Table;

            // retrieve data from server
            Table = TRemote.MPartner.Partner.WebConnectors.GetLedgerUnits(AFilter);

            DataView view = new DataView(Table);

            DataTable NewTable = view.ToTable(true, new string[] { ValueMember, DisplayMember });

            NewTable.Columns.Add(new DataColumn(CheckedMember, typeof(bool)));

            clbLedger.Columns.Clear();
            clbLedger.AddCheckBoxColumn("", NewTable.Columns[CheckedMember], 17, false);
            clbLedger.AddTextColumn(Catalog.GetString("Ledger Name"), NewTable.Columns[DisplayMember], 240);
            clbLedger.AddPartnerKeyColumn(Catalog.GetString("Partner Key"), NewTable.Columns[ValueMember], 100);

            clbLedger.DataBindGrid(NewTable, DisplayMember, CheckedMember, ValueMember, false, true, false);

            // allow 'any' selection for receipt frequency
            DataRow emptyRow = cmbReceiptLetterFrequency.Table.NewRow();

            emptyRow[0] = string.Empty;
            emptyRow[1] = Catalog.GetString("Any Frequency");
            cmbReceiptLetterFrequency.Table.Rows.Add(emptyRow);
        }
예제 #8
0
        private void LoadListData(string AFilter)
        {
            string     CheckedMember = "CHECKED";
            string     ValueMember   = PUnitTable.GetPartnerKeyDBName();
            string     DisplayMember = PUnitTable.GetUnitNameDBName();
            PUnitTable Table;

            Table = TRemote.MPartner.Partner.WebConnectors.GetActiveFieldUnits(AFilter);

            DataView view = new DataView(Table);

            DataTable NewTable = view.ToTable(true, new string[] { ValueMember, DisplayMember });

            NewTable.Columns.Add(new DataColumn(CheckedMember, typeof(bool)));

            clbField.Columns.Clear();
            clbField.AddCheckBoxColumn("", NewTable.Columns[CheckedMember], 17, false);
            clbField.AddTextColumn(Catalog.GetString("Field Name"), NewTable.Columns[DisplayMember], 240);
            clbField.AddPartnerKeyColumn(Catalog.GetString("Partner Key"), NewTable.Columns[ValueMember], 100);

            clbField.DataBindGrid(NewTable, DisplayMember, CheckedMember, ValueMember, false, true, false);

            //TODO: only temporarily until settings file exists
            clbField.SetCheckedStringList("");
        }
예제 #9
0
        /// <summary>
        /// Gets the filter criteria.
        /// </summary>
        /// <returns></returns>
        public string GetFilterCriteria()
        {
            string ReturnValue = PUnitTable.GetUnitNameDBName() + " LIKE '" + NameFilter + "%'";

            // add filter for current and future events
            if (CurrentAndFutureEventsOnly)
            {
                ReturnValue += " AND " + PPartnerLocationTable.GetDateGoodUntilDBName() + " >= '" + DateTime.Today.Date + "'";
            }

            // add filter for conference and/or outreach
            String ConferenceWhereClause = "(" +
                                           PUnitTable.GetUnitTypeCodeDBName() + " LIKE '%CONF%' OR " +
                                           PUnitTable.GetUnitTypeCodeDBName() + " LIKE '%CONG%')";

            String OutreachWhereClause = PUnitTable.GetOutreachCodeDBName() + " IS NOT NULL AND " +
                                         PUnitTable.GetOutreachCodeDBName() + " <> '' AND (" +
                                         PUnitTable.GetUnitTypeCodeDBName() + " NOT LIKE '%CONF%' AND " +
                                         PUnitTable.GetUnitTypeCodeDBName() + " NOT LIKE '%CONG%')";

            if (IncludeConferenceUnits && IncludeOutreachUnits)
            {
                ReturnValue += " AND ((" + ConferenceWhereClause + ") OR (" + OutreachWhereClause + "))";
            }
            else if (IncludeConferenceUnits)
            {
                ReturnValue += " AND (" + ConferenceWhereClause + ")";
            }
            else if (IncludeOutreachUnits)
            {
                ReturnValue += " AND (" + OutreachWhereClause + ")";
            }

            return(ReturnValue);
        }
예제 #10
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="e"></param>
        /// <param name="AMainDS"></param>
        /// <param name="AVerificationResult"></param>
        /// <returns></returns>
        public static Boolean VerifyUnitData(DataColumnChangeEventArgs e, PartnerEditTDS AMainDS, out TVerificationResult AVerificationResult)
        {
            Boolean ReturnValue;

            AVerificationResult = null;

            if (e.Column.ColumnName == PUnitTable.GetUnitNameDBName())
            {
                VerifyUnitNameChange(e, AMainDS, out AVerificationResult);
            }

            // any verification errors?
            if (AVerificationResult == null)
            {
                ReturnValue = true;
            }
            else
            {
                ReturnValue = false;

                // MessageBox.Show('VerifyUnitData: There was an error!');
            }

            return(ReturnValue);
        }
        /// <summary>
        /// Initialisation
        /// </summary>
        public void InitUserControlsManually()
        {
            FUnitTable = TRemote.MConference.WebConnectors.GetOutreachOptions(FUnitKey);
            FUnitTable.Columns.Add("Is Selected", Type.GetType("System.Boolean"));

            for (int Counter = 0; Counter < FUnitTable.Rows.Count; ++Counter)
            {
                FUnitTable.Rows[Counter]["Is Selected"] = false;
            }

            grdOutreachOption.AddCheckBoxColumn("", FUnitTable.Columns["Is Selected"]);
            grdOutreachOption.AddTextColumn("Outreach Code", FUnitTable.ColumnOutreachCode);
            grdOutreachOption.AddTextColumn("Unit Name", FUnitTable.ColumnUnitName);
            grdOutreachOption.AddTextColumn("Unit Key", FUnitTable.ColumnPartnerKey);

            FUnitTable.DefaultView.AllowNew    = false;
            FUnitTable.DefaultView.AllowEdit   = true;
            FUnitTable.DefaultView.AllowDelete = false;

            // automatically check all options
            SelectOutreachOptions(true);

            grdOutreachOption.DataSource       = new DevAge.ComponentModel.BoundDataView(FUnitTable.DefaultView);
            grdOutreachOption.DoubleClickCell += new TDoubleClickCellEventHandler(grdOutreachOptionDoubleClick);
        }
        private void LoadEventListData()
        {
            string    CheckedMember   = "CHECKED";
            string    ValueMember     = PPartnerTable.GetPartnerKeyDBName();
            string    DisplayMember   = PPartnerTable.GetPartnerShortNameDBName();
            string    EventCodeMember = PUnitTable.GetOutreachCodeDBName();
            DataTable Table;

            Table = TRemote.MPartner.Partner.WebConnectors.GetEventUnits
                        (ucoFilter.IncludeConferenceUnits, ucoFilter.IncludeOutreachUnits,
                        ucoFilter.NameFilter, false, ucoFilter.CurrentAndFutureEventsOnly);

            DataView view = new DataView(Table);

            DataTable NewTable = view.ToTable(true, new string[] { DisplayMember, ValueMember, EventCodeMember });

            NewTable.Columns.Add(new DataColumn(CheckedMember, typeof(bool)));

            clbEvent.Columns.Clear();
            clbEvent.AddCheckBoxColumn("", NewTable.Columns[CheckedMember], 17, false);
            clbEvent.AddTextColumn(Catalog.GetString("Event Name"), NewTable.Columns[DisplayMember], 240);
            clbEvent.AddPartnerKeyColumn(Catalog.GetString("Partner Key"), NewTable.Columns[ValueMember], 100);

            // outreach/event code column only needed in case of displaying Outreaches
            if (ucoFilter.IncludeOutreachUnits)
            {
                clbEvent.AddTextColumn(Catalog.GetString("Event Code"), NewTable.Columns[EventCodeMember], 110);
            }

            clbEvent.DataBindGrid(NewTable, DisplayMember, CheckedMember, ValueMember, false, true, false);

            //TODO: only temporarily until settings file exists
            clbEvent.SetCheckedStringList("");
        }
        private void InitializeManualCode()
        {
            string        CurrencyCode;
            string        CurrencyName;
            string        ConferenceName;
            TPartnerClass PartnerClass;

            // display the conference name in the title bar and in a text box at the top of the screen
            TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetPartnerShortName(FPartnerKey, out ConferenceName, out PartnerClass);
            this.Text = this.Text + " [" + ConferenceName + "]";
            txtConferenceName.Text = ConferenceName;

            // display the conference currency in a text box at the top of the screen and in pnlDetails
            TRemote.MConference.Conference.WebConnectors.GetCurrency(FPartnerKey, out CurrencyCode, out CurrencyName);
            txtConferenceCurrency.Text       = CurrencyCode + ": " + CurrencyName;
            txtDetailSupplement.CurrencyCode = CurrencyCode;

            DataTable Table = TRemote.MConference.Conference.WebConnectors.GetOutreachTypes(FPartnerKey);

            // add empty row
            DataRow emptyRow = Table.NewRow();

            emptyRow[PUnitTable.ColumnPartnerKeyId]   = -1;
            emptyRow[PUnitTable.ColumnOutreachCodeId] = string.Empty;
            emptyRow[PUnitTable.ColumnUnitNameId]     = Catalog.GetString("Select an outreach");
            Table.Rows.Add(emptyRow);

            // populate the combo box
            cmbDetailOutreachType.InitialiseUserControl(Table,
                                                        PUnitTable.GetOutreachCodeDBName(),
                                                        PUnitTable.GetUnitNameDBName(),
                                                        null);
            cmbDetailOutreachType.AppearanceSetup(new int[] { -1, 500 }, -1);
        }
예제 #14
0
        private void FilterList(System.Object sender, EventArgs e)
        {
            DataView view = new DataView(FFieldTable);

            view.RowFilter = PUnitTable.GetUnitNameDBName() + " LIKE '" + txtFilterFields.Text + "%'";

            clbLedger.DataBindGrid(view.ToTable(), PUnitTable.GetUnitNameDBName(), "CHECKED", PUnitTable.GetPartnerKeyDBName(), false, true, false);
        }
예제 #15
0
        private static bool GetAllReceivingFields(long AConferenceKey, ref DataTable AFieldsTable)
        {
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;

            TLogging.LogAtLevel(9, "TConferenceOptions.GetAllReceivingFields called!");

            TDataBase db = DBAccess.Connect("GetAllReceivingFields");

            ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                             out NewTransaction);

            try
            {
                OdbcParameter[] ParametersArray;

                ParametersArray = new OdbcParameter[0];

                DataSet TmpDS = ReadTransaction.DataBaseObj.Select(
                    "SELECT PUB_" + PUnitTable.GetTableDBName() + '.' + PUnitTable.GetPartnerKeyDBName() +
                    ", PUB_" + PUnitTable.GetTableDBName() + '.' + PUnitTable.GetUnitNameDBName() +
                    " FROM PUB_" + PUnitTable.GetTableDBName() +
                    ", PUB_" + PPartnerTable.GetTableDBName() + ", " +
                    "PUB_" + PPartnerTypeTable.GetTableDBName() +
                    " WHERE PUB_" + PUnitTable.GetTableDBName() + '.' + PUnitTable.GetPartnerKeyDBName() +
                    " = PUB_" + PPartnerTable.GetTableDBName() + '.' + PPartnerTable.GetPartnerKeyDBName() +
                    " AND PUB_" + PPartnerTypeTable.GetTableDBName() + '.' + PPartnerTypeTable.GetPartnerKeyDBName() +
                    " = PUB_" + PPartnerTable.GetTableDBName() + '.' + PPartnerTable.GetPartnerKeyDBName() +
                    " AND PUB_" + PPartnerTable.GetTableDBName() + '.' + PPartnerTable.GetStatusCodeDBName() + " = \"ACTIVE\"" +
                    " AND PUB_" + PPartnerTypeTable.GetTableDBName() + '.' + PPartnerTypeTable.GetTypeCodeDBName() + " = \"LEDGER\"" +
                    " ORDER BY PUB_" + PUnitTable.GetTableDBName() + '.' + PUnitTable.GetUnitNameDBName() + " ASC",
                    "TempTable", ReadTransaction, ParametersArray);

                DataTable ResultTale = TmpDS.Tables[0];

                for (int Counter = 0; Counter < ResultTale.Rows.Count; ++Counter)
                {
                    DataRow NewRow = AFieldsTable.NewRow();

                    NewRow[SELECTION]          = false;
                    NewRow[UNIT_KEY]           = ResultTale.Rows[Counter][PUnitTable.GetPartnerKeyDBName()];
                    NewRow[UNIT_NAME]          = ResultTale.Rows[Counter][PUnitTable.GetUnitNameDBName()];
                    NewRow[USED_IN_CONFERENCE] = true;

                    AFieldsTable.Rows.Add(NewRow);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    ReadTransaction.Commit();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetReceivingFields: committed own transaction.");
                }
            }
            return(true);
        }
예제 #16
0
        /// <summary>
        /// Refresh Outreach Code for applications and conference
        /// </summary>
        public static void RefreshOutreachCode(Int64 AConferenceKey)
        {
            TDBTransaction              Transaction  = new TDBTransaction();
            bool                        SubmissionOK = true;
            PcConferenceTable           ConferenceTable;
            PUnitTable                  UnitTable;
            PmShortTermApplicationTable ShortTermAppTable;
            ConferenceApplicationTDS    MainDS;

            DBAccess.WriteTransaction(
                ref Transaction,
                ref SubmissionOK,
                delegate
            {
                ConferenceTable   = new PcConferenceTable();
                UnitTable         = new PUnitTable();
                ShortTermAppTable = new PmShortTermApplicationTable();
                MainDS            = new ConferenceApplicationTDS();

                // get the conference in order to update the OutreachPrefix
                ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction);

                if (ConferenceTable.Count == 0)
                {
                    throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000"));
                }

                // update OutreachPrefix in conference record in case it was changed in Unit record for event
                UnitTable = PUnitAccess.LoadByPrimaryKey(AConferenceKey, Transaction);

                if (UnitTable[0].OutreachCode.Length >= 5)
                {
                    ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode.Substring(0, 5);
                }
                else
                {
                    ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode;
                }

                MainDS.Merge(ConferenceTable);

                // update event code
                ShortTermAppTable = PmShortTermApplicationAccess.LoadViaPUnitStConfirmedOption(AConferenceKey, Transaction);

                foreach (PmShortTermApplicationRow ShortTermAppRow in ShortTermAppTable.Rows)
                {
                    ShortTermAppRow.ConfirmedOptionCode = UnitTable[0].OutreachCode;
                }

                MainDS.Merge(ShortTermAppTable);

                MainDS.ThrowAwayAfterSubmitChanges = true;

                ConferenceApplicationTDSAccess.SubmitChanges(MainDS);
            });
        }
예제 #17
0
        /// <summary>
        /// Refresh Outreach Code for applications and conference
        /// </summary>
        public static void RefreshOutreachCode(Int64 AConferenceKey)
        {
            TDBTransaction Transaction = null;
            bool SubmissionOK = true;
            PcConferenceTable ConferenceTable;
            PUnitTable UnitTable;
            PmShortTermApplicationTable ShortTermAppTable;
            ConferenceApplicationTDS MainDS;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                ref Transaction,
                ref SubmissionOK,
                delegate
                {
                    ConferenceTable = new PcConferenceTable();
                    UnitTable = new PUnitTable();
                    ShortTermAppTable = new PmShortTermApplicationTable();
                    MainDS = new ConferenceApplicationTDS();

                    // get the conference in order to update the OutreachPrefix
                    ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction);

                    if (ConferenceTable.Count == 0)
                    {
                        throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000"));
                    }

                    // update OutreachPrefix in conference record in case it was changed in Unit record for event
                    UnitTable = PUnitAccess.LoadByPrimaryKey(AConferenceKey, Transaction);

                    if (UnitTable[0].OutreachCode.Length >= 5)
                    {
                        ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode.Substring(0, 5);
                    }
                    else
                    {
                        ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode;
                    }

                    MainDS.Merge(ConferenceTable);

                    // update event code
                    ShortTermAppTable = PmShortTermApplicationAccess.LoadViaPUnitStConfirmedOption(AConferenceKey, Transaction);

                    foreach (PmShortTermApplicationRow ShortTermAppRow in ShortTermAppTable.Rows)
                    {
                        ShortTermAppRow.ConfirmedOptionCode = UnitTable[0].OutreachCode;
                    }

                    MainDS.Merge(ShortTermAppTable);

                    MainDS.ThrowAwayAfterSubmitChanges = true;

                    ConferenceApplicationTDSAccess.SubmitChanges(MainDS);
                });
        }
        private void UpdateDefaultCombobox(Boolean ADuringScreenActivation)
        {
            // update default combobox
            String SelectedSites       = clbSites.GetCheckedStringList();
            Int64  SelectedDefaultSite = 0;
            String SiteName;

            // remember original selection for default site
            if (ADuringScreenActivation)
            {
                SelectedDefaultSite = Convert.ToInt64(TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_SITEKEY));
            }
            else
            {
                if (cmbDefaultSite.SelectedValue != null)
                {
                    SelectedDefaultSite = Convert.ToInt64(cmbDefaultSite.SelectedValue);
                }
            }

            String[] SiteKeyArray = SelectedSites.Split(',');
            Int32    Counter      = 0;

            // initialize data table for combobox
            CmbDataTable.Clear();

            for (Counter = 0; Counter < SiteKeyArray.Length; Counter++)
            {
                if (SiteKeyArray[Counter] != "")
                {
                    // find site name for given key ("Find" does not work on DataTable as it does not have primary key)
                    SiteName = "";

                    foreach (DataRow SiteRow in AvailableSitesTable.Rows)
                    {
                        if (Convert.ToInt64(SiteRow[PUnitTable.GetPartnerKeyDBName()]) == Convert.ToInt64(SiteKeyArray[Counter]))
                        {
                            SiteName = SiteRow[PUnitTable.GetUnitNameDBName()].ToString();
                            break;
                        }
                    }

                    CmbDataTable.Rows.Add(string.Format("{0:0000000000}",
                                                        Convert.ToInt64(SiteKeyArray[Counter])) + " - " + SiteName, Convert.ToInt64(SiteKeyArray[Counter]));
                }
            }

            // now reselected the original selected default site
            if (SelectedDefaultSite > 0)
            {
                cmbDefaultSite.SelectedValue = SelectedDefaultSite;
            }
        }
예제 #19
0
        private static bool AddFieldToTable(long AFieldKey, ref DataTable AFieldsTable, ref TDBTransaction ATransaction)
        {
            // First check if the unit is already in the table
            foreach (DataRow Row in AFieldsTable.Rows)
            {
                if ((long)Row[UNIT_KEY] == AFieldKey)
                {
                    return(true);
                }
            }

            bool IsLedger = false;

            PUnitTable        UnitTable;
            PPartnerTypeTable PartnerTypeTable;

            StringCollection FieldList = new StringCollection();

            FieldList.Add(PUnitTable.GetUnitNameDBName());

            UnitTable        = PUnitAccess.LoadByPrimaryKey(AFieldKey, FieldList, ATransaction);
            PartnerTypeTable = PPartnerTypeAccess.LoadViaPPartner(AFieldKey, ATransaction);

            foreach (PPartnerTypeRow PartnerTypeRow in PartnerTypeTable.Rows)
            {
                if (PartnerTypeRow.TypeCode == "LEDGER")
                {
                    IsLedger = true;
                    break;
                }
            }

            if (!IsLedger)
            {
                return(false);
            }

            if (UnitTable.Rows.Count > 0)
            {
                DataRow NewRow = AFieldsTable.NewRow();

                NewRow[SELECTION]          = false;
                NewRow[UNIT_KEY]           = AFieldKey;
                NewRow[UNIT_NAME]          = UnitTable.Rows[0][PUnitTable.GetUnitNameDBName()];
                NewRow[USED_IN_CONFERENCE] = true;

                AFieldsTable.Rows.Add(NewRow);
            }

            return(true);
        }
        /// <summary>
        /// Returns all or only the selected outreach options
        /// </summary>
        /// <param name="ASelection">List with Unit key and Unit name of the selected outreach options</param>
        /// <param name="AAllOptionsInTable">True if all outreach options should be returned</param>
        public static void GetSelectedOutreachOptions(ref List <KeyValuePair <long, String> > ASelection,
                                                      bool AAllOptionsInTable)
        {
            foreach (DataRow Row in FUnitTable.Rows)
            {
                if (AAllOptionsInTable || (bool)Row["Is Selected"])
                {
                    long   UnitKey  = (long)Row[PUnitTable.GetPartnerKeyDBName()];
                    String UnitName = (String)Row[PUnitTable.GetUnitNameDBName()];

                    ASelection.Add(new KeyValuePair <long, String>(UnitKey, UnitName));
                }
            }
        }
예제 #21
0
        private DataTable GetConferenceListTable(TDBTransaction AReadTransaction, string ATableName)
        {
            DataTable Table;

            DataColumn[] Key = new DataColumn[1];

            // Used eg. Select Event Dialog
            Table = DBAccess.GetDBAccessObj(AReadTransaction).SelectDT(
                "SELECT DISTINCT " +
                PPartnerTable.GetPartnerShortNameDBName() +
                ", " + PPartnerTable.GetPartnerClassDBName() +
                ", " + PUnitTable.GetOutreachCodeDBName() +
                ", " + PCountryTable.GetTableDBName() + "." + PCountryTable.GetCountryNameDBName() +
                ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetDateEffectiveDBName() +
                ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetDateGoodUntilDBName() +
                ", " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() +
                ", " + PUnitTable.GetUnitTypeCodeDBName() +

                " FROM PUB." + PPartnerTable.GetTableDBName() +
                ", PUB." + PUnitTable.GetTableDBName() +
                ", PUB." + PLocationTable.GetTableDBName() +
                ", PUB." + PPartnerLocationTable.GetTableDBName() +
                ", PUB." + PCountryTable.GetTableDBName() +

                " WHERE " +
                PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + " = " +
                PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() + " AND " +
                PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + " = " +
                PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetPartnerKeyDBName() + " AND " +

                PLocationTable.GetTableDBName() + "." + PLocationTable.GetSiteKeyDBName() + " = " +
                PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetSiteKeyDBName() + " AND " +
                PLocationTable.GetTableDBName() + "." + PLocationTable.GetLocationKeyDBName() + " = " +
                PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetLocationKeyDBName() + " AND " +
                PCountryTable.GetTableDBName() + "." + PCountryTable.GetCountryCodeDBName() + " = " +
                PLocationTable.GetTableDBName() + "." + PLocationTable.GetCountryCodeDBName() + " AND " +


                PPartnerTable.GetStatusCodeDBName() + " = 'ACTIVE' AND " +
                PPartnerTable.GetPartnerClassDBName() + " = 'UNIT' AND (" +
                PUnitTable.GetUnitTypeCodeDBName() + " LIKE '%CONF%' OR " +
                PUnitTable.GetUnitTypeCodeDBName() + " LIKE '%CONG%')"
                ,
                ATableName, AReadTransaction);

            Key[0]           = Table.Columns[PPartnerTable.GetPartnerKeyDBName()];
            Table.PrimaryKey = Key;

            return(Table);
        }
예제 #22
0
        /// <summary>
        /// Get the units which start with the same outreach code as given with the prefix.
        /// </summary>
        /// <param name="AUnitKey">Partner Key of the unit from which the outreach options are retrieved</param>
        /// <param name="AConferenceTable">A table with all the units</param>
        /// <returns></returns>
        private static System.Boolean GetOutreachOptions(long AUnitKey,
                                                         out System.Data.DataTable AConferenceTable)
        {
            AConferenceTable = new DataTable();
            AConferenceTable.Columns.Add("Partner Key", Type.GetType("System.Int64"));
            AConferenceTable.Columns.Add("Outreach Code");
            AConferenceTable.Columns.Add("Unit Name");

            String     ConferenceCodePrefix = "";
            PUnitTable UnitTable            = new PUnitTable();
            PUnitRow   TemplateRow          = UnitTable.NewRowTyped(false);

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!");

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(ref Transaction,
                                     delegate
            {
                /* Load data */
                UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, Transaction);

                if (UnitTable.Rows.Count > 0)
                {
                    ConferenceCodePrefix = ((PUnitRow)UnitTable.Rows[0]).OutreachCode.Substring(0, 5);

                    UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, null, null, Transaction);
                }
            });

            foreach (PUnitRow UnitRow in UnitTable.Rows)
            {
                if (!UnitRow.OutreachCode.StartsWith(ConferenceCodePrefix, true, null))
                {
                    continue;
                }

                DataRow NewRow = AConferenceTable.NewRow();

                NewRow["Partner Key"]   = UnitRow.PartnerKey;
                NewRow["Outreach Code"] = UnitRow.OutreachCode;
                NewRow["Unit Name"]     = UnitRow.UnitName;

                AConferenceTable.Rows.Add(NewRow);
            }

            return(true);
        }
예제 #23
0
        public static PUnitTable GetOutreachOptions(Int64 AUnitKey)
        {
            String         ConferenceCodePrefix = "";
            PUnitTable     UnitTable            = new PUnitTable();
            PUnitRow       TemplateRow          = UnitTable.NewRowTyped(false);
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!");

            TDataBase db = DBAccess.Connect("GetOutreachOptions");

            ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                             out NewTransaction);

            try
            {
                /* Load data */
                UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, ReadTransaction);

                if (UnitTable.Rows.Count > 0)
                {
                    String ConferenceCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;

                    if (ConferenceCode.Length >= 5)
                    {
                        ConferenceCodePrefix = ConferenceCode.Substring(0, 5) + "%";
                    }

                    StringCollection operators = new StringCollection();
                    operators.Add("LIKE");
                    TemplateRow.OutreachCode = ConferenceCodePrefix;

                    UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, operators, null, ReadTransaction);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    ReadTransaction.Commit();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetOutreachOptions: committed own transaction.");
                }
            }
            return(UnitTable);
        }
예제 #24
0
        public static PUnitTable GetOutreachOptions(Int64 AUnitKey)
        {
            String ConferenceCodePrefix = "";
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow TemplateRow = UnitTable.NewRowTyped(false);
            TDBTransaction ReadTransaction;
            Boolean NewTransaction = false;

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!");

            ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                TEnforceIsolationLevel.eilMinimum,
                out NewTransaction);

            try
            {
                /* Load data */
                UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, ReadTransaction);

                if (UnitTable.Rows.Count > 0)
                {
                    String ConferenceCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;

                    if (ConferenceCode.Length >= 5)
                    {
                        ConferenceCodePrefix = ConferenceCode.Substring(0, 5) + "%";
                    }

                    StringCollection operators = new StringCollection();
                    operators.Add("LIKE");
                    TemplateRow.OutreachCode = ConferenceCodePrefix;

                    UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, operators, null, ReadTransaction);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetOutreachOptions: committed own transaction.");
                }
            }
            return UnitTable;
        }
예제 #25
0
 /// <summary>
 /// Loads all costcentres that are linked to a partner, with the partner key and partner class
 /// </summary>
 public static DataTable GetData(String ATableName, Int32 ALedgerNumber, TDBTransaction AReadTransaction)
 {
     return(DBAccess.GDBAccessObj.SelectDT(
                String.Format(
                    "SELECT {0}, {3}.{1}, {3}.{5}, {2}, {8} FROM pub_{3} " +
                    "LEFT OUTER JOIN PUB_{7} ON PUB_{7}.{1} = PUB_{3}.{1}, pub_{4} " +
                    "WHERE pub_{3}.{1} = pub_{4}.{1} AND pub_{3}.{5} = {6}",
                    AValidLedgerNumberTable.GetCostCentreCodeDBName(),
                    AValidLedgerNumberTable.GetPartnerKeyDBName(),
                    PPartnerTable.GetPartnerClassDBName(),
                    AValidLedgerNumberTable.GetTableDBName(),
                    PPartnerTable.GetTableDBName(),
                    AValidLedgerNumberTable.GetLedgerNumberDBName(),
                    ALedgerNumber.ToString(),
                    PUnitTable.GetTableDBName(),
                    PUnitTable.GetUnitTypeCodeDBName()),
                ATableName,
                AReadTransaction));
 }
예제 #26
0
        public static string GetOutreachCode(Int64 APartnerKey)
        {
            string         ReturnValue = "";
            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(
                ref Transaction,
                delegate
            {
                PUnitTable UnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, Transaction);

                if (UnitTable.Count > 0)
                {
                    ReturnValue = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;
                }
            });

            return(ReturnValue);
        }
예제 #27
0
        public static string GetOutreachCode(Int64 APartnerKey)
        {
            string         ReturnValue = "";
            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                PUnitTable UnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, Transaction);

                if (UnitTable.Count > 0)
                {
                    ReturnValue = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;
                }
            });

            return(ReturnValue);
        }
예제 #28
0
        private static String GetConferencePrefix(long AConferenceKey)
        {
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction   = false;
            String         ConferencePrefix = "-----";
            PUnitTable     UnitTable;

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachPrefix: called.");

            TDataBase db = DBAccess.Connect("GetConferencePrefix");

            ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                             out NewTransaction);

            try
            {
                UnitTable = PUnitAccess.LoadByPrimaryKey(AConferenceKey, ReadTransaction);

                if (UnitTable.Rows.Count > 0)
                {
                    if (UnitTable.Rows[0][PUnitTable.GetOutreachCodeDBName()] != System.DBNull.Value)
                    {
                        ConferencePrefix = (string)UnitTable.Rows[0][PUnitTable.GetOutreachCodeDBName()];

                        if (ConferencePrefix.Length > 5)
                        {
                            ConferencePrefix = ConferencePrefix.Substring(0, 5);
                        }
                    }
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    ReadTransaction.Commit();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetOutreachPrefix: committed own transaction.");
                }
            }

            return(ConferencePrefix);
        }
        public static DataTable GetOutreachTypes(long APartnerKey)
        {
            TDBTransaction ReadTransaction;

            ReadTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            DataTable Table = new PUnitTable();

            try
            {
                string OutreachPrefixCode =
                    ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix;

                PUnitTable UnitTable = PUnitAccess.LoadAll(ReadTransaction);

                // add PUnit rows with matching OutreachPrefixCode to the new DataTable
                foreach (PUnitRow Row in UnitTable.Rows)
                {
                    if ((Row.OutreachCode.Length == 13) && (Row.OutreachCode.Substring(0, 5) == OutreachPrefixCode))
                    {
                        DataRow CopyRow = Table.NewRow();
                        ((PUnitRow)CopyRow).PartnerKey   = Row.PartnerKey;
                        ((PUnitRow)CopyRow).OutreachCode = Row.OutreachCode.Substring(5, 6);
                        ((PUnitRow)CopyRow).UnitName     = Row.UnitName;
                        Table.Rows.Add(CopyRow);
                    }
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetOutreachTypes: commit own transaction.");
            }

            return(Table);
        }
        public static PUnitTable GetActiveFieldUnits()
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow   UnitRow;

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetActiveFieldUnits called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                // Load data
                string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                 " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTable.GetTableDBName() +
                                 " WHERE ((" + PUnitTable.GetOutreachCodeDBName() + " IS NULL)" +
                                 "        OR(" + PUnitTable.GetOutreachCodeDBName() + " = ''))" +
                                 " AND " + PUnitTable.GetUnitTypeCodeDBName() + " <> 'KEY-MIN'" +
                                 " AND pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 " = pub_" + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() +
                                 " AND " + PPartnerTable.GetStatusCodeDBName() + " = 'ACTIVE'";

                // sort rows according to name
                SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "fields", Transaction);

                foreach (DataRow eventRow in events.Rows)
                {
                    UnitRow            = (PUnitRow)UnitTable.NewRow();
                    UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                    UnitRow.UnitName   = Convert.ToString(eventRow[1]);
                    UnitTable.Rows.Add(UnitRow);
                }
            });

            return(UnitTable);
        }
예제 #31
0
        /// <summary>
        /// Returns the Unit Structure Info for a Partner of Partner Class UNIT.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the UNIT.</param>
        /// <param name="AReadTransaction">Open DB Transaction.</param>
        /// <returns>An Instance of <see cref="PartnerInfoTDSUnitInfoTable" />.
        /// Contains one DataRow if Unit Structure information could be retrieved, otherwise no DataRow.</returns>
        private static PartnerInfoTDSUnitInfoTable GetUnitStructure(Int64 APartnerKey, TDBTransaction AReadTransaction)
        {
            PartnerInfoTDSUnitInfoTable UnitInfoDT = new PartnerInfoTDSUnitInfoTable();

            UmUnitStructureTable UnitStructureDT = UmUnitStructureAccess.LoadViaPUnitChildUnitKey(APartnerKey, AReadTransaction);

            if (UnitStructureDT.Rows.Count > 0)
            {
                PUnitTable UnitDT = PUnitAccess.LoadByPrimaryKey(UnitStructureDT[0].ParentUnitKey, AReadTransaction);

                if (UnitDT != null)
                {
                    PartnerInfoTDSUnitInfoRow UnitInfoDR = UnitInfoDT.NewRowTyped(false);
                    UnitInfoDR.ParentUnitKey  = UnitDT[0].PartnerKey;
                    UnitInfoDR.ParentUnitName = UnitDT[0].UnitName;

                    UnitInfoDT.Rows.Add(UnitInfoDR);
                }
            }

            return(UnitInfoDT);
        }
        private void LoadEventListData()
        {
            string CheckedMember   = "CHECKED";
            string ValueMember     = PPartnerTable.GetPartnerKeyDBName();
            string DisplayMember   = PPartnerTable.GetPartnerShortNameDBName();
            string EventCodeMember = PUnitTable.GetOutreachCodeDBName();

            FOutreachUnitsTable = TRemote.MPartner.Partner.WebConnectors.GetEventUnits();
            FOutreachUnitsTable.Columns.Add(new DataColumn("CHECKED", typeof(bool)));

            clbEvent.Columns.Clear();
            clbEvent.AddCheckBoxColumn("", FOutreachUnitsTable.Columns[CheckedMember], 17, false);
            clbEvent.AddTextColumn(Catalog.GetString("Event Name"), FOutreachUnitsTable.Columns[DisplayMember]);
            clbEvent.AddPartnerKeyColumn(Catalog.GetString("Partner Key"), FOutreachUnitsTable.Columns[ValueMember]);

            // outreach/event code column only needed in case of displaying Outreaches
            if (ucoFilter.IncludeOutreachUnits)
            {
                clbEvent.AddTextColumn(Catalog.GetString("Event Code"), FOutreachUnitsTable.Columns[EventCodeMember]);
            }

            EventFilterChanged(this, null);
        }
        public static PUnitTable GetLedgerUnits()
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow   UnitRow;

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetLedgerUnits called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                // Load data
                string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                 " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTypeTable.GetTableDBName() +
                                 " WHERE pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 " = pub_" + PPartnerTypeTable.GetTableDBName() + "." + PPartnerTypeTable.GetPartnerKeyDBName() +
                                 " AND " + PPartnerTypeTable.GetTypeCodeDBName() + " = '" + MPartnerConstants.PARTNERTYPE_LEDGER + "'";

                // sort rows according to name
                SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "ledgers", Transaction);

                foreach (DataRow eventRow in events.Rows)
                {
                    UnitRow            = (PUnitRow)UnitTable.NewRow();
                    UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                    UnitRow.UnitName   = Convert.ToString(eventRow[1]);
                    UnitTable.Rows.Add(UnitRow);
                }
            });

            return(UnitTable);
        }
예제 #34
0
        /// <summary>
        /// This function fills the combobox for the key ministry depending on the partnerkey
        /// </summary>
        /// <param name="ACmbKeyMinistry"></param>
        /// <param name="APartnerKey"></param>
        /// <param name="AFieldNumber"></param>
        /// <param name="ARefreshData"></param>
        private static void GetRecipientData(ref TCmbAutoPopulated ACmbKeyMinistry,
            Int64 APartnerKey,
            out Int64 AFieldNumber,
            Boolean ARefreshData = false)
        {
            string CurrentRowFilter = string.Empty;

            AFieldNumber = 0;

            if ((FKeyMinTable != null) && !ARefreshData)
            {
                if (FindAndSelect(ref ACmbKeyMinistry, APartnerKey))
                {
                    return;
                }
            }
            else if ((FKeyMinTable != null) && ARefreshData)
            {
                FKeyMinTable.Clear();
                FKeyMinTable = null;
            }

            string DisplayMember = PUnitTable.GetUnitNameDBName();
            string ValueMember = PUnitTable.GetPartnerKeyDBName();

            try
            {
                FKeyMinTable = TRemote.MFinance.Gift.WebConnectors.LoadKeyMinistry(APartnerKey, out FFieldNumber);

                AFieldNumber = FFieldNumber;

                CurrentRowFilter = FKeyMinTable.DefaultView.RowFilter;
                FKeyMinTable.DefaultView.RowFilter = String.Format("{0}='{1}'",
                    PUnitTable.GetUnitTypeCodeDBName(),
                    MPartnerConstants.UNIT_TYPE_KEYMIN);

                FKeyMinTable.DefaultView.Sort = DisplayMember + " Desc";

                DataTable dt = FKeyMinTable.DefaultView.ToTable();

                ACmbKeyMinistry.InitialiseUserControl(dt,
                    ValueMember,
                    DisplayMember,
                    DisplayMember,
                    null);
                ACmbKeyMinistry.AppearanceSetup(new int[] { 500 }, -1);

                if (!FindAndSelect(ref ACmbKeyMinistry, APartnerKey))
                {
                    //Clear the combobox
                    ACmbKeyMinistry.SelectedIndex = -1;
                }
            }
            finally
            {
                FKeyMinTable.DefaultView.RowFilter = CurrentRowFilter;
            }
        }
예제 #35
0
        /// <summary>
        /// Load/Refresh all Attendees for a conference
        /// </summary>
        public static void RefreshAttendees(Int64 AConferenceKey)
        {
            TDBTransaction Transaction = null;
            bool SubmissionOK = true;
            PcConferenceTable ConferenceTable;
            PUnitTable UnitTable;
            string OutreachPrefix = String.Empty;
            ConferenceApplicationTDS MainDS;

            // make sure outreach codes are up to date in case it has changed in Unit record
            RefreshOutreachCode(AConferenceKey);

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                ref Transaction,
                ref SubmissionOK,
                delegate
                {
                    ConferenceTable = new PcConferenceTable();
                    UnitTable = new PUnitTable();
                    MainDS = new ConferenceApplicationTDS();

                    // get the conference prefix which links all outreaches associated with a conference
                    ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction);

                    if (ConferenceTable.Count == 0)
                    {
                        throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000"));
                    }

                    OutreachPrefix = ConferenceTable[0].OutreachPrefix;

                    // load application data for all conference attendees from db
                    TApplicationManagement.GetApplications(ref MainDS, AConferenceKey, OutreachPrefix, "all", -1, true, null, false);

                    // check a valid pcattendee record exists for each short term application
                    foreach (PmShortTermApplicationRow ShortTermAppRow in MainDS.PmShortTermApplication.Rows)
                    {
                        if (!IsAttendeeValid(MainDS, OutreachPrefix, ShortTermAppRow.PartnerKey))
                        {
                            // ignore deleted applications, or cancelled applications
                            continue;
                        }

                        // update outreach code in application (it may have changed)
                        UnitTable = PUnitAccess.LoadByPrimaryKey(ShortTermAppRow.StConfirmedOption, Transaction);
                        ShortTermAppRow.ConfirmedOptionCode = ((PUnitRow)UnitTable.Rows[0]).OutreachCode;

                        // Do we have a record for this attendee yet?
                        bool AttendeeRecordExists = false;

                        if (MainDS.PcAttendee.Rows.Contains(new object[] { AConferenceKey, ShortTermAppRow.PartnerKey }))
                        {
                            AttendeeRecordExists = true;
                        }

                        // create a new PcAttendee record if one does not already exist for this attendee
                        if (!AttendeeRecordExists)
                        {
                            PcAttendeeRow AttendeeRow = MainDS.PcAttendee.NewRowTyped();

                            AttendeeRow.ConferenceKey = AConferenceKey;
                            AttendeeRow.PartnerKey = ShortTermAppRow.PartnerKey;

                            if (ShortTermAppRow.ConfirmedOptionCode.Length >= 11)
                            {
                                AttendeeRow.OutreachType = ShortTermAppRow.ConfirmedOptionCode.Substring(5, 6);
                            }

                            PmGeneralApplicationRow GeneralAppRow = (PmGeneralApplicationRow)MainDS.PmGeneralApplication.Rows.Find(
                                new object[] { ShortTermAppRow.PartnerKey, ShortTermAppRow.ApplicationKey, ShortTermAppRow.RegistrationOffice });

                            DateTime DateAccepted = GeneralAppRow.GenAppDate;

                            if (!GeneralAppRow.IsGenAppSendFldAcceptDateNull())
                            {
                                DateAccepted = GeneralAppRow.GenAppSendFldAcceptDate.Value;
                            }
                            else if (!GeneralAppRow.IsGenAppRecvgFldAcceptNull())
                            {
                                DateAccepted = GeneralAppRow.GenAppRecvgFldAccept.Value;
                            }

                            AttendeeRow.Registered = DateAccepted;

                            // TODO: in Petra 2.x, this was calculated from pm_staff_data
                            AttendeeRow.HomeOfficeKey = ShortTermAppRow.RegistrationOffice;

                            if (AttendeeRow.HomeOfficeKey == 0)
                            {
                                AttendeeRow.HomeOfficeKey = ((int)AttendeeRow.PartnerKey / 1000000) * 1000000;
                            }

                            MainDS.PcAttendee.Rows.Add(AttendeeRow);
                        }
                    }

                    PcRoomAllocTable RoomAllocTable = null;
                    PcExtraCostTable ExtraCostTable = null;

                    // now check the other way: all attendees of this conference, are they still valid?
                    foreach (PcAttendeeRow AttendeeRow in MainDS.PcAttendee.Rows)
                    {
                        if ((AttendeeRow.RowState != DataRowState.Added)
                            && !IsAttendeeValid(MainDS, OutreachPrefix, AttendeeRow.PartnerKey))
                        {
                            // remove their accommodation
                            RoomAllocTable = PcRoomAllocAccess.LoadViaPcAttendee(AttendeeRow.ConferenceKey, AttendeeRow.PartnerKey, Transaction);

                            foreach (DataRow Row in RoomAllocTable.Rows)
                            {
                                Row.Delete();
                            }

                            if (RoomAllocTable != null)
                            {
                                PcRoomAllocAccess.SubmitChanges(RoomAllocTable, Transaction);
                            }

                            // remove any extra costs
                            ExtraCostTable = PcExtraCostAccess.LoadViaPcAttendee(AttendeeRow.ConferenceKey, AttendeeRow.PartnerKey, Transaction);

                            foreach (DataRow Row in ExtraCostTable.Rows)
                            {
                                Row.Delete();
                            }

                            if (ExtraCostTable != null)
                            {
                                PcExtraCostAccess.SubmitChanges(ExtraCostTable, Transaction);
                            }

                            // remove attendee
                            AttendeeRow.Delete();
                        }
                    }

                    int shorttermApplicationsCount = MainDS.PmShortTermApplication.Count;
                    int attendeeCount = MainDS.PcAttendee.Count;

                    MainDS.ThrowAwayAfterSubmitChanges = true;

                    ConferenceApplicationTDSAccess.SubmitChanges(MainDS);
                });
        }
예제 #36
0
        private static PUnitTable LoadKeyMinistriesOfField(Int64 APartnerKey, TDBTransaction ATransaction)
        {
            #region Validate Arguments

            if (APartnerKey < 0)
            {
                throw new ArgumentException(String.Format(Catalog.GetString("Function:{0} - The Partner Key cannot be negative!"),
                        Utilities.GetMethodName(true)));
            }
            else if (ATransaction == null)
            {
                throw new EFinanceSystemDBTransactionNullException(String.Format(Catalog.GetString(
                            "Function:{0} - Database Transaction must not be NULL!"),
                        Utilities.GetMethodName(true)));
            }

            #endregion Validate Arguments

            string sqlLoadKeyMinistriesOfField =
                "SELECT unit.* FROM PUB_um_unit_structure us, PUB_p_unit unit, PUB_p_partner partner " +
                "WHERE us.um_parent_unit_key_n = " + APartnerKey.ToString() + " " +
                "AND unit.p_partner_key_n = us.um_child_unit_key_n " +
                "AND unit.u_unit_type_code_c = '" + MPartnerConstants.UNIT_TYPE_KEYMIN + "' " +
                "AND partner.p_partner_key_n = unit.p_partner_key_n " +
                "AND partner.p_status_code_c = '" + MPartnerConstants.PARTNERSTATUS_ACTIVE + "'";

            PUnitTable UnitTable = new PUnitTable();

            DBAccess.GDBAccessObj.SelectDT(UnitTable, sqlLoadKeyMinistriesOfField, ATransaction, new OdbcParameter[0], 0, 0);

            return UnitTable;
        }
예제 #37
0
        private static PUnitTable LoadKeyMinistriesOfField(Int64 partnerKey, TDBTransaction ATransaction)
        {
            string sqlLoadKeyMinistriesOfField =
                "SELECT unit.* FROM PUB_um_unit_structure us, PUB_p_unit unit, PUB_p_partner partner " +
                "WHERE us.um_parent_unit_key_n = " + partnerKey.ToString() + " " +
                "AND unit.p_partner_key_n = us.um_child_unit_key_n " +
                "AND unit.u_unit_type_code_c = '" + MPartnerConstants.UNIT_TYPE_KEYMIN + "' " +
                "AND partner.p_partner_key_n = unit.p_partner_key_n " +
                "AND partner.p_status_code_c = '" + MPartnerConstants.PARTNERSTATUS_ACTIVE + "'";

            PUnitTable UnitTable = new PUnitTable();

            DBAccess.GDBAccessObj.SelectDT(UnitTable, sqlLoadKeyMinistriesOfField, ATransaction, new OdbcParameter[0], 0, 0);

            return UnitTable;
        }
        public static DataTable GetOutreachTypes(long APartnerKey)
        {
            TDBTransaction ReadTransaction;

            ReadTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            DataTable Table = new PUnitTable();

            try
            {
                string OutreachPrefixCode =
                    ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix;

                PUnitTable UnitTable = PUnitAccess.LoadAll(ReadTransaction);

                // add PUnit rows with matching OutreachPrefixCode to the new DataTable
                foreach (PUnitRow Row in UnitTable.Rows)
                {
                    if ((Row.OutreachCode.Length == 13) && (Row.OutreachCode.Substring(0, 5) == OutreachPrefixCode))
                    {
                        DataRow CopyRow = Table.NewRow();
                        ((PUnitRow)CopyRow).PartnerKey = Row.PartnerKey;
                        ((PUnitRow)CopyRow).OutreachCode = Row.OutreachCode.Substring(5, 6);
                        ((PUnitRow)CopyRow).UnitName = Row.UnitName;
                        Table.Rows.Add(CopyRow);
                    }
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetOutreachTypes: commit own transaction.");
            }

            return Table;
        }
        public static PUnitTable GetActiveFieldUnits()
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow UnitRow;

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetActiveFieldUnits called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                ref Transaction,
                delegate
                {
                    // Load data
                    string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                     ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                     " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTable.GetTableDBName() +
                                     " WHERE ((" + PUnitTable.GetOutreachCodeDBName() + " IS NULL)" +
                                     "        OR(" + PUnitTable.GetOutreachCodeDBName() + " = ''))" +
                                     " AND " + PUnitTable.GetUnitTypeCodeDBName() + " <> 'KEY-MIN'" +
                                     " AND pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                     " = pub_" + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() +
                                     " AND " + PPartnerTable.GetStatusCodeDBName() + " = 'ACTIVE'";

                    // sort rows according to name
                    SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                    DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "fields", Transaction);

                    foreach (DataRow eventRow in events.Rows)
                    {
                        UnitRow = (PUnitRow)UnitTable.NewRow();
                        UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                        UnitRow.UnitName = Convert.ToString(eventRow[1]);
                        UnitTable.Rows.Add(UnitRow);
                    }
                });

            return UnitTable;
        }
        public static PUnitTable GetLedgerUnits()
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow UnitRow;

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetLedgerUnits called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                ref Transaction,
                delegate
                {
                    // Load data
                    string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                     ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                     " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTypeTable.GetTableDBName() +
                                     " WHERE pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                     " = pub_" + PPartnerTypeTable.GetTableDBName() + "." + PPartnerTypeTable.GetPartnerKeyDBName() +
                                     " AND " + PPartnerTypeTable.GetTypeCodeDBName() + " = '" + MPartnerConstants.PARTNERTYPE_LEDGER + "'";

                    // sort rows according to name
                    SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                    DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "ledgers", Transaction);

                    foreach (DataRow eventRow in events.Rows)
                    {
                        UnitRow = (PUnitRow)UnitTable.NewRow();
                        UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                        UnitRow.UnitName = Convert.ToString(eventRow[1]);
                        UnitTable.Rows.Add(UnitRow);
                    }
                });

            return UnitTable;
        }
        public static DataTable GetOutreachTypes(long APartnerKey)
        {
            TDBTransaction ReadTransaction = null;

            DataTable Table = new PUnitTable();

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref ReadTransaction,
                delegate
                {
                    string OutreachPrefixCode =
                        ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix;

                    string Query = "SELECT" +
                                   " p_unit.p_partner_key_n," +
                                   " SUBSTRING (p_unit.p_outreach_code_c,6,6) AS p_outreach_code_c," +
                                   " p_unit.p_unit_name_c" +

                                   " FROM p_unit" +

                                   " WHERE LENGTH(p_unit.p_outreach_code_c) = 13" +
                                   " AND SUBSTRING(p_unit.p_outreach_code_c,1,5) = '" + OutreachPrefixCode + "'";

                    DBAccess.GDBAccessObj.SelectDT(Table, Query, ReadTransaction);
                });

            return Table;
        }
        public static PUnitTable GetLedgerUnits(string ALedgerName)
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow UnitRow;

            TDBTransaction ReadTransaction;
            Boolean NewTransaction = false;

            if (ALedgerName == "*")
            {
                ALedgerName = "";
            }
            else if (ALedgerName.EndsWith("*"))
            {
                ALedgerName = ALedgerName.Substring(0, ALedgerName.Length - 1);
            }

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetLedgerUnits called!");

            ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                TEnforceIsolationLevel.eilMinimum,
                out NewTransaction);

            try
            {
                // Load data
                string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                 " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTypeTable.GetTableDBName() +
                                 " WHERE pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 " = pub_" + PPartnerTypeTable.GetTableDBName() + "." + PPartnerTypeTable.GetPartnerKeyDBName() +
                                 " AND " + PPartnerTypeTable.GetTypeCodeDBName() + " = '" + MPartnerConstants.PARTNERTYPE_LEDGER + "'";

                if (ALedgerName.Length > 0)
                {
                    // in case there is a filter set for the event name
                    ALedgerName = ALedgerName.Replace('*', '%') + "%";
                    SqlStmt = SqlStmt + " AND " + PUnitTable.GetUnitNameDBName() +
                              " LIKE '" + ALedgerName + "'";
                }

                // sort rows according to name
                SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "ledgers", ReadTransaction);

                foreach (DataRow eventRow in events.Rows)
                {
                    UnitRow = (PUnitRow)UnitTable.NewRow();
                    UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                    UnitRow.UnitName = Convert.ToString(eventRow[1]);
                    UnitTable.Rows.Add(UnitRow);
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TPartnerDataReaderWebConnector.GetLedgerUnits: committed own transaction.");
                }
            }

            return UnitTable;
        }
예제 #43
0
        public static System.Boolean GetOutreachOptions(long AUnitKey,
            out System.Data.DataTable AConferenceTable)
        {
            AConferenceTable = new DataTable();
            AConferenceTable.Columns.Add("Partner Key", Type.GetType("System.Int64"));
            AConferenceTable.Columns.Add("Outreach Code");
            AConferenceTable.Columns.Add("Unit Name");

            String ConferenceCodePrefix = "";
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow TemplateRow = UnitTable.NewRowTyped(false);

            TLogging.LogAtLevel(9, "TConferenceOptions.GetOutreachOptions called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(ref Transaction,
                delegate
                {
                    /* Load data */
                    UnitTable = PUnitAccess.LoadByPrimaryKey(AUnitKey, Transaction);

                    if (UnitTable.Rows.Count > 0)
                    {
                        ConferenceCodePrefix = ((PUnitRow)UnitTable.Rows[0]).OutreachCode.Substring(0, 5);

                        UnitTable = PUnitAccess.LoadUsingTemplate(TemplateRow, null, null, Transaction);
                    }
                });

            foreach (PUnitRow UnitRow in UnitTable.Rows)
            {
                if (!UnitRow.OutreachCode.StartsWith(ConferenceCodePrefix, true, null))
                {
                    continue;
                }

                DataRow NewRow = AConferenceTable.NewRow();

                NewRow["Partner Key"] = UnitRow.PartnerKey;
                NewRow["Outreach Code"] = UnitRow.OutreachCode;
                NewRow["Unit Name"] = UnitRow.UnitName;

                AConferenceTable.Rows.Add(NewRow);
            }

            return true;
        }