public virtual void ProgramParticipantDelete(ProgramParticipant entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdProgramParticipantDelete(entity.ExpertRef,
                                               entity.ProgramRef);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        public new void ProgramParticipantDelete(ProgramParticipant entity)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            // logical checks:
            ProgramService progSrv = new ProgramService();
            Program selected = progSrv.ProgramSelect(entity.ProgramRef);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik program.");
            if (!selected.IsActive)
              throw new ApplicationException("A program nem aktív.");

            // check permission: Writer or Admin
            string writerRole = selected.OrganisationRef.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();

            // save data:
            base.ProgramParticipantDelete(entity);

            BusinessAuditEvent.Success(
              new EventParameter("ProgramID", entity.ProgramRef.ToString()),
              new EventParameter("ExpertID", entity.ExpertRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramID", entity.ProgramRef.ToString()),
              new EventParameter("ExpertID", entity.ExpertRef.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public ProgramParticipant(ProgramParticipant origInstance)
     : base(origInstance)
 {
 }
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            try
              {
            if (!Page.IsValid)
            {
              return;
            }

            string displayMode = Request["mode"];
            string progId = Request["progId"];

            Guid expertGuid = Guid.NewGuid();
            Guid programGuid = new Guid(progId);

            Expert expert = new Expert(expertGuid);
            expert.Name = txtName.Text;
            expert.NamePrefix = txtNamePrefix.Text;
            expert.Phone1 = txtPhone1.Text;
            if (txtPhone2.Text.Trim().Length > 0) expert.Phone2 = txtPhone2.Text;
            if (txtPhone3.Text.Trim().Length > 0) expert.Phone3 = txtPhone3.Text;
            if (txtFax.Text.Trim().Length > 0) expert.Fax = txtFax.Text;
            expert.Email1 = txtEmail1.Text;
            if (txtEmail2.Text.Trim().Length > 0) expert.Email2 = txtEmail2.Text;
            if (txtEmail3.Text.Trim().Length > 0) expert.Email3 = txtEmail3.Text;
            if (txtAddressInstitute.Text.Trim().Length > 0) expert.AddressInstitute = txtAddressInstitute.Text;
            expert.PostCode = txtMailingPostCode.Text;
            expert.City = txtMailingCity.Text;
            expert.Address = txtMailingAddress.Text;
            if (txtJob.Text.Trim().Length > 0) expert.Job = txtJob.Text;
            expert.QualificationRef = cmbQualification.SelectedValue;
            if (txtProfession.Text.Trim().Length > 0) expert.Profession = txtProfession.Text;
            if (txtGraduate.Text.Trim().Length > 0) expert.Graduation = txtGraduate.Text;
            if (txtActivity.Text.Trim().Length > 0) expert.Activity = txtActivity.Text;
            if (txtPublication.Text.Trim().Length > 0) expert.Publications = txtPublication.Text;
            if (txtBiography.Text.Trim().Length > 0) expert.Biography = txtBiography.Text;

            IExpertService expSrv = ServiceFactory.GetExpertService();
            //akar feltölteni önéletrajzot

            #region önéletrajz feltöltés

            //kiválasztott egy file-t
            if (fileUpload.PostedFile != null && fileUpload.PostedFile.ContentLength != 0)
            {
              Guid attachmentID = Guid.NewGuid();
              ExpertAttachment attachment = new ExpertAttachment(attachmentID);
              attachment.Name = txtFileName.Text.Length == 0 ? attachmentID.ToString() : txtFileName.Text;
              attachment.Description = txtFileDesc.Text.Length == 0 ? "" : txtFileDesc.Text;

              string fileName = Path.GetFileName(fileUpload.PostedFile.FileName);
              attachment.Path = fileName;

              BinaryReader reader = new BinaryReader(fileUpload.PostedFile.InputStream);
              byte[] buffer = new byte[fileUpload.PostedFile.ContentLength];
              reader.Read(buffer, 0, fileUpload.PostedFile.ContentLength);
              attachment.FileData = buffer;

              expert.ExpertAttachments.Add(attachment);
            }

            #endregion

            expSrv.ExpertInsert(expert);

            IProgramService programSrv = ServiceFactory.GetProgramService();
            switch (displayMode)
            {
              case "participantSelect":
            ProgramParticipant participant = new ProgramParticipant(expertGuid, programGuid);
            IProgramParticipantService participantSrv = ServiceFactory.GetProgramParticipantService();
            participantSrv.ProgramParticipantInsert(participant);
            break;
              case "responsibleSelect":
            Program responsible = new Program(programGuid);
            responsible.ResponsibleRef = expertGuid;
            programSrv.ProgramResponsibleUpdate(responsible);
            break;
              case "coordinator1Select":
            Program coordinator1 = new Program(programGuid);
            coordinator1.Coordinator1Ref = expertGuid;
            programSrv.ProgramCoordinator1Update(coordinator1);
            break;
              case "coordinator2Select":
            Program coordinator2 = new Program(programGuid);
            coordinator2.Coordinator2Ref = expertGuid;
            programSrv.ProgramCoordinator2Update(coordinator2);
            break;
            }
            Response.Redirect("ProgramData.aspx?progId=" + progId);
              }
              catch (Exception ex)
              {
            errorPanel.Exception = ex;
              }
        }
 private void gridParticipant_ItemCommand(object source, DataGridCommandEventArgs e)
 {
     try
       {
     if (e.CommandName.ToLower().Equals("delete"))
     {
       string expId = e.CommandArgument.ToString();
       string progId = Request["progid"];
       Guid expGuid = new Guid(expId);
       Guid progGuid = new Guid(progId);
       ProgramParticipant participant = new ProgramParticipant(expGuid, progGuid);
       IProgramParticipantService srv = ServiceFactory.GetProgramParticipantService();
       srv.ProgramParticipantDelete(participant);
       ShowParticipantGrid(gridParticipant, 0, null, null, progGuid);
     }
       }
       catch (Exception ex)
       {
     errorPanel.Exception = ex;
       }
 }
        private void gridExpert_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            try
              {
            if (e.CommandName.ToLower().Equals("linktoexpert"))
            {
              string expId = e.CommandArgument.ToString();
              Response.Redirect("ExpertData.aspx?expid=" + expId);
            }
            if (e.CommandName.ToLower().Equals("expertselect"))
            {
              string expId = e.CommandArgument.ToString();
              string progId = Request["progId"];
              string displayMode = Request["mode"];
              if (displayMode == null) displayMode = "normal";
              Guid expertGuid = new Guid(expId);
              Guid programGuid = new Guid(progId);
              IProgramService programSrv = ServiceFactory.GetProgramService();

              switch (displayMode)
              {
            case "participantSelect":
              ProgramParticipant participant = new ProgramParticipant(expertGuid, programGuid);
              IProgramParticipantService participantSrv = ServiceFactory.GetProgramParticipantService();
              participantSrv.ProgramParticipantInsert(participant);
              break;
            case "responsibleSelect":
              Program responsible = new Program(programGuid);
              responsible.ResponsibleRef = expertGuid;
              programSrv.ProgramResponsibleUpdate(responsible);
              break;
            case "coordinator1Select":
              Program coordinator1 = new Program(programGuid);
              coordinator1.Coordinator1Ref = expertGuid;
              programSrv.ProgramCoordinator1Update(coordinator1);
              break;
            case "coordinator2Select":
              Program coordinator2 = new Program(programGuid);
              coordinator2.Coordinator2Ref = expertGuid;
              programSrv.ProgramCoordinator2Update(coordinator2);
              break;
              }
              Response.Redirect("ProgramData.aspx?progId=" + progId);
            }
              }
              catch (Exception ex)
              {
            errorPanel.Exception = ex;
              }
        }
 public virtual ProgramParticipant ProgramParticipantSelect(DBGuid ExpertRefVal,
                                                        DBGuid ProgramRefVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     ProgramParticipant result = null;
     DataSet entitySet = m_DataContext.ndihdProgramParticipantSelect(ExpertRefVal,
                                                                 ProgramRefVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new ProgramParticipant(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }