public static void DoRepairOrCheck(Worker worker, List <string> descriptions, bool isRepair_) { int i = 0; foreach (var item in Items.GetItems) { using (kipEntities context = new kipEntities()) { Guid guid = Guid.Parse(item.Block.Id); var eq = context.EquipmentSet.Where(b => b.Id == guid).SingleOrDefault(); var performer = context.WorkerSet.Where(b => b.Id == worker.Id).SingleOrDefault(); if (eq == null) { throw new Exception("Не найден блок с идентификатором " + guid.ToString()); } else { eq.isWorking = true; eq.serviceDate = DateTime.Today.Date; var service = new ServiceLog { date = DateTime.Now, description = descriptions[i++], Equipment = eq, isRepair = isRepair_, Performer = performer }; context.ServiceLogSet.Add(service); eq.ServiceLog.Add(service); context.SaveChanges(); } } } }
public static void FillGrid(ListBox list, DataGridView view) { var str = ""; if (list.SelectedItem != null) { str = list.SelectedItem.ToString(); } gridView = view; listBox = list; switch (str) { case "Оборудование": Equipment.FillGrid(view); break; case "Типы оборудования": EquipmentType.FillGrid(view); break; case "Производители": Manufacturer.FillGrid(view); break; case "Типы систем": SystemType.FillGrid(view); break; case "Роли МВПС": MVPSRole.FillGrid(view); break; case "Типы МВПС": MVPSType.FillGrid(view); break; case "МВПС": MVPS.FillGrid(view); break; case "Правила компелктования": EquipmentRule.FillGrid(view); break; case "Замены оборудования": ReplacingLog.FillGrid(view); break; case "Работники": Worker.FillGrid(view); break; case "Должности": Position.FillGrid(view); break; case "График ТО и ТР": Shedule.FillGrid(view); break; case "Журнал проверки/ремонта": ServiceLog.FillGrid(view); break; default: break; } }