Exemplo n.º 1
0
        //验证控件值
        public static bool Validate(XtraTabPage tabPage)
        {
            if (tabPage == null)
            {
                return(false);
            }

            List <Control> childrens = TmoComm.GetChildrenControl(tabPage, true);

            foreach (Control children in childrens)
            {
                if (children is UCQuestion)
                {
                    UCQuestion ucq = (UCQuestion)children;

                    if (ucq.Enabled && !ucq.ValidateValue())
                    {
                        //ucq._valueControls.ForEach(x => x.Focus());
                        ucq.Focus();
                        tabPage.Select();
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取结果从控件
        /// </summary>
        /// <param name="ctrl"></param>
        /// <returns></returns>
        private List <tmo_questionnaire_result> GetResultFormControl(Control ctrl)
        {
            List <tmo_questionnaire_result> list = new List <tmo_questionnaire_result>();

            if (ctrl == null)
            {
                return(list);
            }
            if (ctrl is UCQuestion)
            {
                UCQuestion ucQuestion = (UCQuestion)ctrl;
                ucQuestion.SaveValue();
                list.Add(ucQuestion.Question.QuestionnaireResult);
            }
            if (ctrl.HasChildren)
            {
                foreach (Control crl in ctrl.Controls)
                {
                    list.AddRange(GetResultFormControl(crl));
                }
            }
            return(list);
        }
Exemplo n.º 3
0
        public void Init(List <tmo_questionnaire_category> qclist)
        {
            if (qclist != null && qclist.Count > 0)
            {
                var tabs = qclist.Where(x => x.qc_level == 1).ToList();
                tabs.Sort();
                for (int i = 0; i < tabs.Count; i++)
                {
                    tmo_questionnaire_category qc = tabs[i];
                    qc.Index = i + 1;
                    XtraTabPage page = new XtraTabPage();
                    page.Name = qc.qc_id;
                    page.Text = qc.qc_name;
                    FlowLayoutPanel flp = new FlowLayoutPanel();
                    flp.AutoScroll    = true;
                    flp.Dock          = DockStyle.Fill;
                    flp.FlowDirection = FlowDirection.TopDown;
                    flp.WrapContents  = false;
                    page.Controls.Add(flp);
                    var groupboxs = qclist.Where(x => x.qc_pid == qc.qc_id).ToList();
                    groupboxs.Sort();
                    foreach (tmo_questionnaire_category qcgroup in groupboxs)
                    {
                        GroupBox gb = new GroupBox();
                        gb.AutoSize = false;
                        gb.Name     = qcgroup.qc_id;
                        gb.Text     = qcgroup.qc_name;
                        gb.Margin   = new Padding(10, 5, 0, 5);
                        gb.Padding  = new Padding(0, 0, 0, 5);
                        FlowLayoutPanel flpgroup = new FlowLayoutPanel();
                        //flpgroup.Margin = new Padding(0);
                        flpgroup.Padding       = new Padding(3);
                        flpgroup.Dock          = DockStyle.Fill;
                        flpgroup.FlowDirection = FlowDirection.TopDown;
                        flpgroup.WrapContents  = false;
                        gb.Controls.Add(flpgroup);
                        if (qcgroup.Questions != null && qcgroup.Questions.Any())
                        {
                            int h = 20;
                            qcgroup.Questions.Sort();
                            qcgroup.Questions.ForEach(x =>
                            {
                                if (_status == null)
                                {
                                    _status = x.QuestionnaireResult.Userstatus;
                                }
                                UCQuestion ucQuestion = new UCQuestion(x);
                                //ucQuestion.Margin = new Padding(3);
                                h += ucQuestion.Height + 6;
                                flpgroup.Controls.Add(ucQuestion);
                                QuestionList.Add(ucQuestion);
                            });

                            gb.ClientSize = new Size(857, h);
                        }
                        flp.Controls.Add(gb);
                    }
                    TabPages.Add(page, qc);
                }

                InitValidate();     //初始化验证
            }
        }