コード例 #1
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;
            }
        }
コード例 #2
0
        public IHttpActionResult GetMaterials(int id)
        {
            Materials m = db.Materials.Find(id);

            if (m == null)
            {
                return(NotFound());
            }

            MaterialsDTO materials = new MaterialsDTO
            {
                Id         = m.Id,
                Type       = m.Type,
                Price      = m.Price,
                AmountLeft = m.AmountLeft
            };

            return(Ok(materials));
        }
コード例 #3
0
 public short MaterialCreate(MaterialsDTO material)
 {
     if (NotDublicate(material.Article))
     {
         try
         {
             var createrecord = Materials.Create(mapper.Map <Materials>(material));
             return((short)createrecord.MaterialId);
         }
         catch (Exception ex)
         {
             return(0);
         }
     }
     else
     {
         return(-1);
     }
 }
コード例 #4
0
 public Error.ErrorCRUD MaterialDelete(MaterialsDTO material)
 {
     try
     {
         Error.ErrorCRUD result = CanDelete(material.MaterialId);
         if (result == Error.ErrorCRUD.CanDelete)
         {
             Materials.Delete(Materials.GetAll().FirstOrDefault(c => c.MaterialId == material.MaterialId));
             return(Error.ErrorCRUD.NoError);
         }
         else
         {
             return(Error.ErrorCRUD.RelationError);
         }
     }
     catch (Exception ex)
     {
         return(Error.ErrorCRUD.DatabaseError);
     }
 }
コード例 #5
0
        public void MaterialUpdate(MaterialsDTO material)
        {
            var eGroup = Materials.GetAll().SingleOrDefault(c => c.MaterialId == material.MaterialId);

            Materials.Update((mapper.Map <MaterialsDTO, Materials>(material, eGroup)));
        }