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; } }
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)); }
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); } }
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); } }
public void MaterialUpdate(MaterialsDTO material) { var eGroup = Materials.GetAll().SingleOrDefault(c => c.MaterialId == material.MaterialId); Materials.Update((mapper.Map <MaterialsDTO, Materials>(material, eGroup))); }