示例#1
0
        private void Edit()
        {
            CustomizableFieldSearchResult entity = olvFieldGroups.SelectedObject as CustomizableFieldSearchResult;

            Debug.Assert(entity != null, "Group of fields is not selected!");
            int entityId = (int)Enum.Parse(typeof(OCustomizableFieldEntities), GetString(entity.EntityName));

            AddCustomizableFields frm = new AddCustomizableFields(entityId);

            frm.ShowDialog();
            LoadFields();

            //if (DialogResult.OK != frm.ShowDialog()) return;

            //ServicesProvider.GetInstance().GetTellerServices().Update(teller);

            olvFieldGroups.RefreshSelectedObjects();
        }
示例#2
0
        private void LoadFields()
        {
            List <CustomizableFieldSearchResult> results = new List <CustomizableFieldSearchResult>();

            List <CustomizableFieldSearchResult> entities = ServicesProvider.GetInstance().GetCustomizableFieldsServices().SelectCreatedEntites();

            foreach (var entity in entities)
            {
                CustomizableFieldSearchResult result = new CustomizableFieldSearchResult();
                result.EntityName   = GetString("entity" + entity.EntityName);
                result.Fields       = entity.Fields;
                result.FieldsNumber = entity.FieldsNumber;
                results.Add(result);
            }

            olvFieldGroups.Items.Clear();
            olvFieldGroups.SetObjects(results);
            CheckSelected();
        }
        public List <CustomizableFieldSearchResult> SelectCreatedEntites()
        {
            string sqlText = @"SELECT 
                                 AdvancedFieldsEntities.id, 
                                 AdvancedFieldsEntities.name, 
                                 COUNT(AdvancedFieldsEntities.id) AS fields_number 
                               FROM AdvancedFieldsEntities
                               INNER JOIN dbo.AdvancedFields ON dbo.AdvancedFieldsEntities.id = dbo.AdvancedFields.entity_id
                               GROUP BY 
                                 AdvancedFieldsEntities.id, 
                                 AdvancedFieldsEntities.name
                               ORDER BY dbo.AdvancedFieldsEntities.id";

            List <CustomizableFieldSearchResult> entities = new List <CustomizableFieldSearchResult>();

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand cmd = new OpenCbsCommand(sqlText, conn))
                {
                    using (OpenCbsReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Empty)
                        {
                            return(new List <CustomizableFieldSearchResult>());
                        }
                        while (reader.Read())
                        {
                            CustomizableFieldSearchResult result = new CustomizableFieldSearchResult();
                            result.EntityName   = reader.GetString("name");
                            result.FieldsNumber = reader.GetInt("fields_number");
                            result.Fields       = SelectFieldNamesForEntity(reader.GetInt("id"));
                            entities.Add(result);
                        }
                    }
                }

            return(entities);
        }