コード例 #1
0
ファイル: QueryModel.cs プロジェクト: davidbwire/bvcms
        public void EditCondition()
        {
            var c = Db.LoadQueryById(SelectedId);

            if (c == null)
            {
                return;
            }
            ConditionName = c.FieldInfo.Name;
            SetVisibility();
            Comparison = c.Comparison;
            switch (c.FieldInfo.Type)
            {
            case FieldType.String:
            case FieldType.StringEqual:
            case FieldType.StringEqualOrStartsWith:
                TextValue = c.TextValue;
                break;

            case FieldType.Integer:
            case FieldType.IntegerSimple:
            case FieldType.IntegerEqual:
            case FieldType.NullInteger:
                IntegerValue = c.TextValue;
                break;

            case FieldType.Number:
            case FieldType.NullNumber:
                NumberValue = c.TextValue;
                break;

            case FieldType.Date:
            case FieldType.DateSimple:
                DateValue = DateString(c.DateValue);
                break;

            case FieldType.Code:
            case FieldType.NullCode:
            case FieldType.CodeStr:
            case FieldType.DateField:
            case FieldType.Bit:
            case FieldType.NullBit:
                CodeValue = c.CodeIdValue;
                if (c.HasMultipleCodes && CodeValue.HasValue())
                {
                    CodeValues = c.CodeIdValue.Split(';');
                    foreach (var i in CodeData)
                    {
                        i.Selected = CodeValues.Contains(i.Value);
                    }
                }
                break;
            }
            Program           = c.Program;
            DivisionData      = Divisions(Program).ToList();
            Division          = c.Division;
            OrganizationData  = Organizations(Division).ToList();
            Organization      = c.Organization;
            Schedule          = c.Schedule;
            Campus            = c.Campus;
            OrgType           = c.OrgType;
            StartDate         = DateString(c.StartDate);
            EndDate           = DateString(c.EndDate);
            SelectMultiple    = c.HasMultipleCodes;
            AddToGroupEnabled = c.IsGroup;
            AddEnabled        = !c.IsFirst;
            RemoveEnabled     = !c.IsFirst;
            Days     = c.Days.ToString();
            Age      = c.Age.ToString();
            Quarters = c.Quarters;
            if (TagsVisible)
            {
                if (c.Tags != null)
                {
                    Tags = c.Tags.Split(';');
                }
                var cv = new CodeValueModel();
                TagData = CodeValueModel.ConvertToSelect(cv.UserTags(Util.UserPeopleId), "Code");
                foreach (var i in TagData)
                {
                    i.Selected = Tags.Contains(i.Value);
                }
            }
            if (PmmLabelsVisible)
            {
                if (c.Tags != null)
                {
                    PmmLabels = c.Tags.Split(',').Select(vv => vv).ToArray();
                }
                var cv = new CodeValueModel();
                PmmLabelData = CodeValueModel.ConvertToSelect(cv.PmmLabels(), "Id");
                if (PmmLabels != null)
                {
                    foreach (var i in PmmLabelData)
                    {
                        i.Selected = PmmLabels.Contains(i.Value);
                    }
                }
            }
            if (MinistryVisible)
            {
                Ministry = c.Program;
            }
            SavedQueryDesc = c.SavedQueryIdDesc;
        }