예제 #1
0
 public virtual QuestionFormContainer SelectChildrenByQuestionFormOfTemplate(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     QuestionFormContainer result;
     DataSet entitySet = m_DataContext.ndihdQuestionFormOfTemplateSelectBy(IDVal);
     result = new QuestionFormContainer(entitySet.Tables[0]);
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public virtual QuestionFormContainer QuestionFormSelectAll()
 {
     TraceCallEnterEvent.Raise();
       try
       {
     QuestionFormContainer result;
     DataSet entitySet = m_DataContext.ndihdQuestionFormSelectAll();
     result = new QuestionFormContainer(entitySet.Tables[0]);
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
예제 #3
0
        public QuestionFormContainer QuestionFormSelectFiltered(QuestionForm filter)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            if (filter.ProgramCategoryId.IsNull)
              throw new ArgumentNullException("filter.ProgramCategoryId", "A program kategória nincs megadva.");

            QuestionFormContainer result;
            if (filter.ProgramCategoryId.Equals("ORG"))
            {
              DataSet entitySet = m_DataContext.ndihdQuestionFormOfOrganisationSelectFiltered(
            filter.OrganisationID,
            "ORG",
            filter.TemplateRef);
              result = new QuestionFormContainer(entitySet.Tables[0]);
            }
            else
            {
              DataSet entitySet = m_DataContext.ndihdQuestionFormOfProgramSelectFiltered(
            filter.ProgramID,
            filter.OrganisationID,
            filter.ProgramCategoryId,
            filter.TemplateRef);
              result = new QuestionFormContainer(entitySet.Tables[0]);
            }
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void FillDatagrid(DBGuid ID)
        {
            try
              {
            string sortColumn = "OrganisationName";
            int selectedRow = -1;

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

            // retrieving data from BusinessServices
            QuestionForm filter = new QuestionForm(Guid.NewGuid());
            if (cmbCategory.SelectedIndex > 0)
            {
              filter.ProgramCategoryId = cmbCategory.SelectedValue.ToString();
            }
            else
            {
              filter.ProgramCategoryId = "";
            }
            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;
            }
            if (cmbTemplate.SelectedValue.ToString().Length > 0)
            {
              Guid templId = new Guid(cmbTemplate.SelectedValue.ToString());
              filter.TemplateRef = templId;
            }

            IQuestionFormService qfSrv = ServiceFactory.GetQuestionFormService();
            m_QuestionFormContainer = qfSrv.QuestionFormSelectFiltered(filter);
            DataTable dt = m_QuestionFormContainer.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.
            tbbModify.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);
              }
        }