示例#1
0
        private void m_addCriteriaButton_Click(object sender, EventArgs e)
        {
            //get a local reference of the currently selected PropertyDefinition object
            PropDefItem propertyItem = m_propertyComboBox.SelectedItem as PropDefItem;
            PropDef     property;

            property = (propertyItem == null) ? null : propertyItem.PropDef;

            //get local reference of the condition combo boxes currently selected item
            Condition condition = m_conditionComboBox.SelectedItem as Condition;

            if (property == null || condition == null)
            {
                return;
            }

            SearchRuleType rule     = SearchRuleType.Must;
            RuleItem       ruleItem = m_ruleComboBox.SelectedItem as RuleItem;

            if (ruleItem != null)
            {
                rule = ruleItem.Rule;
            }


            //create a SearchCondition object
            SrchCond searchCondition = new SrchCond();

            searchCondition.PropDefId = property.Id;
            searchCondition.PropTyp   = PropertySearchType.SingleProperty;
            searchCondition.SrchOper  = condition.Code;
            if (checkBox1.Checked)
            {
                //here we would effectively need to perform a search for everything and then search those results.
                searchCondition.SrchTxt = m_valueComboBox.SelectedItem.ToString();
            }
            else
            {
                searchCondition.SrchTxt = m_valueTextBox.Text;
            }

            searchCondition.SrchRule = rule;


            //create the list item to contain the condition
            SrchCondItem searchItem = new SrchCondItem(searchCondition, property);

            //add the SearchCondition object to the search criteria list box
            m_criteriaListBox.Items.Add(searchItem);
        }
示例#2
0
        private void RunSave()
        {
            SaveFileDialog saveFile = new SaveFileDialog();

            saveFile.DefaultExt       = ".xml";
            saveFile.Filter           = "XML files|*.xml";
            saveFile.InitialDirectory = SavedSearch.GetDefaultFolder();

            if (!System.IO.Directory.Exists(saveFile.InitialDirectory))
            {
                System.IO.Directory.CreateDirectory(saveFile.InitialDirectory);
            }

            DialogResult result = saveFile.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                SavedSearch search      = new SavedSearch();
                EntityClass entityClass = m_entityClassComboBox.SelectedItem as EntityClass;

                if (entityClass == null)
                {
                    MessageBox.Show("You must select an entity type.");
                    return;
                }

                search.EntityType = entityClass.EntityClassId;
                List <SrchCondItem> conditions = new List <SrchCondItem>();
                foreach (Object o in m_criteriaListBox.Items)
                {
                    SrchCondItem item = o as SrchCondItem;
                    if (item != null)
                    {
                        conditions.Add(item);
                    }
                }

                if (!conditions.Any())
                {
                    MessageBox.Show("You must have at least one search condition.");
                    return;
                }

                search.Conditions = conditions;

                search.Save(saveFile.FileName);
            }
        }