/// <summary>
        /// Handles the Click event of the btnExportCsv control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnExportCsv_Click(object sender, EventArgs e)
        {
            try
              {
            #region lekérdezzük a OrganisationContainer -t (a szûrési feltételeknek megfelelõen)

            // Get query result from database
            Organisation filter = new Organisation(Guid.NewGuid());
            filter.Name = txtName.Text;
            filter.RegionRef = cmbRegion.SelectedValue;
            filter.OrganisationFormRef = cmbOrganisationForm.SelectedValue;
            if (cbxPrevention.Checked) filter.ActivityPrevention = true;
            if (cbxResearch.Checked) filter.ActivityResearch = true;
            if (cbxRehabilitation.Checked) filter.ActivityRehabilitation = true;
            if (cbxOther.Checked) filter.ActivityOther = true;
            filter.FilterOnIsactive = 1;

            IOrganisationService orgSrv = ServiceFactory.GetOrganisationService();
            OrganisationContainer selected = orgSrv.OrganisationSelectFiltered(filter);

            #endregion

            // Writes result to response
            string csv = selected.ExportToCsv();
            Helpers.DownloadFile(csv, "szervezetek.csv");
              }
              catch (Exception ex)
              {
            errorPanel.Exception = ex;
              }
        }
Esempio n. 2
0
        protected void ShowGrid(DataGrid dataGrid,
                            int index, string sort, string order)
        {
            //lekérdezzük a régió kódhoz tartozó nevet

              IOrganisationService srvOrg = ServiceFactory.GetOrganisationService();
              Organisation filter = new Organisation(Guid.NewGuid());
              filter.FilterOnIsactive = (DBInt) Convert.ToInt32(true);
              filter.IsActive = true;
              filter.IsKef = true;
              OrganisationDispsetContainer data = srvOrg.OrganisationSelectDispsetFiltered(filter);
              OrganisationDispsetContainer contUnion = data;

              ArrayList sortableList = null;
              // Sort if necessary
              if (sort == null)
              {
            sortableList = contUnion.All.Items;
              }
              else
              {
            if (String.Compare(order, "Ascending", true) == 0)
            {
              sortableList = contUnion.All.SortBy(sort, true);
            }
            else if (String.Compare(order, "Descending", true) == 0)
            {
              sortableList = contUnion.All.SortBy(sort, false);
            }
            else
            {
              sortableList = data.All.SortBy(sort);
            }
              }

              if (contUnion.AllCount > 0)
              {
            // Bind list to datagrid control
            dataGrid.CurrentPageIndex = index;
            dataGrid.CurrentSortExpression = sort;
            dataGrid.CurrentSortOrder = order;
            dataGrid.DataSource = sortableList;
            dataGrid.DataBind();
            dataGrid.Visible = true;
            dataGrid.Focus();
              }
              else
              {
            dataGrid.Visible = false;
              }
        }
 /// <summary>
 /// Noes the program validation.
 /// </summary>
 /// <param name="org">The org.</param>
 /// <returns></returns>
 public string NoProgramValidate(Organisation org)
 {
     string organisationState = org.ValidationState ?? "";
       if (organisationState == OrganisationValidate.IsValid || organisationState == "")
       {
     organisationState = OrganisationValidate.NoProgram;
       }
       else
       {
     if (organisationState.IndexOf(OrganisationValidate.NoProgram) < 0)
       //még nem írtam be ezt a hibát
       organisationState += " " + OrganisationValidate.NoProgram;
       }
       return organisationState;
 }
        public OrganisationContainer OrganisationSelectFiltered(Organisation filter)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            DBInt ActivityPrevention = DBInt.Null;
            if (filter.ActivityPrevention) ActivityPrevention = 1;
            DBInt ActivityResearch = DBInt.Null;
            if (filter.ActivityResearch) ActivityResearch = 1;
            DBInt ActivityRehabilitation = DBInt.Null;
            if (filter.ActivityRehabilitation) ActivityRehabilitation = 1;
            DBInt ActivityOther = DBInt.Null;
            if (filter.ActivityOther) ActivityOther = 1;

            DBInt ActivityCoord = DBInt.Null;
            if (filter.FilterOnIsKef != DBInt.Null) ActivityCoord = filter.FilterOnIsKef;

            OrganisationContainer result;
            DataSet entitySet = m_DataContext.ndihdOrganisationSelectFiltered(
              filter.Name,
              filter.RegionRef,
              filter.OrganisationFormRef,
              ActivityPrevention,
              ActivityResearch,
              ActivityRehabilitation,
              ActivityOther,
              filter.FilterOnIsactive,
              filter.FilterOnIsKef,
              filter.ValidationState);
            result = new OrganisationContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public void OrganisationSetActive(Organisation entity)
        {
            // Check permission: Admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Logical checks
            Organisation selected = base.OrganisationSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik szervezet.");

            // Save data
            selected.IsActive = entity.IsActive;
            base.OrganisationUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 6
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="IDVal">Value of 'uID' field</param>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public Organisation(DBGuid IDVal,
                 Organisation origInstance)
     : base(IDVal, origInstance)
 {
 }
Esempio n. 7
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public Organisation(Organisation origInstance)
     : base(origInstance)
 {
 }
        /// <summary>
        /// Organisations the base data validation priv.
        /// </summary>
        /// <param name="org">The org.</param>
        /// <param name="referenceDate">The reference date.</param>
        /// <param name="numDays">The num days.</param>
        /// <param name="service">if set to <c>true</c> [service].</param>
        /// <returns></returns>
        private string OrganisationBaseDataValidationPriv(Organisation org, DateTime referenceDate, int numDays, bool service)
        {
            string organisationState = org.ValidationState ?? "";
              if (service)
              {
               // if (referenceDate < (DateTime) (org.LastModified?? DateTime.MinValue))
            {
              if (organisationState == OrganisationValidate.IsValid || organisationState == "")
            organisationState = OrganisationValidate.NoBaseDatasRefresh;
              else
              {
            if (organisationState.IndexOf(OrganisationValidate.NoBaseDatasRefresh) < 0)
              //még nem írtam be ezt a hibát
              organisationState += " " + OrganisationValidate.NoBaseDatasRefresh;
              }
            }
              }
              else
              {

              if (referenceDate.AddDays(-numDays) > (DateTime)(org.LastModified ?? DateTime.MinValue))
            {
              if (organisationState == OrganisationValidate.IsValid || organisationState == "")
            organisationState = OrganisationValidate.NoBaseDatasRefresh;
              else
              {
            if (organisationState.IndexOf(OrganisationValidate.NoBaseDatasRefresh) < 0)
              //még nem írtam be ezt a hibát
              organisationState += " " + OrganisationValidate.NoBaseDatasRefresh;
              }
            }
              }
              return organisationState;
        }
Esempio n. 9
0
        protected void ShowGrid(DataGrid dataGrid,
                            int index, string sort, string order, string regionCode)
        {
            dataGrid.PageSize = Helper.GetPageSize("PageSize.RegionSearch");

              if (regionCode != null)
              {
            //lekérdezzük a régió kódhoz tartozó nevet
            IRegionSearchService srvRegSearch = ServiceFactory.GetRegionSearchService();
            lblRegionName.Text = srvRegSearch.RegionSearchSelect(regionCode).RegionDescription;
            lblRegionName.Text = "(" + lblRegionName.Text + ")";

            IOrganisationService srvOrg = ServiceFactory.GetOrganisationService();
            Organisation filter = new Organisation(Guid.NewGuid());
            filter.FilterOnIsactive = (DBInt) Convert.ToInt32(true);
            filter.IsActive = true;
            filter.RegionSearchCodeRef = regionCode;
            OrganisationDispsetContainer data = srvOrg.OrganisationSelectDispsetFiltered(filter);
            OrganisationDispsetContainer contUnion = data;

            ArrayList sortableList = null;
            // Sort if necessary
            if (sort == null)
            {
              sortableList = contUnion.All.Items;
            }
            else
            {
              if (String.Compare(order, "Ascending", true) == 0)
              {
            sortableList = contUnion.All.SortBy(sort, true);
              }
              else if (String.Compare(order, "Descending", true) == 0)
              {
            sortableList = contUnion.All.SortBy(sort, false);
              }
              else
              {
            sortableList = data.All.SortBy(sort);
              }
            }

            if (contUnion.AllCount > 0)
            {
              // Bind list to datagrid control
              dataGrid.CurrentPageIndex = index;
              dataGrid.CurrentSortExpression = sort;
              dataGrid.CurrentSortOrder = order;
              dataGrid.DataSource = sortableList;
              dataGrid.DataBind();
              dataGrid.Visible = true;
              dataGrid.Focus();
              lblPleaseSelect.Visible = false;
            }
            else
            {
              dataGrid.Visible = false;
              lblNotFound.Visible = true;
              lblPleaseSelect.Visible = false;
            }
              }
              else lblPleaseSelect.Visible = true;
        }
Esempio n. 10
0
        public void OrganisationUpdateBase(Organisation entity)
        {
            // check permission: Writer or Admin
              string writerRole = entity.ID.Value.ToString() + ".Writer";
              PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permWriter.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("Organisation.Name", "A szervezet neve nincs megadva.");
            if (entity.PostCode.Length == 0)
              throw new ArgumentNullException("Organisation.PostCode", "A szervezet címének irányítószáma nincs megadva.");
            if (entity.City.Length == 0)
              throw new ArgumentNullException("Organisation.City", "A szervezet címének települése nincs megadva.");
            if (entity.Address.Length == 0)
              throw new ArgumentNullException("Organisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("Organisation.OrganisationFormRef", "A szervezeti forma kódja nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("Organisation.WorkingAreaRef", "A mûködési terület nincs megadva.");

            // logical checks:
            Organisation selected = base.OrganisationSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik szervezet.");

            NdiPrincipal principal = (NdiPrincipal) Thread.CurrentPrincipal;
            if (!selected.IsActive && !principal.IsInRole("Administrator"))
              throw new ApplicationException("A szervezet nem aktív.");
            // save data:
            entity.IsActive = selected.IsActive;
            entity.LastValidationDate = selected.LastValidationDate;
            entity.ValidationState = selected.ValidationState;
            //entity.LastModified = DateTime.Now; //Ezt azért vettem ki, hogyha az admin módosít, akkor ne tűnjön módosításnak
            try
            {
              m_DataContext.BeginNestedTran();
              //elmentjük a szervezet módosított adatokat
              base.OrganisationUpdate(entity);
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 11
0
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Fill edit window controls
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void RetrieveData()
        {
            try
              {
            // Get data
            IOrganisationService srv = ServiceFactory.GetOrganisationService();
            IOrganisationAttachmentService srvOrgAtt = ServiceFactory.GetOrganisationAttachmentService();
            Organisation org = srv.OrganisationSelect(CurrentID);

            // Fill the controls

            // First page
            txtOrganisationName.Text = org.Name;
            txtDepartment.Text = org.Department;
            txtPostCode.Text = org.PostCode;
            txtCity.Text = org.City;
            txtOrgAddress.Text = org.Address;
            txtCountry.Text = org.Country;
            cmbRegion.SelectedValue = org.RegionRef.ToString();
            txtMailingPostCode.Text = org.MailingPostCode;
            txtMailingCity.Text = org.MailingCity;
            txtMailingAddress.Text = org.MailingAddress;
            txtPhone1.Text = org.Phone1;
            txtPhone2.Text = org.Phone2;
            txtPhone3.Text = org.Phone3;
            txtPhonediscounted.Text = org.PhoneDiscounted;
            txtFax.Text = org.Fax;
            txtHomePage.Text = org.HomePage;
            txtEmail1.Text = org.Email1;
            txtEmail2.Text = org.Email2;
            txtEmail3.Text = org.Email3;
            txtContactName.Text = org.ContactName;
            txtContactPhone.Text = org.ContactPhone;
            txtContactEmail.Text = org.ContactEmail;
            txtDescription.Text = org.Description;
            txtCallingHours.Text = org.CallingHours;
            cmbOrganisationForm.SelectedValue = org.OrganisationFormRef.ToString();
            txtEstablishmentYear.Text = org.EstablishmentYear;
            cbxOrgActPrevention.Checked = org.ActivityPrevention;
            cbxOrgActRehabilitation.Checked = org.ActivityRehabilitation;
            cbxOrgActResearch.Checked = org.ActivityResearch;
            cbxOrgActOther.Checked = org.ActivityOther;
            cmbOrgWorkingArea.SelectedValue = org.WorkingAreaRef.ToString();
            txtOrgWorkingAreaOther.Text = org.WorkingAreaOther;
            cbxActivate.Checked = org.IsActive;

            // Second page
            txtSourceGovernment.Text = org.SourceGovernment.ToString();
            txtSourceCompetition.Text = org.SourceCompetition.ToString();
            txtSourceSponsor.Text = org.SourceSponsor.ToString();
            txtSourceDonation.Text = org.SourceDonation.ToString();
            txtSourceTax.Text = org.SourceTax.ToString();
            txtSourceOther.Text = org.SourceOther.ToString();
            txtSourceOtherName.Text = org.SourceOtherName;
            txtWorkersFix.Text = org.WorkersFix.ToString();
            txtWorkersExternal.Text = org.WorkersExternal.ToString();
            txtWorkersVolunteer.Text = org.WorkersVolunteer.ToString();
            txtJobPsychologist.Text = org.JobPsychologist.ToString();
            txtJobPsychiater.Text = org.JobPsychiater.ToString();
            txtJobDoctor.Text = org.JobDoctor.ToString();
            txtJobMedicalExpert.Text = org.JobMedicalExpert.ToString();
            txtJobHealthExpert.Text = org.JobHealthExpert.ToString();
            txtJobSociologist.Text = org.JobSociologist.ToString();
            txtJobSocialPolitician.Text = org.JobSocialPolitician.ToString();
            txtJobSocialWorker.Text = org.JobSocialWorker.ToString();
            txtJobSocialPedagogist.Text = org.JobSocialPedagogist.ToString();
            txtJobPedagogist.Text = org.JobPedagogist.ToString();
            txtJobManualist.Text = org.JobManualist.ToString();
            txtJobLawyer.Text = org.JobLawyer.ToString();
            txtJobPoliceman.Text = org.JobPoliceman.ToString();
            txtJobMentalhygiene.Text = org.JobMentalhygiene.ToString();
            txtJobCultureOrganizer.Text = org.JobCultureOrganizer.ToString();
            txtJobOther1.Text = org.JobOther1.ToString();
            txtJobOther2.Text = org.JobOther2.ToString();
            txtJobOther3.Text = org.JobOther3.ToString();
            txtJobOtherName1.Text = org.JobOtherName1;
            txtJobOtherName2.Text = org.JobOtherName2;
            txtJobOtherName3.Text = org.JobOtherName3;

            // Save original value
            bIsActive = org.IsActive;
            cbxActual.Checked = org.IsActual;
            #region Egyéb dokumentumok

            m_CurrentOrganisation = srv.OrganisationSelect(org.ID);
            m_CurrentOrganisation.OrgAttachments =
              srvOrgAtt.OrganisationAttachmentSelectFiltered(org.ID, false, false, true);

            foreach (OrganisationAttachment file in m_CurrentOrganisation.OrgAttachments.All)
            {
              OrganisationAttachment fileData = srvOrgAtt.OrganisationAttachmentSelectFile(file.ID);
              file.DownloadData = fileData.DownloadData;
            }

            FillKefFilesDatagrid(DBGuid.Null);

            #endregion
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Hiba lépett fel az adatok lekérdezése során", ex);
            //	---	invisible btnOk button
            btnOk.Visible = false;
              }
        }
 public virtual void OrganisationUpdate(Organisation entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdOrganisationUpdate(entity.ID,
                                         entity.Name,
                                         entity.Department,
                                         entity.PostCode,
                                         entity.City,
                                         entity.Address,
                                         entity.RegionRef,
                                         entity.Country,
                                         entity.MailingPostCode,
                                         entity.MailingCity,
                                         entity.MailingAddress,
                                         entity.Phone1,
                                         entity.Phone2,
                                         entity.Phone3,
                                         entity.PhoneDiscounted,
                                         entity.Fax,
                                         entity.Email1,
                                         entity.Email2,
                                         entity.Email3,
                                         entity.HomePage,
                                         entity.ContactName,
                                         entity.ContactPhone,
                                         entity.ContactEmail,
                                         entity.Description,
                                         entity.CallingHours,
                                         entity.OrganisationFormRef,
                                         entity.SourceGovernment,
                                         entity.SourceCompetition,
                                         entity.SourceSponsor,
                                         entity.SourceDonation,
                                         entity.SourceTax,
                                         entity.SourceOther,
                                         entity.SourceOtherName,
                                         entity.EstablishmentYear,
                                         entity.ActivityPrevention,
                                         entity.ActivityResearch,
                                         entity.ActivityRehabilitation,
                                         entity.ActivityOther,
                                         entity.WorkingAreaRef,
                                         entity.WorkingAreaOther,
                                         entity.WorkersFix,
                                         entity.WorkersExternal,
                                         entity.WorkersVolunteer,
                                         entity.IsActive,
                                         entity.JobPsychologist,
                                         entity.JobPsychiater,
                                         entity.JobDoctor,
                                         entity.JobMedicalExpert,
                                         entity.JobHealthExpert,
                                         entity.JobSociologist,
                                         entity.JobSocialPolitician,
                                         entity.JobSocialWorker,
                                         entity.JobSocialPedagogist,
                                         entity.JobPedagogist,
                                         entity.JobManualist,
                                         entity.JobLawyer,
                                         entity.JobPoliceman,
                                         entity.JobMentalhygiene,
                                         entity.JobCultureOrganizer,
                                         entity.JobOther1,
                                         entity.JobOther2,
                                         entity.JobOther3,
                                         entity.JobOtherName1,
                                         entity.JobOtherName2,
                                         entity.JobOtherName3,
                                         entity.IsKef,
                                         entity.RegionSearchCodeRef,
                                         entity.DistrictSearchCodeRef,
                                         entity.IntroduceText,
                                         entity.DrogStrategyDescription,
                                         entity.AreaDescription,
                                         entity.EstablishmentMonth,
                                         entity.AreaHomePage,
                                         entity.LastModified,
                                         entity.IntroduceTextLastModified,
                                         entity.AreaDescriptionLastModified,
                                         entity.DrogStrategyLastModified,
                                         entity.KefMembersLastModified,
                                         entity.KefDownloadsLastModified,
                                         entity.KefEventsLastModified,
                                         entity.ValidationState,
                                         entity.LastValidationDate,
                                         entity.IsActual, out count);
       if (count == 0) throw new ServiceUpdateException();
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Esempio n. 13
0
        protected void ShowGrid(DataGrid dataGrid,
                            int index, string sort, string order, string selectedRegion)
        {
            dataGrid.PageSize = Helpers.GetPageSize("PageSize.OrganisationList");

              // Get query result from database
              Organisation filter = new Organisation(Guid.NewGuid());
              filter.RegionRef = selectedRegion;
              filter.FilterOnIsactive = 1;
              IOrganisationService orgSrv = ServiceFactory.GetOrganisationService();
              OrganisationDispsetContainer orgSelected = orgSrv.OrganisationSelectDispsetFiltered(filter);

              if (orgSelected.AllCount > 0)
              {
            dataGrid.Visible = true;
            lblNotFound.Visible = false;
              }
              else
              {
            dataGrid.Visible = false;
            lblNotFound.Visible = true;
              }
              ArrayList sortableList = null;
              // Sort if necessary
              if (sort == null)
              {
            sortableList = orgSelected.All.Items;
              }
              else
              {
            if (String.Compare(order, "Ascending", true) == 0)
            {
              sortableList = orgSelected.All.SortBy(sort, true);
            }
            else if (String.Compare(order, "Descending", true) == 0)
            {
              sortableList = orgSelected.All.SortBy(sort, false);
            }
            else
            {
              sortableList = orgSelected.All.SortBy(sort);
            }
              }

              // Bind list to datagrid control
              dataGrid.CurrentPageIndex = index;
              if (orgSelected.AllCount <= dataGrid.PageSize * dataGrid.CurrentPageIndex)
              {
            dataGrid.CurrentPageIndex = 0;
              }
              else
              {
            dataGrid.CurrentPageIndex = index;
              }

              //dataGrid.CurrentSortExpression = sort;
              //dataGrid.CurrentSortOrder = order;

              if (sort != null)
              {
            dataGrid.CurrentSortExpression = sort;
              }
              if (order != null)
              {
            dataGrid.CurrentSortOrder = order;
              }
              dataGrid.DataSource = sortableList;
              dataGrid.DataBind();
        }
 public virtual Organisation OrganisationSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     Organisation result = null;
     DataSet entitySet = m_DataContext.ndihdOrganisationSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new Organisation(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public virtual void OrganisationDelete(Organisation entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdOrganisationDelete(entity.ID);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        protected void btnModify_Click(object sender, EventArgs e)
        {
            try
              {
            if (!Page.IsValid)
            {
              return;
            }

            IOrganisationService orgSrv = ServiceFactory.GetOrganisationService();

            NdiPrincipal principal = (NdiPrincipal) Context.User;
            Organisation origOrg = orgSrv.OrganisationSelect(principal.OrganisationID);
            Organisation org = new Organisation(principal.OrganisationID);

            org.SourceTax = Convert.ToInt32(txtSourceTax.Text);

            org.Name = txtOrgName.Text;
            org.Department = txtDepartment.Text;
            org.PostCode = txtPostCode.Text;
            org.City = txtCity.Text;
            org.Address = txtAddress.Text;
            if (rbtHungary.Checked)
            {
              if (cmbRegion.SelectedValue.Length == 0)
              {
            throw new ArgumentNullException("Organisation.Region", "A megye nincs megadva.");
              }
              org.RegionRef = cmbRegion.SelectedValue;
            }
            if (rbtAbroad.Checked)
            {
              org.Country = txtCountry.Text;
            }
            org.MailingPostCode = txtMailingPostCode.Text;
            org.MailingCity = txtMailingCity.Text;
            org.MailingAddress = txtMailingAddress.Text;
            org.Phone1 = txtPhone1.Text;
            org.Phone2 = txtPhone2.Text;
            org.Phone3 = txtPhone3.Text;
            org.PhoneDiscounted = txtPhoneDiscounted.Text;
            org.Fax = txtFax.Text;
            org.Email1 = txtEmail1.Text;
            org.Email2 = txtEmail2.Text;
            org.Email3 = txtEmail3.Text;
            org.HomePage = txtHomePage.Text;
            org.ContactName = txtContactName.Text;
            org.ContactPhone = txtContactPhone.Text;
            org.ContactEmail = txtContactEmail.Text;
            org.Description = txtDescription.Text;
            org.CallingHours = txtCallingHours.Text;
            org.OrganisationFormRef = cmbOrganisationForm.SelectedValue;
            org.SourceGovernment = Convert.ToDouble(txtSourceGovernment.Text);
            org.SourceCompetition = Convert.ToDouble(txtSourceCompetition.Text);
            org.SourceSponsor = Convert.ToDouble(txtSourceSponsor.Text);
            org.SourceDonation = Convert.ToDouble(txtSourceDonation.Text);
            org.SourceTax = Convert.ToDouble(txtSourceTax.Text);
            org.SourceOther = Convert.ToDouble(txtSourceOther.Text);
            org.SourceOtherName = txtSourceOtherName.Text;
            org.EstablishmentYear = txtEstablishmentYear.Text;
            org.ActivityPrevention = cbxPrevention.Checked;
            org.ActivityResearch = cbxResearch.Checked;
            org.ActivityRehabilitation = cbxRehabilitation.Checked;
            org.ActivityOther = cbxOther.Checked;
            org.WorkingAreaRef = cmbWorkingArea.SelectedValue;
            org.WorkingAreaOther = txtWorkingAreaOther.Text;
            org.WorkersFix = Convert.ToInt32(txtWorkersFix.Text);
            org.WorkersExternal = Convert.ToInt32(txtWorkersExternal.Text);
            org.WorkersVolunteer = Convert.ToInt32(txtWorkersVolunteer.Text);
            org.JobPsychologist = Convert.ToInt32(txtJobPsychologist.Text);
            org.JobPsychiater = Convert.ToInt32(txtJobPsychiater.Text);
            org.JobDoctor = Convert.ToInt32(txtJobDoctor.Text);
            org.JobMedicalExpert = Convert.ToInt32(txtJobMedicalExpert.Text);
            org.JobHealthExpert = Convert.ToInt32(txtJobHealthExpert.Text);
            org.JobSociologist = Convert.ToInt32(txtJobSociologist.Text);
            org.JobSocialPolitician = Convert.ToInt32(txtJobSocialPolitician.Text);
            org.JobSocialWorker = Convert.ToInt32(txtJobSocialWorker.Text);
            org.JobSocialPedagogist = Convert.ToInt32(txtJobSocialPedagogist.Text);
            org.JobPedagogist = Convert.ToInt32(txtJobPedagogist.Text);
            org.JobManualist = Convert.ToInt32(txtJobManualist.Text);
            org.JobLawyer = Convert.ToInt32(txtJobLawyer.Text);
            org.JobPoliceman = Convert.ToInt32(txtJobPoliceman.Text);
            org.JobMentalhygiene = Convert.ToInt32(txtJobMentalhygiene.Text);
            org.JobCultureOrganizer = Convert.ToInt32(txtJobCultureOrganizer.Text);
            org.JobOther1 = Convert.ToInt32(txtJobOther1.Text);
            org.JobOther2 = Convert.ToInt32(txtJobOther2.Text);
            org.JobOther3 = Convert.ToInt32(txtJobOther3.Text);
            org.JobOtherName1 = txtJobOtherName1.Text;
            org.JobOtherName2 = txtJobOtherName2.Text;
            org.JobOtherName3 = txtJobOtherName3.Text;
            org.LastModified = DateTime.Now;
            if (origOrg != null && origOrg.IsActual && !chkIsActual.Checked) //konrétan annyit módosított, hogy direkt kikapcsolta
              org.IsActual = false;
            else
              org.IsActual = true ; //Amikor módosít, akkor úgy véli, hogy naprakészchkIsActual.Checked;

            orgSrv.OrganisationUpdateBase(org);

            Response.Redirect("OrganisationData.aspx?orgID=" + principal.OrganisationID.ToString());
              }
              catch (Exception ex)
              {
            errorPanel.Exception = ex;
              }
        }
Esempio n. 17
0
        public new void OrganisationUpdate(Organisation entity)
        {
            // check permission: Writer or Admin
              string writerRole = entity.ID.Value.ToString() + ".Writer";
              PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permWriter.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("Organisation.Name", "A szervezet neve nincs megadva.");
            if (entity.PostCode.Length == 0)
              throw new ArgumentNullException("Organisation.PostCode", "A szervezet címének irányítószáma nincs megadva.");
            if (entity.City.Length == 0)
              throw new ArgumentNullException("Organisation.City", "A szervezet címének települése nincs megadva.");
            if (entity.Address.Length == 0)
              throw new ArgumentNullException("Organisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");
            //if(entity.MailingPostCode.Length == 0)  throw new ArgumentNullException("Organisation.MailingPostCode", "A szervezet levelezési címének irányítószáma nincs megadva.");
            //if(entity.MailingCity.Length == 0)  throw new ArgumentNullException("Organisation.MailingCity", "A szervezet levelezési címének települése nincs megadva.");
            //if(entity.MailingAddress.Length == 0)  throw new ArgumentNullException("Organisation.MailingAddress", "A szervezet levelezési címének utca, házszám része nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("Organisation.OrganisationFormRef", "A szervezeti forma kódja nincs megadva.");
            //if(entity.EstablishmentYear.Length == 0)  throw new ArgumentNullException("Organisation.EstablishmentYear", "A szervezet alapításának éve nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("Organisation.WorkingAreaRef", "A mûködési terület nincs megadva.");

            // logical checks:
            Organisation selected = base.OrganisationSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik szervezet.");

            NdiPrincipal principal = (NdiPrincipal) Thread.CurrentPrincipal;
            if (!selected.IsActive && !principal.IsInRole("Administrator"))
              throw new ApplicationException("A szervezet nem aktív.");
            // save data:
            entity.IsActive = selected.IsActive;

            //entity.LastModified = DateTime.Now; ide csak az user módosítás lesz beírva, és ezt nem hívja az user
            try
            {
              m_DataContext.BeginNestedTran();

              //elmentjük a szervezet módosított adatokat
              base.OrganisationUpdate(entity);

              //elmentjük a szervezethez tartozó feltöltött fileokat
              OrganisationAttachmentService srvOrgAtt = new OrganisationAttachmentService(m_DataContext);

              // Clear old files:
              OrganisationAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfOrganisation(entity.ID);

              foreach (OrganisationAttachment oldFile in oldFiles.All)
              {
            srvOrgAtt.OrganisationAttachmentDelete(oldFile);
              }

              foreach (OrganisationAttachment file in entity.OrgAttachments.Current)
              {
            srvOrgAtt.OrganisationAttachmentInsert(file);
              }

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 18
0
 /// <summary>
 /// Organisations the base data validate.
 /// </summary>
 /// <param name="org">The org.</param>
 /// <param name="numDays">The num days.</param>
 /// <param name="referenceDate"></param>
 /// <returns></returns>
 public string OrganisationBaseDataValidate(Organisation org, int numDays, DateTime referenceDate)
 {
     return OrganisationBaseDataValidationPriv(org, referenceDate, numDays, false);
 }
Esempio n. 19
0
 private void SetOrganisationCombo()
 {
     IOrganisationService srv = ServiceFactory.GetOrganisationService();
       Organisation filter = new Organisation(Guid.NewGuid());
       filter.FilterOnIsactive = 1;
       OrganisationDispsetContainer data = srv.OrganisationSelectDispsetFiltered(filter);
       ArrayList sortableList = data.All.SortBy("Name");
       cmbOrganisation.DataSource = sortableList;
       cmbOrganisation.DataValueField = "ID";
       cmbOrganisation.DataTextField = "Name";
       cmbOrganisation.DataBind();
       ListItem li = new ListItem("-- Összes --", "");
       cmbOrganisation.Items.Insert(0, li);
 }
Esempio n. 20
0
        //kész
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Loads combos
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void LoadCombos()
        {
            try
              {
            //Load Organisations
            // First set filter
            Organisation filter = new Organisation(Guid.Empty);
            filter.FilterOnIsactive = 1;
            filter.IsActive = false;
            filter.IsKef = false;
            filter.IsKef = true;
            IOrganisationService srvOrg = ServiceFactory.GetOrganisationService();
            OrganisationDispsetContainer contOrg = srvOrg.OrganisationSelectDispsetFiltered(filter);
            DataTable dtKefMembers = contOrg.AllAsDatatable;
            CreateSimpleCombo(dtKefMembers, cmbKefMembers);
            //cmbKefMembers.LoadListItem(dtKefMembers,"ID","Name",false);

            #region Lehet e egyszerre több is ebbõl a tagból?

            FillContactTypeCombo();

            #endregion
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Hiba lépett fel a lista adatok feltöltése során", ex);
            //	---	invisible btnOk button
            btnOk.Visible = false;
              }
        }
Esempio n. 21
0
        public bool OrganisationValidateSendEmailByCategory(Organisation entity, string category, string adminMail)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Logical checks:
            Organisation selected = base.OrganisationSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik szervezet.");

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, category);

            // Le kell kérdezni a szervezethez tartozó irási joggal rendelkező felhasználókat
            User filter = new User(DBString.Empty);

            filter.Right = "W";
            filter.OrganisationRef = entity.ID;
            filter.IsActive = true;
            filter.FilterOnIsactive = DBInt.Null;
            filter.FilterOnLockedOut = 0;

            // Retrieving data from BusinessServices
            UserService srvUser = new UserService();

            UserContainer allUser = srvUser.UserSelectFiltered(filter);
            if (allUser.AllCount == 0)
            {
              OrganisationService srvOrgUser = new OrganisationService();
              OrganisationUserContainer orgUsers = srvOrgUser.SelectChildrenByOrganisationOfOrganisationUser(selected.ID);
              foreach (OrganisationUser orguser in orgUsers.All)
              {
            User user = srvUser.UserSelect(orguser.LoginNameRef);
            if (allUser[user.HashString()] == null)
              allUser.Add(user);

              }
            }

            foreach (User user in allUser.All)
            {
              string tmpBody = body;

              //set mail:
              Email mail = new Email(Guid.NewGuid());
              mail.Category = category;
              mail.To = user.Email; //"*****@*****.**";
              mail.OrganisationRef = entity.ID;

              tmpBody = tmpBody.Replace("<FULL_USER_NAME>", user.Name);
              tmpBody = tmpBody.Replace("<LOGIN_NAME>", user.LoginName);
              tmpBody = tmpBody.Replace("<ORGANISATION>", selected.Name);

              mail.MailBody = tmpBody;
              mail.Subject = subject;

              SendMail(mail);

            }

            if (!string.IsNullOrEmpty(adminMail)) //küldünk mailt az adminna is
            {
              string tmpBody = body;

              //set mail:
              Email mail = new Email(Guid.NewGuid());
              mail.Category = EmailCategory.ValidationInactivationAdmin;
              mail.To = adminMail; //"*****@*****.**";
              mail.OrganisationRef = entity.ID;

              tmpBody = tmpBody.Replace("<ORGANISATION>", selected.Name);

              mail.MailBody = tmpBody;
              mail.Subject = subject;

              SendMail(mail);
            }
            // Log success
            BusinessAuditEvent.Success(new EventParameter("OrganisationID", entity.ID.ToString()));

            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterUserID", entity.ID.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 22
0
        /// <summary>
        /// Programs the question form validate priv.
        /// </summary>
        /// <param name="org">The org.</param>
        /// <param name="prog">The prog.</param>
        /// <param name="referenceDate">The reference date.</param>
        /// <param name="refreshNum">The refresh num.</param>
        /// <param name="service">if set to <c>true</c> [service].</param>
        /// <returns></returns>
        private string ProgramQuestionFormValidatePriv(Organisation org, Program prog, DateTime referenceDate, int refreshNum, bool service)
        {
            string organisationState = org.ValidationState ?? "";
              var filter = new Template(DBGuid.Null)
                     {
                       PublicityLevel = 1,
                       FilterOnIsActive = 1,
                       FilterOnCategory = prog.ProgramCategoryRef
                     };

              //IOrganisationService organisationService = ServiceFactory.GetOrganisationService();
              ProgramService programService =  new ProgramService();
              PendingQuestionFormService pqfService = new PendingQuestionFormService();
              TemplateService templateSrv = new TemplateService();
              ProgramPendingQuestionFormContainer qfPendings =
            programService.SelectChildrenByPendingQuestionFormOfProgram(prog.ID);

              //Ezek azok a kérdőívek, amiknek ki kellene töltve lennie a programhoz
              TemplateContainer templSelectedOrg = templateSrv.TemplateSelectFiltered(filter);
              foreach (Template template in templSelectedOrg.All)
              {
            bool isFilled = false;
            var allPendingsToTemplate = new PendingQuestionFormContainer();
            // ebben a konténerben lesznek az ehhez a templatehez tartozó pendingek

            //megnézem van-e ilyen a szervezethez
            //ezek vannak kitöltve a szervezethez
            foreach (ProgramPendingQuestionForm qf in qfPendings.All)
            {
              //Az organisationhoz tartozóak a pendingben

              PendingQuestionForm pqf = pqfService.PendingQuestionFormSelect(qf.PendingQuestionFormRef);
              if (pqf != null && pqf.TemplateRef == template.ID /*&& pqf.Status != QuestionFormStatus.Updated_SendBack && pqf.Status != QuestionFormStatus.New_SendBack*/) // ki van töltve
              {
              //invaild státuszok
              if (pqf.Status.Equals(QuestionFormStatus.New) || pqf.Status.Equals(QuestionFormStatus.New_Rejected) ||
                  pqf.Status.Equals(QuestionFormStatus.New_SendBack) ||
                  pqf.Status.Equals(QuestionFormStatus.Updated) ||
                  pqf.Status.Equals(QuestionFormStatus.Updated_Rejected) ||
                  pqf.Status.Equals(QuestionFormStatus.Updated_SendBack))
              {
                  isFilled = false;
                  // Nincs kitöltve neki
                  if (organisationState == OrganisationValidate.IsValid || organisationState == "")
                  {
                      organisationState = OrganisationValidate.NoQuestionForm;
                  }
                  else
                  {
                      if (organisationState.IndexOf(OrganisationValidate.NoQuestionForm) < 0) //még nem írtam be ezt a hibát
                          organisationState += " " + OrganisationValidate.NoQuestionForm;
                  }
                  continue; //tovább a ciklusban, mert ezt elég egyszer beírni a státuszba
              }

                  isFilled = true;
                  //nincs még ilyen
                  if (allPendingsToTemplate[pqf.HashString()] == null)
                      allPendingsToTemplate.Add(pqf);

              }
            } // amikor ideérek, akkor az isFilled true, ha van ilyen kérdőív kitöltve a szervezethez
            //és a allPendingsToTemplate -ben benne van az összes pending ehhez a template-hez

            //amikor itt tartunk megvan az összes szervezethez  tartozó pendibgünk, ehhez a template-hoz
            if (allPendingsToTemplate.AllCount > 0)
            {
              //Ebből ki kell vennünk a legutolsót
              ArrayList allSorted = allPendingsToTemplate.All.SortBy("SentDate");
              //Itt egy sorrendezett listánk van
              //Kiveszem az utolsót, mert dátum szerint ezt kell nézni
              var validable = (PendingQuestionForm)allSorted[allSorted.Count - 1];
              //Mindig csak az utolsót kell validálni
              if (validable != null)
              {
            if (validable.Status.Equals(QuestionFormStatus.New_WaitingForDecision) ||
                validable.Status.Equals(QuestionFormStatus.Updated_WaitingForDecision))
            {
              continue; // végeztünk, mert jóváhagyásra váró kérdőíve van ehhez a template-hez
            }
            //megnézzük hogy jóváhagyottja van-e
            if (validable.Status.Equals(QuestionFormStatus.New_Accepted) ||
                validable.Status.Equals(QuestionFormStatus.Updated_Accepted))
            {
              if (service)
              {
                //van jóváhagyottja, akkor meg kell nézni, hogy az utplsó módosíás dátuma nem túl régi-e
                //if (referenceDate < (DateTime) validable.SentDate)
                {
                  // Túl régi ehhez a template-hoz
                  if (organisationState == OrganisationValidate.IsValid || organisationState == "")
                  {
                    organisationState = OrganisationValidate.NoQuestionFormRefresh;
                  }
                  else
                  {
                    if (organisationState.IndexOf(OrganisationValidate.NoQuestionFormRefresh) < 0)
                      //még nem írtam be ezt a hibát
                      organisationState += " " + OrganisationValidate.NoQuestionFormRefresh;
                  }
                }
              }
              else
              {
                //van jóváhagyottja, akkor meg kell nézni, hogy az utplsó módosíás dátuma nem túl régi-e
                if (referenceDate.AddDays(-(int)refreshNum) > (DateTime)validable.SentDate)
                {
                  // Túl régi ehhez a template-hoz
                  if (organisationState == OrganisationValidate.IsValid || organisationState == "")
                  {
                    organisationState = OrganisationValidate.NoQuestionFormRefresh;
                  }
                  else
                  {
                    if (organisationState.IndexOf(OrganisationValidate.NoQuestionFormRefresh) < 0)
                      //még nem írtam be ezt a hibát
                      organisationState += " " + OrganisationValidate.NoQuestionFormRefresh;
                  }
                }
              }
            }

            ////invaild státuszok
            //if (validable.Status.Equals(QuestionFormStatus.New) || validable.Status.Equals(QuestionFormStatus.New_Rejected) ||
            //    validable.Status.Equals(QuestionFormStatus.New_SendBack) ||
            //    validable.Status.Equals(QuestionFormStatus.Updated) ||
            //    validable.Status.Equals(QuestionFormStatus.Updated_Rejected) ||
            //    validable.Status.Equals(QuestionFormStatus.Updated_SendBack))
            //{
            //  isFilled = false;
            //}
              }
            }
            //nincs kitöltve
            if (!isFilled)
              if (organisationState == OrganisationValidate.IsValid || organisationState == "")
              {
            organisationState = OrganisationValidate.NoQuestionForm;
              }
              if (organisationState.IndexOf(OrganisationValidate.NoQuestionForm) < 0)
            //még nem írtam be ezt a hibát
            organisationState += " " + OrganisationValidate.NoQuestionForm;
              }
              //Mindig csak a legutolsó pendinget kell megnéznem. Ennek a státusza számít

              return organisationState;
        }
Esempio n. 23
0
 /// <summary>
 /// Programs the question from validate for service.
 /// </summary>
 /// <param name="org">The org.</param>
 /// <param name="prog">The prog.</param>
 /// <param name="refreshNum">The refresh num.</param>
 /// <param name="referenceDate">The reference date.</param>
 /// <returns></returns>
 public string ProgramQuestionFromValidateForService(Organisation org, Program prog, int refreshNum, DateTime referenceDate)
 {
     return ProgramQuestionFormValidatePriv(org, prog, referenceDate, refreshNum, true);
 }
Esempio n. 24
0
        public void OrganisationKefUpdate(Organisation org, KefEventContainer kefEvents, DataTable kefMembers)
        {
            // check permission: Writer or Admin
              string writerRole = org.ID.Value.ToString() + ".Writer";
              PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permWriter.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (org.Name.Length == 0)
              throw new ArgumentNullException("Organisation.Name", "A szervezet neve nincs megadva.");
            if (org.PostCode.Length == 0)
              throw new ArgumentNullException("Organisation.PostCode", "A szervezet címének irányítószáma nincs megadva.");
            if (org.City.Length == 0)
              throw new ArgumentNullException("Organisation.City", "A szervezet címének települése nincs megadva.");
            if (org.Address.Length == 0)
              throw new ArgumentNullException("Organisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");
            if (org.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("Organisation.OrganisationFormRef", "A szervezeti forma kódja nincs megadva.");
            if (org.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("Organisation.WorkingAreaRef", "A mûködési terület nincs megadva.");

            // logical checks:
            Organisation selected = base.OrganisationSelect(org.ID);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik szervezet.");

            NdiPrincipal principal = (NdiPrincipal) Thread.CurrentPrincipal;
            if (!selected.IsActive && !principal.IsInRole("Administrator"))
              throw new ApplicationException("A szervezet nem aktív.");
            // save data:
            org.IsActive = selected.IsActive;

            try
            {

              //elmentjük a szervezet módosított adatokat
              base.OrganisationUpdate(org);
              m_DataContext.BeginNestedTran();
              //töröljük az összes kapcsolódó eseményt ...
              OrganisationService srvOrg = new OrganisationService(m_DataContext);
              KefEventService srvKefEvent = new KefEventService(m_DataContext);
              srvOrg.DeleteChildrenByOrganisationOfKefEvent(org.ID);

              //majd beszúrjuk az újakat
              foreach (KefEvent item in kefEvents.Current)
              {
            srvKefEvent.KefEventInsert(item);
              }

              //töröljük az összes kapcsolódó tagot ...
              srvOrg.DeleteChildrenByKefOrgOfOrg(org.ID);
              OrgMemberOfOrgService srvKefMember = new OrgMemberOfOrgService(m_DataContext);

              //majd beszúrjuk az újakat
              foreach (DataRow row in kefMembers.Rows)
              {
            OrgMemberOfOrg member = new OrgMemberOfOrg(Guid.NewGuid());

            member.OrganisationKefRef = new Guid(row["uOrganisationKefRef"].ToString());
            member.OrganisationMemberRef = new Guid(row["uOrganisationMemberRef"].ToString());
            member.ContactName = row["cContactName"].ToString();
            member.ContactInstitution = row["cContactInstitution"].ToString();
            member.ContactZipCode = row["cContactZipCode"].ToString();
            member.ContactTownShip = row["cContactTownShip"].ToString();
            member.ContactAddress = row["cContactAddress"].ToString();
            member.ContactPhone1 = row["cContactPhone1"].ToString();
            member.ContactPhone2 = row["cContactPhone2"].ToString();
            member.ContactPhone3 = row["cContactPhone3"].ToString();
            member.ContactFax = row["cContactFax"].ToString();
            member.ContactPosition = row["cContactPosition"].ToString();
            member.ContactPositionInKef = row["cContactPositionInKef"].ToString();
            member.ContactEmail1 = row["cContactEmail1"].ToString();
            member.ContactEmail2 = row["cContactEmail2"].ToString();
            member.ContactEmail3 = row["cContactEmail3"].ToString();
            member.ContactQualification = row["cContactQualification"].ToString();
            member.KefContactTypeRef = row["cKefContactTypeRef"].ToString();

            srvKefMember.OrgMemberOfOrgInsert(member);
              }

              //elmentjük a szervezethez tartozó feltöltött fileokat
              OrganisationAttachmentService srvOrgAtt = new OrganisationAttachmentService(m_DataContext);

              // Clear old files:
              OrganisationAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfOrganisation(org.ID);

              foreach (OrganisationAttachment oldFile in oldFiles.All)
              {
            srvOrgAtt.OrganisationAttachmentDelete(oldFile);
              }

              foreach (OrganisationAttachment file in org.OrgAttachments.Current)
              {
            if(file.DownloadData != null)
              srvOrgAtt.OrganisationAttachmentInsert(file);
              }

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("OrganisationID", org.ID.ToString()),
              new EventParameter("OrganisationName", org.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("OrganisationID", org.ID.ToString()),
              new EventParameter("OrganisationName", org.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 25
0
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        private void FillDatagridOrg(DBGuid OrganisationID)
        {
            try
              {
            string sSortColumn = "Name";
            int nSelectedRow = -1;

            // Storing the previous sort order
            if (dtgOrg.DataSource != null)
            {
              sSortColumn = ((DataTable) dtgOrg.DataSource).DefaultView.Sort;
            }

            if (m_allDataOrg == null)
            {
              // Retrieving Organisations

              // Set filter
              Organisation filter = new Organisation(Guid.Empty);
              filter.FilterOnIsactive = DBInt.Null;
              filter.FilterOnIsactive = 1;
              filter.IsActive = true;

              // Retrieving data from BusinessServices
              IOrganisationService srv = ServiceFactory.GetOrganisationService();
              m_allDataOrg = srv.OrganisationSelectFiltered(filter);

              // Retrieving ProgramPartners
              DBGuid ProgramID = new DBGuid(new Guid(m_sCurrentID));
              IProgramService srvP = ServiceFactory.GetProgramService();
              ProgramPartnerContainer allDataP = srvP.SelectChildrenByPartnerProgram(ProgramID);

              // Hide selected Organisation items
              for (int i = 0; i < allDataP.All.Count; i++)
              {
            DBGuid OrganisationRef = ((ProgramPartner) allDataP.All.Items[i]).OrganisationRef;
            Organisation selected = (Organisation) m_allDataOrg[OrganisationRef.ToString()];
            if (selected != null)
            {
              m_allDataOrg.Delete(selected);
            }
              }
            }
            // Fill organisation grid
            DataTable dt = m_allDataOrg.CurrentAsDatatable;
            dt.DefaultView.Sort = sSortColumn;
            dtgOrg.DataSource = dt;

            // Fill organisation "detail" grid
            DataTable dtDetail = m_allDataOrg.DeletedAsDatatable;
            dtDetail.DefaultView.Sort = sSortColumn;
            dtgOrgDetail.DataSource = dtDetail;

            // Locates the row specified by ID param
            if (!OrganisationID.IsNull)
            {
              BindingManagerBase bm = dtgOrg.BindingContext[dtgOrg.DataSource, dtgOrg.DataMember];
              int nPositionStart = bm.Position;
              DataRow dr;
              for (int i = 0; i < bm.Count; i++)
              {
            dr = ((DataRowView) bm.Current).Row;
            if (OrganisationID.Value.Equals(dr["ID"]))
            {
              nSelectedRow = i;
              break;
            }
            bm.Position += 1;
              }
              bm.Position = nPositionStart;
            }

            // Makes the row selected
            if (nSelectedRow <= ((DataTable) dtgOrg.DataSource).DefaultView.Count && nSelectedRow > -1)
            {
              dtgOrg.Select(nSelectedRow);
              dtgOrg.CurrentRowIndex = nSelectedRow;
            }
            else if (((DataTable) dtgOrg.DataSource).DefaultView.Count != 0)
            {
              dtgOrg.Select(0);
            }

            // Enabling or disabling the buttons according to record count.
            // And is because of previous disable state.
            bool bIsEmptyGrid = (((DataTable) dtgOrg.DataSource).DefaultView.Count == 0);
            btnAddOrganisation.Enabled = ! bIsEmptyGrid;
            btnDetailOrganisation.Enabled = ! bIsEmptyGrid;

            bIsEmptyGrid = (((DataTable) dtgOrgDetail.DataSource).DefaultView.Count == 0);
            btnRemoveOrganisation.Enabled = ! bIsEmptyGrid;
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba lépett fel a szervezet lista frissítése során.", ex);
              }
        }
Esempio n. 26
0
 /// <summary>
 /// Organisations the question from validate.
 /// </summary>
 /// <param name="org">The org.</param>
 /// <param name="refreshNum">The refresh num.</param>
 /// <param name="referenceDate"></param>
 /// <returns></returns>
 public string OrganisationQuestionFromValidate(Organisation org, int refreshNum, DateTime referenceDate)
 {
     return OrganisationQuestionFormValidatePriv(org, referenceDate, refreshNum, false);
 }
        /// <summary>
        /// Shows the grid.
        /// </summary>
        /// <param name="dataGrid">The data grid.</param>
        /// <param name="index">The index.</param>
        /// <param name="sort">The sort.</param>
        /// <param name="order">The order.</param>
        protected void ShowGrid(DataGrid dataGrid,
                            int index, string sort, string order)
        {
            dataGrid.PageSize = Helpers.GetPageSize("PageSize.OrganisationList");

              // Get query result from database
              Organisation filter = new Organisation(Guid.NewGuid());
              filter.Name = Helpers.CreateLikeSearchText(txtName.Text);
              filter.RegionRef = cmbRegion.SelectedValue;
              filter.OrganisationFormRef = cmbOrganisationForm.SelectedValue;
              if (cbxPrevention.Checked) filter.ActivityPrevention = true;
              if (cbxResearch.Checked) filter.ActivityResearch = true;
              if (cbxRehabilitation.Checked) filter.ActivityRehabilitation = true;
              if (cbxOther.Checked) filter.ActivityOther = true;
              filter.FilterOnIsactive = 1;

              IOrganisationService orgSrv = ServiceFactory.GetOrganisationService();
              OrganisationDispsetContainer orgSelected = orgSrv.OrganisationSelectDispsetFiltered(filter);

              if (orgSelected.AllCount > 0)
              {
            gridOrganisation.Visible = true;
            lblNotFound.Visible = false;
              }
              else
              {
            gridOrganisation.Visible = false;
            lblNotFound.Visible = true;
              }
              ArrayList sortableList = null;
              // Sort if necessary
              if (sort == null)
              {
            sortableList = orgSelected.All.Items;
              }
              else
              {
            if (String.Compare(order, "Ascending", true) == 0)
            {
              sortableList = orgSelected.All.SortBy(sort, true);
            }
            else if (String.Compare(order, "Descending", true) == 0)
            {
              sortableList = orgSelected.All.SortBy(sort, false);
            }
            else
            {
              sortableList = orgSelected.All.SortBy(sort);
            }
              }

              // Bind list to datagrid control
              dataGrid.CurrentPageIndex = index;
              if (orgSelected.AllCount <= dataGrid.PageSize*dataGrid.CurrentPageIndex)
              {
            dataGrid.CurrentPageIndex = 0;
              }
              else
              {
            dataGrid.CurrentPageIndex = index;
              }

              //dataGrid.CurrentSortExpression = sort;
              //dataGrid.CurrentSortOrder = order;

              if (sort != null)
              {
            dataGrid.CurrentSortExpression = sort;
              }
              if (order != null)
              {
            dataGrid.CurrentSortOrder = order;
              }
              dataGrid.DataSource = sortableList;
              dataGrid.DataBind();
        }
Esempio n. 28
0
        public OrganisationDispsetContainer OrganisationSelectDispsetOwnOrganisation()
        {
            TraceCallEnterEvent.Raise();

              Organisation filter = new Organisation(Guid.Empty);

              try
              {
            DBInt ActivityPrevention = DBInt.Null;
            if (filter.ActivityPrevention) ActivityPrevention = 1;
            DBInt ActivityResearch = DBInt.Null;
            if (filter.ActivityResearch) ActivityResearch = 1;
            DBInt ActivityRehabilitation = DBInt.Null;
            if (filter.ActivityRehabilitation) ActivityRehabilitation = 1;
            DBInt ActivityOther = DBInt.Null;
            if (filter.ActivityOther) ActivityOther = 1;
            DBInt IsKef = 0;

            OrganisationDispsetContainer result;
            DataSet entitySet = m_DataContext.ndihdOrganisationSelectDispsetFiltered(
              filter.Name,
              filter.RegionRef,
              filter.OrganisationFormRef,
              ActivityPrevention,
              ActivityResearch,
              ActivityRehabilitation,
              ActivityOther,
              filter.FilterOnIsactive,
              IsKef,
              filter.RegionSearchCodeRef);
            result = new OrganisationDispsetContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        /// <summary>
        /// Handles the Click event of the btnExportRtf control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnExportRtf_Click(object sender, EventArgs e)
        {
            try
              {
            string rtf = @"";

            #region lekérdezzük a OrganisationContainer -t (a szûrési feltételeknek megfelelõen)

            // Get query result from database
            Organisation filter = new Organisation(Guid.NewGuid());
            filter.Name = txtName.Text;
            filter.RegionRef = cmbRegion.SelectedValue;
            filter.OrganisationFormRef = cmbOrganisationForm.SelectedValue;
            if (cbxPrevention.Checked) filter.ActivityPrevention = true;
            if (cbxResearch.Checked) filter.ActivityResearch = true;
            if (cbxRehabilitation.Checked) filter.ActivityRehabilitation = true;
            if (cbxOther.Checked) filter.ActivityOther = true;
            filter.FilterOnIsactive = 1;

            IOrganisationService orgSrv = ServiceFactory.GetOrganisationService();
            OrganisationContainer selected = orgSrv.OrganisationSelectFiltered(filter);

            #endregion

            if (selected.AllCount > 0)
            {
              DataTable dt = selected.AllAsDatatable;

              dt = Helper.DataTableTypeMakeString(dt);
              dt = Helper.DataTableColumnReplace(dt, "ActivityPrevention", "True", "Igen");
              dt = Helper.DataTableColumnReplace(dt, "ActivityPrevention", "False", "Nem");
              dt = Helper.DataTableColumnReplace(dt, "ActivityResearch", "True", "Igen");
              dt = Helper.DataTableColumnReplace(dt, "ActivityResearch", "False", "Nem");
              dt = Helper.DataTableColumnReplace(dt, "ActivityRehabilitation", "True", "Igen");
              dt = Helper.DataTableColumnReplace(dt, "ActivityRehabilitation", "False", "Nem");
              dt = Helper.DataTableColumnReplace(dt, "ActivityOther", "True", "Igen");
              dt = Helper.DataTableColumnReplace(dt, "ActivityOther", "False", "Nem");

              rtf = Helpers.CreateRtfFromDataSet(dt, "ORGANIZATIONS", Server.MapPath(""));

              // Writes result to response
              Helpers.DownloadFile(rtf, "szervezetek.rtf");
            }
            else lblNotFound.Visible = true;
              }
              catch (Exception ex)
              {
            errorPanel.Exception = ex;
              }
        }
        public bool RegisterOrganisationToUserAccept(RegisterOrganisation entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            // Organisation
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.Name", "A regisztrálandó szervezet neve nincs megadva.");
            if (entity.RegionRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.RegionRef",
                                          "A regisztrálandó szervezet megyéje nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.WorkingAreaRef",
                                          "A regisztrálandó szervezet mûködési területe nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.OrganisationFormRef",
                                          "A regisztrálandó szervezet szervezeti formája nincs megadva.");
            if (entity.ReasonOfRegistration.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.ReasonOfRegistration",
                                          "Az adatbázis használatának célja nincs megadva.");
            if (entity.PostCode.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.PostCode",
                                          "A szervezet címének irányítószáma nincs megadva.");
            if (entity.City.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.City",
                                          "A szervezet címének település része nincs megadva.");
            if (entity.Address.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");

            // User
            if (entity.LoginName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.LoginName",
                                          "A regisztrálandó felhasználó bejelentkezési neve nincs megadva.");
            if (entity.UserName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserName",
                                          "A regisztrálandó felhasználó neve nincs megadva.");
            if (entity.UserSex.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserSex",
                                          "A regisztrálandó felhasználó neme nincs megadva.");
            if (entity.UserBirthYear.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserBirthYear",
                                          "A regisztrálandó felhasználó születési éve nincs megadva.");
            if (entity.UserEmail.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserEmail",
                                          "A regisztrálandó felhasználó e-mail címe nincs megadva.");
            if (entity.QualificationRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.QualificationRef",
                                          "A regisztrálandó felhasználó legmagasabb iskolai végzettsége nincs megadva.");

            // Logical checks
            RegisterOrganisation selected = base.RegisterOrganisationSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik regisztrálandó szervezet.");
            if (! selected.Status.Equals(RegistrationStatus.New))
              throw new ApplicationException("Csak új státuszú regisztráció bírálható el.");

            // Set properties
            entity.SentDate = selected.SentDate;
            entity.DecidedBy = Thread.CurrentPrincipal.Identity.Name;
            entity.DecidedDate = DBDateTime.Now;
            entity.Status = RegistrationStatus.Accepted;

            Organisation newOrg = new Organisation(entity.ID);
            newOrg.Name = entity.Name;
            newOrg.Department = entity.Department;
            newOrg.PostCode = entity.PostCode;
            newOrg.City = entity.City;
            newOrg.Address = entity.Address;
            newOrg.Country = entity.Country;
            newOrg.Phone1 = entity.Phone1;
            newOrg.Fax = entity.Fax;
            newOrg.Email1 = entity.Email1;
            newOrg.HomePage = entity.HomePage;
            newOrg.RegionRef = entity.RegionRef;
            newOrg.WorkingAreaRef = entity.WorkingAreaRef;
            newOrg.WorkingAreaOther = entity.WorkingAreaOther;
            newOrg.OrganisationFormRef = entity.OrganisationFormRef;
            newOrg.ActivityPrevention = entity.ActivityPrevention;
            newOrg.ActivityRehabilitation = entity.ActivityRehabilitation;
            newOrg.ActivityResearch = entity.ActivityResearch;
            newOrg.ActivityOther = entity.ActivityOther;
            newOrg.SourceGovernment = 0;
            newOrg.SourceCompetition = 0;
            newOrg.SourceSponsor = 0;
            newOrg.SourceDonation = 0;
            newOrg.SourceTax = 0;
            newOrg.SourceOther = 0;
            newOrg.IsActive = true;
            // defaults
            newOrg.WorkersFix = 0;
            newOrg.WorkersExternal = 0;
            newOrg.WorkersVolunteer = 0;
            newOrg.JobPsychologist = 0;
            newOrg.JobPsychiater = 0;
            newOrg.JobDoctor = 0;
            newOrg.JobMedicalExpert = 0;
            newOrg.JobHealthExpert = 0;
            newOrg.JobSociologist = 0;
            newOrg.JobSocialPolitician = 0;
            newOrg.JobSocialWorker = 0;
            newOrg.JobSocialPedagogist = 0;
            newOrg.JobPedagogist = 0;
            newOrg.JobManualist = 0;
            newOrg.JobLawyer = 0;
            newOrg.JobPoliceman = 0;
            newOrg.JobMentalhygiene = 0;
            newOrg.JobCultureOrganizer = 0;
            newOrg.JobOther1 = 0;
            newOrg.JobOther2 = 0;
            newOrg.JobOther3 = 0;
            newOrg.IsActual = true;
            newOrg.LastModified = DateTime.Now;
            //set mail:
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.OrganisationRegistrationAccept;
            mail.To = entity.UserEmail;

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.OrganisationRegistrationAccept);

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", entity.Name);
            body = body.Replace("<LOGIN_NAME>", entity.LoginName);
            body = body.Replace("<ORGANIZATION>", newOrg.Name);

            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              //elmentjük a szervezet adatait
              OrganisationService orgSrv = new OrganisationService(m_DataContext);
              orgSrv.OrganisationInsert(newOrg);

              //eltároljuk a szervezet-felhasználó kapcsolatot
              OrganisationUserService orgUserSrv = new OrganisationUserService(m_DataContext);
              OrganisationUser orgUser = new OrganisationUser(newOrg.ID, entity.LoginName);
              orgUser.Right = UserRights.Write;
              orgUserSrv.OrganisationUserInsert(orgUser);

              base.RegisterOrganisationUpdate(entity);
              emailSrv.EmailInsert(mail);
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            // Sending mail:
            try
            {
              emailSrv.EmailSend(mail.ID);
            }
            catch (Exception ex)
            {
              ExceptionManager.Publish(ex);
              return false;
            }

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterOrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationID", newOrg.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterOrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }