示例#1
0
        private void LoadMaterialGroupsData()
        {
            materialGroupsService           = Program.kernel.Get <IMaterialGroupsService>();
            materialGroupsBS.DataSource     = materialGroupsService.GetMaterialGroups();
            materialGroupsFindBS.DataSource = materialGroupsService.GetMaterialGroups();
            MaterialGroupsDTO allMaterials = new MaterialGroupsDTO {
                MaterialGroupId = 0, ParentId = null, Name = "Все материалы", Code = "00"
            };
            int index = materialGroupsBS.Add(allMaterials);

            materialGroupsBS.Position = index;
            groupsTree.DataSource     = materialGroupsBS;
        }
示例#2
0
        public MaterialEditFm(Utils.Operation operation, MaterialsDTO material)
        {
            InitializeComponent();
            LoadMaterialsData();
            this.operation        = operation;
            materialBS.DataSource = Item = material;

            articleTBox.DataBindings.Add("EditValue", materialBS, "Article");
            nameTBox.DataBindings.Add("EditValue", materialBS, "Name");
            descriptionTBox.DataBindings.Add("EditValue", materialBS, "Description");
            notesTBox.DataBindings.Add("EditValue", materialBS, "Notes");

            storageGroupsEdit.DataBindings.Add("EditValue", materialBS, "StorageGroupId", true, DataSourceUpdateMode.OnPropertyChanged);
            storageGroupsEdit.Properties.DataSource    = storageGroupsService.GetStorageGroups();
            storageGroupsEdit.Properties.ValueMember   = "StorageGroupId";
            storageGroupsEdit.Properties.DisplayMember = "StorageGroupName";

            materialGroupsEdit.DataBindings.Add("EditValue", materialBS, "MaterialGroupId", true, DataSourceUpdateMode.OnPropertyChanged);
            materialGroupsEdit.Properties.DataSource    = materialGroupsService.GetMaterialGroups();
            materialGroupsEdit.Properties.ValueMember   = "MaterialGroupId";
            materialGroupsEdit.Properties.DisplayMember = "Name";
            materialGroupsTreeList.KeyFieldName         = "MaterialGroupId";
            materialGroupsTreeList.ParentFieldName      = "ParentId";
            materialGroupsEdit.Properties.NullText      = "[нет данных]";

            if (operation == Utils.Operation.Add)
            {
                storageGroupsEdit.EditValue  = 0;
                materialGroupsEdit.EditValue = ((MaterialsDTO)Item).MaterialGroupId == null ? 0 : ((MaterialsDTO)Item).MaterialGroupId;
            }
        }