Exemple #1
0
 public static void RemoveSection(FormSection fs)
 {
     SFGlobal.ObjectManager.MarkForDeletion(fs);
     SFGlobal.ObjectManager.PersistChanges(fs);
     SFGlobal.ObjectManager.Resync(fs.FormObject);
     SFGlobal.AlertUser("Section: " + fs.Title + " Deleted");
 }
Exemple #2
0
        public static void ChangeSectionRank(FormSection fs, int dir)
        {
            int i = getSectionIndexInParentCollection(fs);

            if (i >= 0 && i < fs.FormObject.FormSections.Count)
            {
                int oldRank = fs.Rank;
                if (dir == -1 && i == 0)
                {
                    return;
                }
                if (dir == 1 && i == fs.FormObject.FormSections.Count - 1)
                {
                    return;
                }
                fs.Rank = ((FormSection)fs.FormObject.FormSections[i + dir]).Rank;
                ((FormSection)fs.FormObject.FormSections[i + dir]).Rank = oldRank;
                SFGlobal.ObjectManager.PersistChanges(fs);
                SFGlobal.ObjectManager.PersistChanges(fs.FormObject.FormSections[i + dir]);
                SFGlobal.ObjectManager.Resync(fs.FormObject);
                SFGlobal.ObjectManager.Resync(fs);
                SFGlobal.ObjectManager.Resync(fs.FormObject.FormSections[i + dir]);
            }
            SFGlobal.AlertUser("Changed Section: " + fs.Title + " rank");
        }
Exemple #3
0
        public static FormSection AddSection(Form f, string title, string description)
        {
            FormSection fs = (FormSection)SFGlobal.ObjectManager.GetObject(typeof(FormSection));

            fs.FormID      = f.FormID;
            fs.Title       = title;
            fs.Description = description;
            fs.Rank        = getSectionNextRank(f);
            SFGlobal.ObjectManager.PersistChanges(fs);
            SFGlobal.ObjectManager.Resync(fs);
            SFGlobal.AlertUser("Section: " + fs.Title + " Added");
            return(fs);
        }
Exemple #4
0
        private static int getSectionIndexInParentCollection(FormSection fs)
        {
            int i = 0;

            foreach (FormSection formSection in fs.FormObject.FormSections)
            {
                if (fs.FormSectionID == formSection.FormSectionID)
                {
                    return(i);
                }
                i++;
            }
            throw new Exception("can't find formsection in parent collection");
        }
Exemple #5
0
        public static Field AddFieldToSection(FormSection fs, int fieldType, string title, string groupName, string description, bool isRequired, bool isValidated, string validationExpression)
        {
            Field f = (Field)SFGlobal.ObjectManager.GetObject(typeof(Field));

            f.SectionID            = fs.FormSectionID;
            f.FieldTypeID          = fieldType;
            f.Title                = title;
            f.Description          = description;
            f.GroupName            = groupName;
            f.IsRequired           = isRequired;
            f.IsValidated          = isValidated;
            f.ValidationExpression = validationExpression;
            f.Rank = getFieldNextRank(fs);
            SFGlobal.ObjectManager.PersistChanges(f);
            SFGlobal.ObjectManager.Resync(fs);
            SFGlobal.AlertUser("Field added");
            return(f);
        }
Exemple #6
0
 private static int getFieldNextRank(FormSection fs)
 {
     return(fs.FieldSectionIDs.Count + 1);
 }
Exemple #7
0
 public static Field AddFieldToSection(FormSection fs, int fieldType, string title)
 {
     return(AddFieldToSection(fs, fieldType, title, "", "", false, false, ""));
 }
Exemple #8
0
 public static void SaveFormSection(FormSection fs)
 {
     SFGlobal.ObjectManager.PersistChanges(fs);
     SFGlobal.ObjectManager.Resync(fs);
     SFGlobal.AlertUser("Section: " + fs.Title + " Saved");
 }