private void ShowAllOutreaches_CheckBox(System.Object sender, EventArgs e)
        {
            FShowAllOutreaches = !FShowAllOutreaches;

            DataView MyDataView = FMainDS.PmShortTermApplication.DefaultView;

            if (!chkShowAllOutreaches.Checked)
            {
                // filter rows so only showing applicants for selected outreach rather than the entire conference
                MyDataView.RowFilter = PmShortTermApplicationTable.GetConfirmedOptionCodeDBName() + " = " + "'" + FOutreachCode + "'";
            }
            else
            {
                MyDataView.RowFilter = null;
            }

            grdApplications.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView);

            UpdateRecordNumberDisplay();
        }
        private void LoadDataGrid()
        {
            FMainDS = new ApplicationTDS();

            // populate dataset
            TRemote.MPersonnel.WebConnectors.LoadShortTermApplications(ref FMainDS, FOutreachCode);

            FMainDS.PmShortTermApplication.DefaultView.AllowNew = false;

            // sort order for grid
            DataView MyDataView = FMainDS.PmShortTermApplication.DefaultView;

            MyDataView.Sort = "p_partner_short_name_c ASC";

            if (!chkShowAllOutreaches.Checked && chkShowAllOutreaches.Enabled)
            {
                // filter rows so only showing applicants for selected outreach rather than the entire conference
                MyDataView.RowFilter = PmShortTermApplicationTable.GetConfirmedOptionCodeDBName() + " = " + "'" + FOutreachCode + "'";
            }

            grdApplications.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView);
        }
Ejemplo n.º 3
0
        public static bool GetFieldUnits(Int64 AConferenceKey, TUnitTypeEnum AFieldTypes, out DataTable AFieldsTable, out String AConferencePrefix)
        {
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;

            AFieldsTable      = new DataTable("Field Units");
            AConferencePrefix = "";
            PUnitTable UnitTable;
            DataTable  TmpTable;

            PmShortTermApplicationTable ShortTermerTable = new PmShortTermApplicationTable();

            AFieldsTable.Columns.Add("Selection", System.Type.GetType("System.Boolean"));
            AFieldsTable.Columns.Add("Unit_Key", System.Type.GetType("System.Int64"));
            AFieldsTable.Columns.Add("Unit_Name", System.Type.GetType("System.String"));
            AFieldsTable.Columns.Add("Outreach_Code", System.Type.GetType("System.String"));
            AFieldsTable.Columns.Add("Used_in_Conference", System.Type.GetType("System.Boolean"));

            AConferencePrefix = TConferenceOptions.GetConferencePrefix(AConferenceKey);

            switch (AFieldTypes)
            {
            case TUnitTypeEnum.utSendingFields:
                return(TConferenceOptions.GetSendingFields(AConferenceKey, ref AFieldsTable));

            case TUnitTypeEnum.utReceivingFields:
                return(TConferenceOptions.GetReceivingFields(AConferenceKey, ref AFieldsTable));

            case TUnitTypeEnum.utOutreachOptions:

                if (TConferenceOptions.GetOutreachOptions(AConferenceKey, out TmpTable))
                {
                    foreach (DataRow Row in TmpTable.Rows)
                    {
                        DataRow NewRow = AFieldsTable.NewRow();

                        NewRow[SELECTION]          = false;
                        NewRow[UNIT_KEY]           = Row["Partner Key"];
                        NewRow[UNIT_NAME]          = Row["Unit Name"];
                        NewRow[CAMPAIGN_CODE]      = Row["Outreach Code"];
                        NewRow[USED_IN_CONFERENCE] = true;

                        AFieldsTable.Rows.Add(NewRow);
                    }

                    return(true);
                }

                return(false);

            default:
                break;
            }

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

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

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

            try
            {
                StringCollection FieldList = new StringCollection();
                FieldList.Add(PmShortTermApplicationTable.GetStFieldChargedDBName());
                FieldList.Add(PmShortTermApplicationTable.GetConfirmedOptionCodeDBName());
                FieldList.Add(PmShortTermApplicationTable.GetRegistrationOfficeDBName());

                ShortTermerTable = PmShortTermApplicationAccess.LoadAll(FieldList, ReadTransaction);

                long LastUnitKey           = 0;
                long NewUnitKey            = 0;
                bool IsUsedInOneConference = false;

                String      ConfirmedOptionCode = "";
                System.Type StringType          = System.Type.GetType("System.String");

                String SearchedColumnName = "";

                switch (AFieldTypes)
                {
                case TUnitTypeEnum.utChargedFields:
                    SearchedColumnName = PmShortTermApplicationTable.GetStFieldChargedDBName();
                    break;

                case TUnitTypeEnum.utRegisteringFields:
                    SearchedColumnName = PmShortTermApplicationTable.GetRegistrationOfficeDBName();
                    break;

                default:
                    break;
                }

                foreach (DataRow ShortTermerRow in ShortTermerTable.Select("", SearchedColumnName))
                {
                    if ((ShortTermerRow[SearchedColumnName] != null) &&
                        (ShortTermerRow[SearchedColumnName].ToString().Length > 0))
                    {
                        NewUnitKey = (long)ShortTermerRow[SearchedColumnName];
                    }
                    else
                    {
                        continue;
                    }

                    if (LastUnitKey != NewUnitKey)
                    {
                        if ((AFieldsTable.Rows.Count > 0) &&
                            (IsUsedInOneConference))
                        {
                            AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true;
                        }

                        IsUsedInOneConference = false;
                    }

                    // We have to check from every shorttermer if the charged field is used
                    // in this conference
                    if (IsUsedInOneConference)
                    {
                        continue;
                    }

                    if (ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()].GetType() == StringType)
                    {
                        ConfirmedOptionCode = (string)ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()];
                    }
                    else
                    {
                        ConfirmedOptionCode = "";
                    }

                    if (ConfirmedOptionCode.StartsWith(AConferencePrefix))
                    {
                        IsUsedInOneConference = true;
                    }

                    if (LastUnitKey == NewUnitKey)
                    {
                        continue;
                    }

                    UnitTable = PUnitAccess.LoadByPrimaryKey(NewUnitKey, ReadTransaction);

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

                        ResultRow[SELECTION]          = false;
                        ResultRow[UNIT_KEY]           = NewUnitKey;
                        ResultRow[UNIT_NAME]          = UnitTable[0][PUnitTable.GetUnitNameDBName()];
                        ResultRow[CAMPAIGN_CODE]      = ConfirmedOptionCode;
                        ResultRow[USED_IN_CONFERENCE] = IsUsedInOneConference;

                        AFieldsTable.Rows.Add(ResultRow);
                        LastUnitKey = NewUnitKey;
                    }
                }

                // Check for the previous entry the "IsUsedInConference" field
                if ((AFieldsTable.Rows.Count > 0) &&
                    (IsUsedInOneConference))
                {
                    AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true;
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    ReadTransaction.Commit();
                    TLogging.LogAtLevel(7, "TConferenceOptions.GetFieldUnits: committed own transaction.");
                }
            }
            return(true);
        }
        // update the grid once the filter is changed
        private void FilterChange(System.Object sender, EventArgs e)
        {
            List <string> Filters       = new List <string>();
            string        FiltersString = "";

            DataView MyDataView = FMainDS.PmShortTermApplication.DefaultView;

            MyDataView.RowFilter = null;

            if (chkShowAllOutreaches.Enabled && !chkShowAllOutreaches.Checked)
            {
                // filter rows so only showing applicants for selected outreach rather than the entire conference
                FiltersString = PmShortTermApplicationTable.GetConfirmedOptionCodeDBName() + " = '" + FOutreachCode + "'";
            }

            if (rbtGeneral.Checked)
            {
                if (!chkAccepted.Checked)
                {
                    Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'A'");
                }

                if (!chkCancelled.Checked)
                {
                    Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'C'");
                }

                if (!chkEnquiry.Checked)
                {
                    Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'E'");
                }

                if (!chkHold.Checked)
                {
                    Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'H'");
                }

                if (!chkRejected.Checked)
                {
                    Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'R'");
                }

                Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'P'");

                for (int i = 0; i < Filters.Count; i++)
                {
                    if ((i != 0) || (FiltersString.Length > 0))
                    {
                        FiltersString += " AND " + Filters[i];
                    }
                    else
                    {
                        FiltersString += Filters[i];
                    }
                }
            }
            else if (rbtDetailed.Checked)
            {
                string[] DetailedStatuses = txtDetailedStatuses.Text.Split(',');

                foreach (string Status in DetailedStatuses)
                {
                    Filters.Add(PmGeneralApplicationTable.GetGenApplicationStatusDBName() + " = '" + Status + "'");
                }

                for (int i = 0; i < Filters.Count; i++)
                {
                    if ((i == 0) && (FiltersString.Length > 0))
                    {
                        FiltersString += " AND (" + Filters[i];
                    }
                    else if ((i == 0) && (FiltersString.Length == 0))
                    {
                        FiltersString += "(" + Filters[i];
                    }
                    else
                    {
                        FiltersString += " OR " + Filters[i];
                    }

                    if (i == Filters.Count - 1)
                    {
                        FiltersString += ")";
                    }
                }
            }

            MyDataView.RowFilter = FiltersString;

            grdApplications.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView);

            UpdateRecordNumberDisplay();
        }