Пример #1
0
 public void Delete(modelProjectActivityVariation activityvariation, bool reload = true)
 {
     db2.Delete("tblProjectActivityVariation", "ID", activityvariation);
     if (reload)
     {
         LoadProjectActivityVariations();
     }
 }
Пример #2
0
 public void Update(modelProjectActivityVariation activityvariation, bool reload = true)
 {
     if (activityvariation.CreatedDate.Year < 2000)
     {
         activityvariation.CreatedDate = new DateTime(2000, 1, 1);
     }
     activityvariation.UpdatedDate = DateTime.Now;
     db2.Update("tblProjectActivityVariation", "ID", activityvariation);
     if (reload)
     {
         LoadProjectActivityVariations();
     }
 }
Пример #3
0
 public void Insert(modelProjectActivityVariation activityvariation, bool reload = true)
 {
     if (activityvariation.ID == 0)
     {
         activityvariation.ID          = Program.GData.LongID();
         activityvariation.CreatedDate = DateTime.Now;
         activityvariation.UpdatedDate = DateTime.Now;
     }
     db2.Insert("tblProjectActivityVariation", "ID", false, activityvariation);
     if (reload)
     {
         LoadProjectActivityVariations();
     }
 }
Пример #4
0
        private void AddProjectActivityVariationVariables(ref Dictionary <string, string> mailMergeVars, modelProjectActivityVariation projactvar, modelProjectVariationOrganization[] partners, string prefix)
        {
            var    country = Program.GData.dataLOV.getCountry(projactvar.CountryOfDestination);
            string cc;

            if (country == null)
            {
                cc = "";
            }
            else
            {
                cc = country.Code;
            }

            var    at = Program.GData.dataProject.getProjectActivity(projactvar.ProjectActivity);
            string atype;

            if (at == null)
            {
                atype = "";
            }
            else
            {
                atype = Program.GData.dataActivity.getActivityType(at.ActivityID).ActivityType;
            }

            AddToVariablesDictionary(ref mailMergeVars, prefix + "participants_total", projactvar.ParticipantsTotal.ToString());
            AddToVariablesDictionary(ref mailMergeVars, prefix + "participants_count_per_country", projactvar.ParticipantsPerCountry.ToString());
            AddToVariablesDictionary(ref mailMergeVars, prefix + "participants_obstacle_total", projactvar.FewerOpportunitieTotal.ToString());
            AddToVariablesDictionary(ref mailMergeVars, prefix + "participants_obstacle_per_country", projactvar.FewerOpportunitiePerCountry.ToString());
            AddToVariablesDictionary(ref mailMergeVars, prefix + "group_leaders_total", projactvar.GTFTotal.ToString());
            AddToVariablesDictionary(ref mailMergeVars, prefix + "group_leaders_per_country", projactvar.GTFPerCountry.ToString());
            AddToVariablesDictionary(ref mailMergeVars, prefix + "staff_facilitators", "0");
            AddToVariablesDictionary(ref mailMergeVars, prefix + "staff_other", "0");
            AddToVariablesDictionary(ref mailMergeVars, prefix + "dates", projactvar.StartDate.ToString("dd.MM.") + "-" + projactvar.StartDate.AddDays(projactvar.Duration - 1).ToString("dd.MM.yyyy"));
            AddToVariablesDictionary(ref mailMergeVars, prefix + "dates_count", projactvar.Duration.ToString());
            AddToVariablesDictionary(ref mailMergeVars, prefix + "location_city", projactvar.CityOfDestination);
            AddToVariablesDictionary(ref mailMergeVars, prefix + "location_country", cc);
            AddToVariablesDictionary(ref mailMergeVars, prefix + "study_visit", projactvar.StudyVisit);

            AddToVariablesDictionary(ref mailMergeVars, prefix + "activity_type", atype);
            AddToVariablesDictionary(ref mailMergeVars, prefix + "start_date", projactvar.StartDate.ToString("dd.MM.yyyy"));
            AddToVariablesDictionary(ref mailMergeVars, prefix + "end_date", projactvar.EndDate.ToString("dd.MM.yyyy"));

            AddToVariablesDictionary(ref mailMergeVars, prefix + "euro_travel", projactvar.Travel.ToString("n2"));
            AddToVariablesDictionary(ref mailMergeVars, prefix + "euro_orgsupport", projactvar.OrgSupport.ToString("n2"));
            AddToVariablesDictionary(ref mailMergeVars, prefix + "euro_total", (projactvar.OrgSupport + projactvar.Travel).ToString("n2"));
        }
Пример #5
0
        public void prepareMailMergeDataVariation(modelProjectVariation prjVariation, ref Dictionary <string, string> mailMergeVars)
        {
            modelOrganization emptyOrg = new modelOrganization();

            //modelProjectVariation projvar1 = null;
            modelProjectActivityVariation projactvar1 = null;
            //modelProjectVariation projvar2 = null;
            modelProjectActivityVariation projactvar2 = null;
            modelOrganization             applicant   = emptyOrg;
            modelOrganization             partner01   = emptyOrg;
            modelOrganization             partner02   = emptyOrg;
            modelOrganization             partner03   = emptyOrg;
            modelOrganization             partner04   = emptyOrg;
            modelOrganization             partner05   = emptyOrg;
            modelOrganization             partner06   = emptyOrg;
            modelOrganization             partner07   = emptyOrg;
            modelMobility emptyMobility = new modelMobility();

            var actvars = Program.GData.dataProject.getProjectActivityVariations.Where(c => c.ProjectVariation == prjVariation.ID).ToArray();

            if (actvars.Count() == 0)
            {
                return;
            }
            if (actvars.Count() == 1)
            {
                projactvar1          = actvars[0];
                projactvar2          = new modelProjectActivityVariation();
                projactvar2.Duration = 1;
            }
            if (actvars.Count() == 2)
            {
                projactvar1 = actvars[0];
                projactvar2 = actvars[1];
            }

            applicant = Program.GData.dataOrganization.getOrganization(prjVariation.ApplicantOrganization);
            var partners = Program.GData.dataProject.getProjectVariationOrganizations.Where(c => c.ProjectVariation == prjVariation.ID).OrderBy(d => d.OrganizationOrder).ToArray();

            if (partners.Count() > 0)
            {
                partner01 = Program.GData.dataOrganization.getOrganization(partners[0].Organization);
            }
            if (partners.Count() > 1)
            {
                partner02 = Program.GData.dataOrganization.getOrganization(partners[1].Organization);
            }
            if (partners.Count() > 2)
            {
                partner03 = Program.GData.dataOrganization.getOrganization(partners[2].Organization);
            }
            if (partners.Count() > 3)
            {
                partner04 = Program.GData.dataOrganization.getOrganization(partners[3].Organization);
            }
            if (partners.Count() > 4)
            {
                partner05 = Program.GData.dataOrganization.getOrganization(partners[4].Organization);
            }
            if (partners.Count() > 5)
            {
                partner06 = Program.GData.dataOrganization.getOrganization(partners[5].Organization);
            }
            if (partners.Count() > 6)
            {
                partner07 = Program.GData.dataOrganization.getOrganization(partners[6].Organization);
            }

            string countryList = applicant.getCountryCode() + "," + partner01.getCountryCode() + "," + partner02.getCountryCode() + "," + partner03.getCountryCode() + "," + partner04.getCountryCode() + "," + partner05.getCountryCode() + "," + partner06.getCountryCode() + "," + partner07.getCountryCode();

            while (countryList.Contains(",,"))
            {
                countryList = countryList.Replace(",,", ",");
            }
            if (countryList.Substring(countryList.Length - 1) == ",")
            {
                countryList = countryList.Substring(0, countryList.Length - 1);
            }

            var mobilities1 = Program.GData.dataActivity.getMobilities.Where(c => c.ActivityVariation == projactvar1.ID).OrderBy(c => c.MobilityOrder).ToArray();
            var mobilities2 = Program.GData.dataActivity.getMobilities.Where(c => c.ActivityVariation == projactvar2.ID).OrderBy(c => c.MobilityOrder).ToArray();

            AddProjectVariationVariables(ref mailMergeVars, prjVariation, partners, countryList);
            AddProjectActivityVariationVariables(ref mailMergeVars, projactvar1, partners, "a1_");
            AddProjectActivityVariationVariables(ref mailMergeVars, projactvar2, partners, "a2_");

            int sum1_facilitators = 0;
            int sum1_stuff        = 0;
            int sum1_gtl          = 0;
            int sum1_participants = 0;

            for (int idx = 0; idx < 8; idx++)
            {
                if (mobilities1.Count() > idx)
                {
                    AddMobilityVariables(ref mailMergeVars, mobilities1[idx], "a1_mob" + (idx + 1).ToString() + "_");
                    sum1_facilitators += mobilities1[idx].Facilitators;
                    sum1_stuff        += mobilities1[idx].Others;
                    sum1_gtl          += mobilities1[idx].GroupLeaders + mobilities1[idx].Trainers + mobilities1[idx].Facilitators;
                    sum1_participants += mobilities1[idx].Participants;
                }
                else
                {
                    AddMobilityVariables(ref mailMergeVars, emptyMobility, "a1_mob" + (idx + 1).ToString() + "_");
                }
            }
            AddMobilitySumsVariables(ref mailMergeVars, sum1_facilitators, sum1_stuff, sum1_gtl, sum1_participants, "a1_");

            int sum2_facilitators = 0;
            int sum2_stuff        = 0;
            int sum2_gtl          = 0;
            int sum2_participants = 0;

            for (int idx = 0; idx < 8; idx++)
            {
                if (mobilities2.Count() > idx)
                {
                    AddMobilityVariables(ref mailMergeVars, mobilities2[idx], "a2_mob" + (idx + 1).ToString() + "_");
                    sum2_facilitators += mobilities2[idx].Facilitators;
                    sum2_stuff        += mobilities2[idx].Others;
                    sum2_gtl          += mobilities2[idx].GroupLeaders + mobilities2[idx].Trainers + mobilities2[idx].Facilitators;
                    sum2_participants += mobilities2[idx].Participants;
                }
                else
                {
                    AddMobilityVariables(ref mailMergeVars, emptyMobility, "a2_mob" + (idx + 1).ToString() + "_");
                }
            }
            AddMobilitySumsVariables(ref mailMergeVars, sum2_facilitators, sum2_stuff, sum2_gtl, sum2_participants, "a2_");

            AddApplicantVariables(ref mailMergeVars, applicant, "applicant_");
            AddPartnerVariables(ref mailMergeVars, partner01, "partner01_");
            AddPartnerVariables(ref mailMergeVars, partner02, "partner02_");
            AddPartnerVariables(ref mailMergeVars, partner03, "partner03_");
            AddPartnerVariables(ref mailMergeVars, partner04, "partner04_");
            AddPartnerVariables(ref mailMergeVars, partner05, "partner05_");
            AddPartnerVariables(ref mailMergeVars, partner06, "partner06_");
            AddPartnerVariables(ref mailMergeVars, partner07, "partner07_");
        }