Пример #1
0
        /// <summary>
        /// return a list of all applicants for a given event
        /// </summary>
        /// <param name="AMainDS"></param>
        /// <param name="AEventCode"></param>
        /// <param name="ARegisteringOffice"></param>
        /// <param name="AApplicationStatus"></param>
        /// <param name="ARole"></param>
        /// <param name="AClearJSONData"></param>
        /// <param name="ATransaction"></param>
        /// <returns></returns>
        private static ConferenceApplicationTDS GetApplications(
            ref ConferenceApplicationTDS AMainDS,
            string AEventCode,
            Int64 ARegisteringOffice,
            string AApplicationStatus,
            string ARole,
            bool AClearJSONData,
            TDBTransaction ATransaction)
        {
            LoadApplicationsFromDB(ref AMainDS,
                                   AEventCode, ARegisteringOffice,
                                   ARole, new Nullable <Int64>(),
                                   ATransaction);

            DataView PersonView = AMainDS.PPerson.DefaultView;

            PersonView.Sort = PPersonTable.GetPartnerKeyDBName();

            DataView GenAppView = AMainDS.PmGeneralApplication.DefaultView;

            GenAppView.Sort = PmGeneralApplicationTable.GetPartnerKeyDBName() + "," +
                              PmGeneralApplicationTable.GetApplicationKeyDBName() + "," + PmGeneralApplicationTable.GetRegistrationOfficeDBName();

            if (AMainDS.HasChanges())
            {
                AMainDS.EnforceConstraints = false;
                AMainDS.AcceptChanges();
            }

            return(AMainDS);
        }
Пример #2
0
        /// <summary>
        /// todoComment
        /// </summary>
        public void SpecialInitUserControl(IndividualDataTDS AMainDS)
        {
            FMainDS = AMainDS;

            LoadDataOnDemand();

            grdDetails.Columns.Clear();
            grdDetails.AddDateColumn(Catalog.GetString("Date entered"),
                                     FMainDS.PmGeneralApplication.Columns[PmGeneralApplicationTable.GetDateCreatedDBName()]);
            grdDetails.AddTextColumn(Catalog.GetString("Applied for"), FMainDS.PmGeneralApplication.ColumnApplicationForEventOrField);
            grdDetails.AddTextColumn(Catalog.GetString("Field / Event Name"), FMainDS.PmGeneralApplication.ColumnEventOrFieldName);
            grdDetails.AddTextColumn(Catalog.GetString("Status"),
                                     FMainDS.PmGeneralApplication.Columns[PmGeneralApplicationTable.GetGenApplicationStatusDBName()], 100);

            // initialize tab controls
            ucoApplicationEvent.InitialiseUserControl();
            ucoApplicationField.InitialiseUserControl();

            // Hook up DataSavingStarted Event to be able to run code before SaveChanges is doing anything
            FPetraUtilsObject.DataSavingStarted += new TDataSavingStartHandler(this.DataSavingStarted);

            // enable grid to react to insert and delete keyboard keys
            //WB grdDetails.InsertKeyPressed += new TKeyPressedEventHandler(grdDetails_InsertKeyPressed);

            // enable grid to react to modified event or field key in details part
            ucoApplicationEvent.ApplicationEventChanged += new TUC_Application_Event.TDelegateApplicationEventChanged(
                ProcessApplicationEventOrFieldChanged);
            ucoApplicationField.ApplicationFieldChanged += new TUC_Application_Field.TDelegateApplicationFieldChanged(
                ProcessApplicationEventOrFieldChanged);

            if (grdDetails.Rows.Count <= 1)
            {
                pnlDetails.Visible = false;
            }
        }
        /// <summary>
        /// Gets the data from all UserControls on this TabControl.
        /// The data is stored in the DataTables/DataColumns to which the Controls
        /// are mapped.
        /// </summary>
        /// <returns>void</returns>
        public void GetDataFromControls()
        {
            ucoApplications.GetDataFromControls2();

            if (!FPartnerEditTDS.Tables.Contains(PmGeneralApplicationTable.GetTableName()))
            {
                FPartnerEditTDS.Tables.Add(new PmGeneralApplicationTable());
            }

            if (!FPartnerEditTDS.Tables.Contains(PmShortTermApplicationTable.GetTableName()))
            {
                FPartnerEditTDS.Tables.Add(new PmShortTermApplicationTable());
            }

            if (!FPartnerEditTDS.Tables.Contains(PmYearProgramApplicationTable.GetTableName()))
            {
                FPartnerEditTDS.Tables.Add(new PmYearProgramApplicationTable());
            }

            FPartnerEditTDS.Tables[PmShortTermApplicationTable.GetTableName()].Rows.Clear();
            FPartnerEditTDS.Tables[PmShortTermApplicationTable.GetTableName()].Merge(FMainDS.PmShortTermApplication);
            FPartnerEditTDS.Tables[PmYearProgramApplicationTable.GetTableName()].Rows.Clear();
            FPartnerEditTDS.Tables[PmYearProgramApplicationTable.GetTableName()].Merge(FMainDS.PmYearProgramApplication);
            FPartnerEditTDS.Tables[PmGeneralApplicationTable.GetTableName()].Rows.Clear();
            FPartnerEditTDS.Tables[PmGeneralApplicationTable.GetTableName()].Merge(FMainDS.PmGeneralApplication);
        }
Пример #4
0
        public static Boolean LoadLongTermApplications(ref ApplicationTDS AMainDS, long ATargetFieldKey, long APlacementPersonKey)
        {
            ApplicationTDS MainDS                   = new ApplicationTDS();
            String         GenAppTableName          = AMainDS.PmGeneralApplication.TableName;
            string         QueryLongTermApplication = "";

            List <OdbcParameter> Parameters = new List <OdbcParameter>();
            OdbcParameter        Parameter1 = new OdbcParameter(
                "targetfieldkey", OdbcType.BigInt, PmGeneralApplicationTable.GetGenAppPossSrvUnitKeyLength());
            OdbcParameter Parameter2 = new OdbcParameter(
                "Placementpersonkey", OdbcType.BigInt, PmGeneralApplicationTable.GetPlacementPartnerKeyLength());

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                QueryLongTermApplication =
                    "SELECT PUB_pm_general_application.*, PUB_pm_year_program_application.*, PUB_p_partner.p_partner_short_name_c " +
                    "FROM PUB_pm_general_application, PUB_pm_year_program_application, PUB_p_partner WHERE ";

                if (ATargetFieldKey != 0)
                {
                    Parameter1.Value = ATargetFieldKey;
                    Parameters.Add(Parameter1);

                    // load all appicants with given Target Field
                    QueryLongTermApplication += "PUB_pm_general_application.pm_gen_app_poss_srv_unit_key_n = ? AND ";
                }

                if (APlacementPersonKey != 0)
                {
                    Parameter2.Value = APlacementPersonKey;
                    Parameters.Add(
                        Parameter2);

                    // load all appicants with given Placement Person
                    QueryLongTermApplication += "PUB_pm_general_application.pm_placement_partner_key_n = ? AND ";
                }

                QueryLongTermApplication += "PUB_pm_year_program_application.p_partner_key_n = PUB_pm_general_application.p_partner_key_n " +
                                            "AND PUB_pm_year_program_application.pm_application_key_i = PUB_pm_general_application.pm_application_key_i "
                                            +
                                            "AND PUB_pm_year_program_application.pm_registration_office_n = PUB_pm_general_application.pm_registration_office_n "
                                            +
                                            "AND PUB_p_partner.p_partner_key_n = PUB_pm_general_application.p_partner_key_n";

                DBAccess.GDBAccessObj.Select(MainDS,
                                             QueryLongTermApplication,
                                             GenAppTableName, Transaction, Parameters.ToArray());
            });

            AMainDS.Merge(MainDS);

            return(true);
        }
 /// <summary>
 /// Selects the given application.
 /// </summary>
 /// <param name="AApplicationKey">Application's application key.</param>
 /// <param name="ARegistrationOffice">Application's registration office.</param>
 public void SelectApplications(Int32 AApplicationKey, Int64 ARegistrationOffice)
 {
     foreach (DataRowView RowView in FMainDS.PmGeneralApplication.DefaultView)
     {
         if ((Convert.ToInt32(RowView[PmGeneralApplicationTable.GetApplicationKeyDBName()]) == AApplicationKey) &&
             (Convert.ToInt64(RowView[PmGeneralApplicationTable.GetRegistrationOfficeDBName()]) == ARegistrationOffice))
         {
             grdDetails.SelectRowInGrid(grdDetails.Rows.DataSourceRowToIndex(RowView) + 1);
             return;
         }
     }
 }
        /// <summary>
        /// returns number of application records existing for current person record
        /// </summary>
        /// <returns>int</returns>
        public int CountApplications()
        {
            DataView TmpDV;

            if (FMainDS.Tables.Contains(PmGeneralApplicationTable.GetTableName()))
            {
                TmpDV = new DataView(FMainDS.PmGeneralApplication, "", "", DataViewRowState.CurrentRows);
                return(TmpDV.Count);
            }
            else
            {
                return(FMainDS.MiscellaneousData[0].ItemsCountApplications);
            }
        }
Пример #7
0
        /// <summary>
        /// return a list of all applicants for a given event,
        /// but if AConferenceOrganisingOffice is false,
        /// consider only the registration office that the user has permissions for, ie. Module REG-00xx0000000
        /// </summary>
        /// <param name="AMainDS"></param>
        /// <param name="AEventPartnerKey">The ConferenceKey</param>
        /// <param name="AEventCode">The OutreachPrefix</param>
        /// <param name="AApplicationStatus"></param>
        /// <param name="ARegistrationOffice">if -1, then show all offices that the user has permission for</param>
        /// <param name="AConferenceOrganisingOffice">if true, all offices are considered</param>
        /// <param name="ARole"></param>
        /// <param name="AClearJSONData"></param>
        /// <returns></returns>
        public static bool GetApplications(
            ref ConferenceApplicationTDS AMainDS,
            Int64 AEventPartnerKey,
            string AEventCode,
            string AApplicationStatus,
            Int64 ARegistrationOffice,
            bool AConferenceOrganisingOffice,
            string ARole,
            bool AClearJSONData)
        {
            TDBTransaction           Transaction = null;
            ConferenceApplicationTDS MainDS      = new ConferenceApplicationTDS();

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(
                IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum,
                ref Transaction,
                delegate
            {
                // load all attendees of this conference.
                // only load once: GetApplications might be called for several application stati
                if (MainDS.PcAttendee.Rows.Count == 0)
                {
                    PcAttendeeRow templateAttendeeRow = MainDS.PcAttendee.NewRowTyped(false);
                    templateAttendeeRow.ConferenceKey = AEventPartnerKey;
                    PcAttendeeAccess.LoadUsingTemplate(MainDS, templateAttendeeRow, Transaction);
                    MainDS.PcAttendee.DefaultView.Sort = PcAttendeeTable.GetPartnerKeyDBName();
                }

                if (AConferenceOrganisingOffice && (ARegistrationOffice == -1))
                {
                    // avoid duplicates, who are registered by one office, but charged to another office
                    GetApplications(ref MainDS, AEventCode, -1, AApplicationStatus, ARole, AClearJSONData, Transaction);
                }
                else
                {
                    List <Int64> AllowedRegistrationOffices = GetRegistrationOfficeKeysOfUser(Transaction);

                    foreach (Int64 RegistrationOffice in AllowedRegistrationOffices)
                    {
                        if ((ARegistrationOffice == RegistrationOffice) || (ARegistrationOffice == -1))
                        {
                            GetApplications(ref MainDS, AEventCode, RegistrationOffice, AApplicationStatus, ARole, AClearJSONData, Transaction);
                        }
                    }
                }

                // required for DefaultView.Find
                MainDS.PmShortTermApplication.DefaultView.Sort =
                    PmShortTermApplicationTable.GetStConfirmedOptionDBName() + "," +
                    PmShortTermApplicationTable.GetPartnerKeyDBName();
                MainDS.PmGeneralApplication.DefaultView.Sort =
                    PmGeneralApplicationTable.GetPartnerKeyDBName() + "," +
                    PmGeneralApplicationTable.GetApplicationKeyDBName() + "," +
                    PmGeneralApplicationTable.GetRegistrationOfficeDBName();
                MainDS.PDataLabelValuePartner.DefaultView.Sort = PDataLabelValuePartnerTable.GetDataLabelKeyDBName() + "," +
                                                                 PDataLabelValuePartnerTable.GetPartnerKeyDBName();
                MainDS.PDataLabel.DefaultView.Sort = PDataLabelTable.GetTextDBName();
            });

            AMainDS = MainDS;

            if (AMainDS.HasChanges())
            {
                AMainDS.EnforceConstraints = false;
                AMainDS.AcceptChanges();
            }

            return(true);
        }
Пример #8
0
        public static TSubmitChangesResult SubmitChangesServerSide(ref IndividualDataTDS AInspectDS,
                                                                   ref PartnerEditTDS APartnerEditInspectDS,
                                                                   TDBTransaction ASubmitChangesTransaction,
                                                                   out TVerificationResultCollection AVerificationResult)
        {
            TSubmitChangesResult SubmissionResult;

            PmJobAssignmentTable PmJobAssignmentTableSubmit;

            AVerificationResult = new TVerificationResultCollection();

            if (AInspectDS != null)
            {
                SubmissionResult = TSubmitChangesResult.scrOK;

                // Job Assignments: make sure that jobs exist for assignments
                if (AInspectDS.Tables.Contains(PmJobAssignmentTable.GetTableName()) &&
                    (AInspectDS.PmJobAssignment.Rows.Count > 0))
                {
                    UmJobTable JobTableTemp = new UmJobTable();

                    UmJobTable JobTableSubmit = new UmJobTable();
                    UmJobRow   JobRow;

                    PmJobAssignmentTableSubmit = AInspectDS.PmJobAssignment;

                    // every job_assignment_row needs to have a row that it references in um_job
                    foreach (PmJobAssignmentRow JobAssignmentRow in PmJobAssignmentTableSubmit.Rows)
                    {
                        if (JobAssignmentRow.RowState != DataRowState.Deleted)
                        {
                            JobTableTemp = UmJobAccess.LoadByPrimaryKey(JobAssignmentRow.UnitKey,
                                                                        JobAssignmentRow.PositionName,
                                                                        JobAssignmentRow.PositionScope,
                                                                        JobAssignmentRow.JobKey,
                                                                        ASubmitChangesTransaction);

                            // if no corresponding job record found then we need to create one
                            // (job key was already set on client side to new value so merging back to the
                            // client does not cause problems because of primary key change)
                            if (JobTableTemp.Count == 0)
                            {
                                JobRow = (UmJobRow)JobTableSubmit.NewRow();

                                JobRow.UnitKey          = JobAssignmentRow.UnitKey;
                                JobRow.PositionName     = JobAssignmentRow.PositionName;
                                JobRow.PositionScope    = JobAssignmentRow.PositionScope;
                                JobRow.JobKey           = JobAssignmentRow.JobKey;
                                JobRow.FromDate         = JobAssignmentRow.FromDate;
                                JobRow.ToDate           = JobAssignmentRow.ToDate;
                                JobRow.CommitmentPeriod = "None";
                                JobRow.TrainingPeriod   = "None";

                                // Need to update the JobKey field in job assignment table record from job record
                                JobAssignmentRow.JobKey = JobRow.JobKey;

                                JobTableSubmit.Rows.Add(JobRow);
                            }
                            else
                            {
                                // job record exists: in this case we need to update JobKey in
                                // the Job Assignment Record from Job Row
                                JobAssignmentRow.JobKey = ((UmJobRow)JobTableTemp.Rows[0]).JobKey;
                            }
                        }
                    }

                    // submit table with newly created jobs
                    if (JobTableSubmit.Rows.Count > 0)
                    {
                        UmJobAccess.SubmitChanges(JobTableSubmit, ASubmitChangesTransaction);
                    }
                }

                // now submit the whole dataset at once
                IndividualDataTDSAccess.SubmitChanges(AInspectDS);

                // Need to merge tables back into APartnerEditInspectDS so the updated s_modification_id_t is returned
                // correctly to the Partner Edit.
                // Unfortunately this can't be done simply by using merge method of the dataset since they are two different
                // types but has to be done per table.
                if (AInspectDS.Tables.Contains(PmSpecialNeedTable.GetTableName()) &&
                    (AInspectDS.PmSpecialNeed.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmSpecialNeedTable.GetTableName()].Merge(AInspectDS.PmSpecialNeed);
                }

                if (AInspectDS.Tables.Contains(PmPersonAbilityTable.GetTableName()) &&
                    (AInspectDS.PmPersonAbility.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonAbilityTable.GetTableName()].Merge(AInspectDS.PmPersonAbility);
                }

                if (AInspectDS.Tables.Contains(PmPassportDetailsTable.GetTableName()) &&
                    (AInspectDS.PmPassportDetails.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPassportDetailsTable.GetTableName()].Merge(AInspectDS.PmPassportDetails);
                }

                if (AInspectDS.Tables.Contains(PmPersonalDataTable.GetTableName()) &&
                    (AInspectDS.PmPersonalData.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonalDataTable.GetTableName()].Merge(AInspectDS.PmPersonalData);
                }

                if (AInspectDS.Tables.Contains(PmPersonLanguageTable.GetTableName()) &&
                    (AInspectDS.PmPersonLanguage.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonLanguageTable.GetTableName()].Merge(AInspectDS.PmPersonLanguage);
                }

                if (AInspectDS.Tables.Contains(PmPersonEvaluationTable.GetTableName()) &&
                    (AInspectDS.PmPersonEvaluation.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonEvaluationTable.GetTableName()].Merge(AInspectDS.PmPersonEvaluation);
                }

                if (AInspectDS.Tables.Contains(PmStaffDataTable.GetTableName()) &&
                    (AInspectDS.PmStaffData.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmStaffDataTable.GetTableName()].Merge(AInspectDS.PmStaffData);
                }

                if (AInspectDS.Tables.Contains(PmPersonSkillTable.GetTableName()) &&
                    (AInspectDS.PmPersonSkill.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonSkillTable.GetTableName()].Merge(AInspectDS.PmPersonSkill);
                }

                if (AInspectDS.Tables.Contains(PmPastExperienceTable.GetTableName()) &&
                    (AInspectDS.PmPastExperience.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPastExperienceTable.GetTableName()].Merge(AInspectDS.PmPastExperience);
                }

                if (AInspectDS.Tables.Contains(PmDocumentTable.GetTableName()) &&
                    (AInspectDS.PmDocument.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmDocumentTable.GetTableName()].Merge(AInspectDS.PmDocument);
                }

                if (AInspectDS.Tables.Contains(PmJobAssignmentTable.GetTableName()) &&
                    (AInspectDS.PmJobAssignment.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmJobAssignmentTable.GetTableName()].Merge(AInspectDS.PmJobAssignment);
                }

                if (AInspectDS.Tables.Contains(PmGeneralApplicationTable.GetTableName()) &&
                    (AInspectDS.PmGeneralApplication.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmGeneralApplicationTable.GetTableName()].Merge(AInspectDS.PmGeneralApplication);
                }

                if (AInspectDS.Tables.Contains(PmShortTermApplicationTable.GetTableName()) &&
                    (AInspectDS.PmShortTermApplication.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmShortTermApplicationTable.GetTableName()].Merge(AInspectDS.PmShortTermApplication);
                }

                if (AInspectDS.Tables.Contains(PmYearProgramApplicationTable.GetTableName()) &&
                    (AInspectDS.PmYearProgramApplication.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmYearProgramApplicationTable.GetTableName()].Merge(AInspectDS.PmYearProgramApplication);
                }
            }
            else
            {
                TLogging.LogAtLevel(8, "TIndividualDataWebConnector.SubmitChangesServerSide: AInspectDS = nil!");
                SubmissionResult = TSubmitChangesResult.scrNothingToBeSaved;
            }

            return(SubmissionResult);
        }
        // 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.PmGeneralApplication.DefaultView;

            MyDataView.RowFilter = null;

            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'");
                }

                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 = FDetailedStatuses.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();
        }
Пример #10
0
        private static void MergeApplications(long AFromPartnerKey, long AToPartnerKey, TDBTransaction ATransaction)
        {
            PmGeneralApplicationTable FromApplicationTable = PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(AFromPartnerKey, ATransaction);
            PmGeneralApplicationTable NewApplicationTable = new PmGeneralApplicationTable();

            if (FromApplicationTable.Rows.Count > 0)
            {
                foreach (DataRow FromRow in FromApplicationTable.Rows)
                {
                    PmGeneralApplicationRow NewRow = NewApplicationTable.NewRowTyped();
                    PmGeneralApplicationRow FromApplicationRow = (PmGeneralApplicationRow)FromRow;
                    DateTime AppDate = FromApplicationRow.GenAppDate;

                    // Create new record (by cloning the old record) and keep old record to avoid constraint errors.
                    // Old record will be deleted later.
                    object[] FromRowArray = FromApplicationRow.ItemArray;
                    object[] FromRowArrayClone = (object[])FromRowArray.Clone();
                    NewRow.ItemArray = FromRowArrayClone;
                    NewRow.PartnerKey = AToPartnerKey;

                    /*  If a general app record already exists in the "merged into" partner that has the same unique index consisting of
                     *  p_partner_key_n, pm_gen_app_date_d, pt_app_type_name_c, pm_old_link_c then change the "app date" (go backwards) field
                     *  so that this unique index is not violated. This will rarely happen but is possible. It will be the case if the two
                     *  partners would have an application for the same event at the same day.  */
                    PmGeneralApplicationTable ToApplicationTable = PmGeneralApplicationAccess.LoadByUniqueKey(AToPartnerKey, AppDate,
                        FromApplicationRow.AppTypeName, FromApplicationRow.OldLink, ATransaction);

                    AppDate = AppDate.AddDays(-ToApplicationTable.Rows.Count);

                    //  the application date needs to be reset in the short term or long term application as well (depending on the type)
                    if (AppDate != FromApplicationRow.GenAppDate)
                    {
                        PmShortTermApplicationTable STAppTable = PmShortTermApplicationAccess.LoadByPrimaryKey(
                            AFromPartnerKey, FromApplicationRow.ApplicationKey, FromApplicationRow.RegistrationOffice, ATransaction);

                        if (STAppTable.Rows.Count != 0)
                        {
                            ((PmShortTermApplicationRow)STAppTable.Rows[0]).StAppDate = AppDate;
                            PmShortTermApplicationAccess.SubmitChanges(STAppTable, ATransaction);
                        }
                        else
                        {
                            PmYearProgramApplicationTable YPAppTable = PmYearProgramApplicationAccess.LoadByPrimaryKey(
                                AFromPartnerKey, FromApplicationRow.ApplicationKey, FromApplicationRow.RegistrationOffice, ATransaction);

                            if (YPAppTable.Rows.Count != 0)
                            {
                                ((PmYearProgramApplicationRow)YPAppTable.Rows[0]).YpAppDate = AppDate;
                                PmYearProgramApplicationAccess.SubmitChanges(YPAppTable, ATransaction);
                            }
                        }
                    }

                    NewRow.GenAppDate = AppDate;

                    NewApplicationTable.Rows.Add(NewRow);
                }

                // submit new records (will delete old records later)
                PmGeneralApplicationAccess.SubmitChanges(NewApplicationTable, ATransaction);
            }

            PmApplicationFileTable FileTable = PmApplicationFileAccess.LoadViaPPerson(AFromPartnerKey, ATransaction);

            foreach (DataRow Row in FileTable.Rows)
            {
                ((PmApplicationFileRow)Row).PartnerKey = AToPartnerKey;
            }

            PmApplicationFileAccess.SubmitChanges(FileTable, ATransaction);

            PmYearProgramApplicationTable YPApplicationTable = PmYearProgramApplicationAccess.LoadViaPPerson(AFromPartnerKey, ATransaction);

            foreach (DataRow Row in YPApplicationTable.Rows)
            {
                ((PmYearProgramApplicationRow)Row).PartnerKey = AToPartnerKey;
            }

            PmYearProgramApplicationAccess.SubmitChanges(YPApplicationTable, ATransaction);

            PmShortTermApplicationTable STApplicationTable = PmShortTermApplicationAccess.LoadViaPPerson(AFromPartnerKey, ATransaction);

            foreach (DataRow Row in STApplicationTable.Rows)
            {
                ((PmShortTermApplicationRow)Row).PartnerKey = AToPartnerKey;
            }

            PmShortTermApplicationAccess.SubmitChanges(STApplicationTable, ATransaction);

            // delete old records
            foreach (DataRow Row in FromApplicationTable.Rows)
            {
                Row.Delete();
            }

            PmGeneralApplicationAccess.SubmitChanges(FromApplicationTable, ATransaction);
        }
        // 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();
        }
Пример #12
0
        public static Boolean LoadLongTermApplications(ref ApplicationTDS AMainDS, long ATargetFieldKey, long APlacementPersonKey)
        {
            Boolean NewTransaction;

            string QueryLongTermApplication = "";

            List <OdbcParameter> Parameters = new List <OdbcParameter>();
            OdbcParameter        Parameter1 = new OdbcParameter(
                "targetfieldkey", OdbcType.BigInt, PmGeneralApplicationTable.GetGenAppPossSrvUnitKeyLength());
            OdbcParameter Parameter2 = new OdbcParameter(
                "Placementpersonkey", OdbcType.BigInt, PmGeneralApplicationTable.GetPlacementPartnerKeyLength());

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

            try
            {
                QueryLongTermApplication =
                    "SELECT PUB_pm_general_application.*, PUB_pm_year_program_application.*, PUB_p_partner.p_partner_short_name_c " +
                    "FROM PUB_pm_general_application, PUB_pm_year_program_application, PUB_p_partner WHERE ";

                if (ATargetFieldKey != 0)
                {
                    Parameter1.Value = ATargetFieldKey;
                    Parameters.Add(Parameter1);

                    // load all appicants with given Target Field
                    QueryLongTermApplication += "PUB_pm_general_application.pm_gen_app_poss_srv_unit_key_n = ? AND ";
                }

                if (APlacementPersonKey != 0)
                {
                    Parameter2.Value = APlacementPersonKey;
                    Parameters.Add(Parameter2);

                    // load all appicants with given Placement Person
                    QueryLongTermApplication += "PUB_pm_general_application.pm_placement_partner_key_n = ? AND ";
                }

                QueryLongTermApplication += "PUB_pm_year_program_application.p_partner_key_n = PUB_pm_general_application.p_partner_key_n " +
                                            "AND PUB_pm_year_program_application.pm_application_key_i = PUB_pm_general_application.pm_application_key_i "
                                            +
                                            "AND PUB_pm_year_program_application.pm_registration_office_n = PUB_pm_general_application.pm_registration_office_n "
                                            +
                                            "AND PUB_p_partner.p_partner_key_n = PUB_pm_general_application.p_partner_key_n";

                DBAccess.GDBAccessObj.Select(AMainDS,
                                             QueryLongTermApplication,
                                             AMainDS.PmGeneralApplication.TableName, ReadTransaction, Parameters.ToArray());
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.LoadLongTermApplications: commit own transaction.");
                }
            }

            return(true);
        }