public IActionResult Check() { var materials = materialsService.GetMaterials(); var model = new SupplyCheckViewModel() { Materials = materials.OrderBy(m => m.Element.ToString()) }; return(View(model)); }
private void editMaterial_() { if (materialsBS.Count != 0) { if (materialsBS.Count != 0) { using (MaterialEditFm materialEditFm = new MaterialEditFm(Utils.Operation.Update, (MaterialsDTO)materialsBS.Current)) { if (materialEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int return_MaterialId = materialEditFm.Return(); materialsGridView.BeginDataUpdate(); materialsService = Program.kernel.Get <IMaterialsService>(); materialsBS.DataSource = materialsService.GetMaterials(); materialsGrid.DataSource = materialsBS; materialsGridView.EndDataUpdate(); int rowHandle = materialsGridView.LocateByValue("MaterialId", return_MaterialId); materialsGridView.FocusedRowHandle = rowHandle; } } } } }
public IActionResult Conduct() { var materials = materialsService.GetMaterials(); var model = new ResearchViewModel() { AdditionalMaterials = materials.Where( m => m.Element.HasAttribute <UsageAttribute>() && m.Element.GetAttribute <UsageAttribute>().IsUsedAsAdditive) .Select(m => new SelectListItem() { Disabled = m.QuantityInKg > 0 ? false : true, Text = $"{m.Element.GetDisplayName()} ({m.Form.ToString()})" + (m.QuantityInKg > 0 ? string.Empty : " [DEPLETED]"), Value = $"{m.Element.ToString()}_{(int)m.Form}" }).OrderBy(i => i.Text), BaseMaterials = materials.Where( m => m.Element.HasAttribute <UsageAttribute>() && m.Element.GetAttribute <UsageAttribute>().IsUsedAsBase) .Select(m => new SelectListItem() { Disabled = m.QuantityInKg > 0 ? false : true, Text = $"{m.Element.GetDisplayName()} ({m.Form.ToString()})" + (m.QuantityInKg > 0 ? string.Empty : " [DEPLETED]"), Value = $"{m.Element.ToString()}_{(int)m.Form}" }).OrderBy(i => i.Text) }; return(View(model)); }
public ReceiptsEditFm(Utils.Operation operation, ReceiptsDTO receipt) { InitializeComponent(); LoadOrdersData(); this.operation = operation; receiptsBS.DataSource = Item = receipt; quantityTBox.DataBindings.Add("EditValue", receiptsBS, "Quantity", true, DataSourceUpdateMode.OnPropertyChanged); unitPriceTBox.DataBindings.Add("EditValue", receiptsBS, "UnitPrice", true, DataSourceUpdateMode.OnPropertyChanged); totalPriceTBox.DataBindings.Add("EditValue", receiptsBS, "TotalPrice", true, DataSourceUpdateMode.OnPropertyChanged); dateProductionEdit.DataBindings.Add("EditValue", receiptsBS, "DateProduction", true, DataSourceUpdateMode.OnPropertyChanged); dateExpirationEdit.DataBindings.Add("EditValue", receiptsBS, "DateExpiration", true, DataSourceUpdateMode.OnPropertyChanged); materialsGridEdit.DataBindings.Add("EditValue", receiptsBS, "MaterialId", true, DataSourceUpdateMode.OnPropertyChanged); materialsGridEdit.Properties.DataSource = materialsService.GetMaterials(); materialsGridEdit.Properties.ValueMember = "MaterialId"; materialsGridEdit.Properties.DisplayMember = "Name"; unitEdit.DataBindings.Add("EditValue", receiptsBS, "UnitId", true, DataSourceUpdateMode.OnPropertyChanged); unitEdit.Properties.DataSource = unitsService.GetUnits(); unitEdit.Properties.ValueMember = "UnitId"; unitEdit.Properties.DisplayMember = "UnitLocalName"; if (this.operation == Utils.Operation.Add) { materialsGridEdit.EditValue = 0; unitEdit.EditValue = 0; materialsGridEdit.Text = "[нет данных]"; ((ReceiptsDTO)Item).DateProduction = null; ((ReceiptsDTO)Item).DateExpiration = null; } }
private void groupsTree_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e) { if (this.groupsTree.FocusedNode.Selected == true) { if ((short)this.groupsTree.FocusedNode[groupsTree.KeyFieldName] != 0) // любая группа { if (!access) { addGroupBtn.Enabled = true; editGroupBtn.Enabled = true; deleteGroupBtn.Enabled = true; addMaterial.Enabled = true; } var source = materialsService.GetMaterials().Where(x => x.MaterialGroupId == (short)this.groupsTree.FocusedNode[groupsTree.KeyFieldName]).ToList(); if (source != null) { materialsBS.DataSource = source; materialsGrid.DataSource = materialsBS; if (!access) { editMaterial.Enabled = true; deleteMaterial.Enabled = true; } } } else // Все материалы { if (!access) { addMaterial.Enabled = false; editMaterial.Enabled = false; deleteMaterial.Enabled = false; editGroupBtn.Enabled = false; deleteGroupBtn.Enabled = false; } var source = materialsService.GetMaterials().ToList(); if (source != null) { materialsBS.DataSource = source; materialsGrid.DataSource = materialsBS; } } } }
private void materialsGridEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { switch (e.Button.Index) { case 1: //Добавить { using (MaterialEditFm materialEditFm = new MaterialEditFm(Utils.Operation.Add, new MaterialsDTO())) { if (materialEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int return_MaterialId = materialEditFm.Return(); materialsService = Program.kernel.Get <IMaterialsService>(); materialsGridEdit.Properties.DataSource = materialsService.GetMaterials(); materialsGridEdit.EditValue = return_MaterialId; } } break; } case 2: //Корректировать { object key = materialsGridEdit.EditValue; var selectedIndex = materialsGridEdit.Properties.GetIndexByKeyValue(key); if (selectedIndex == -1) { return; } using (MaterialEditFm materialEditFm = new MaterialEditFm(Utils.Operation.Update, (MaterialsDTO)materialsGridEdit.GetSelectedDataRow())) { if (materialEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int return_MaterialId = materialEditFm.Return(); materialsService = Program.kernel.Get <IMaterialsService>(); materialsGridEdit.Properties.DataSource = materialsService.GetMaterials(); materialsGridEdit.EditValue = return_MaterialId; } } break; } default: { break; } } }
private void LoadMaterialsData() { materialsService = Program.kernel.Get <IMaterialsService>(); materialsBS.DataSource = materialsService.GetMaterials(); materialsGrid.DataSource = this.materialsBS; }
private bool IsDuplicateRecord(string article) { int itemCount = materialsService.GetMaterials().Count(s => s.Article == article); return(itemCount > 0); }