// -------------------------------------------------------------------------------------
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void FillDatagrid(DBGuid ID)
        {
            try
              {
            string sortColumn = "SentDate";
            int selectedRow = -1;

            // storing the previous sort order
            if (dtgMain.DataSource != null)
            {
              sortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort;
            }

            // retrieving data from BusinessServices
            PendingQuestionForm filter = new PendingQuestionForm(Guid.NewGuid());
            filter.ProgramCategoryId = cmbCategory.SelectedValue.ToString();
            filter.Status = cmbStatusFilter.SelectedValue.ToString();
            if (cmbProgram.SelectedValue.ToString().Length > 0)
            {
              Guid prgId = new Guid(cmbProgram.SelectedValue.ToString());
              filter.ProgramID = prgId;
            }
            if (cmbOrganisation.SelectedValue.ToString().Length > 0)
            {
              Guid orgId = new Guid(cmbOrganisation.SelectedValue.ToString());
              filter.OrganisationID = orgId;
            }

            IPendingQuestionFormService pendingSrv = ServiceFactory.GetPendingQuestionFormService();
            m_PendingQuestionFormContainer = pendingSrv.PendingQuestionFormSelectFiltered(filter);
            DataTable dt = m_PendingQuestionFormContainer.AllAsDatatable;
            dt.DefaultView.Sort = sortColumn;
            dtgMain.DataSource = dt;

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

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

            // enabling or disabling the buttons according to record count. And is because of previous disable state.
            tbbDecide.Enabled = (((DataTable) dtgMain.DataSource).DefaultView.Count != 0);
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba a lista frissítése során.", ex);
              }
        }
Exemplo n.º 2
0
 public virtual PendingQuestionFormContainer SelectChildrenByPendingQuestionFormOfTemplate(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     PendingQuestionFormContainer result;
     DataSet entitySet = m_DataContext.ndihdPendingQuestionFormOfTemplateSelectBy(IDVal);
     result = new PendingQuestionFormContainer(entitySet.Tables[0]);
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Exemplo n.º 3
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;
        }
 public virtual PendingQuestionFormContainer PendingQuestionFormSelectAll()
 {
     TraceCallEnterEvent.Raise();
       try
       {
     PendingQuestionFormContainer result;
     DataSet entitySet = m_DataContext.ndihdPendingQuestionFormSelectAll();
     result = new PendingQuestionFormContainer(entitySet.Tables[0]);
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        public PendingQuestionFormContainer PendingQuestionFormSelectFiltered(PendingQuestionForm filter)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            if (filter.ProgramCategoryId.Length == 0)
              throw new ArgumentNullException("filter.ProgramCategoryId", "A program kategória nincs megadva.");

            PendingQuestionFormContainer result;
            if (filter.ProgramCategoryId.Equals("ORG"))
            {
              DataSet entitySet = m_DataContext.ndihdPendingQuestionFormOfOrganisationSelectFiltered(
            filter.OrganisationID,
            filter.Status,
            "ORG");
              result = new PendingQuestionFormContainer(entitySet.Tables[0]);
            }
            else
            {
              DataSet entitySet = m_DataContext.ndihdPendingQuestionFormOfProgramSelectFiltered(
            filter.ProgramID,
            filter.OrganisationID,
            filter.Status,
            filter.ProgramCategoryId);
              result = new PendingQuestionFormContainer(entitySet.Tables[0]);
            }
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }