private void PictureBox1_Click(object sender, EventArgs e) { ///ToDo: не пускать этот код в продакшн using (kipEntities context = new kipEntities()) { Worker worker = context.WorkerSet.Include("Position").Where(b => b.PersonnelNumber == 11179474).SingleOrDefault(); if (worker == null) { Position pos = context.PositionSet.Where(b => b.name == "Администратор").SingleOrDefault(); if (pos == null) { pos = new Position { name = "Администратор", }; context.PositionSet.Add(pos); } worker = new Worker { Position = pos, Name = "Тестовый", Family = "Профиль", Patronymic = "Администатора", PersonnelNumber = 11100000, PinCodeHash = "" }; context.WorkerSet.Add(worker); context.SaveChanges(); } var position = worker.Position.Id; GetNextForm(position, worker); } }
private void FillNotWorkedList(string NodeText) { NotWorkedList.Items.Clear(); LastSystemType = NodeText; using (kipEntities context = new kipEntities()) { var equipments = from eqType in context.EquipmentSet where eqType.EquipmentType.name == NodeText select eqType; var nonWorked = from eq in equipments where eq.isFree select eq; foreach (var block in nonWorked) { string str = String.Format(" {0:P2}", block.GetRemainingLife()); var color = block.GetColor(); if (!block.isWorking) { color = Color.DarkRed; str = " неиспр."; } NotWorkedList.Items.Add(block.EquipmentType.name + " " + block.number + str).ForeColor = color; } } foreach (ListViewItem item in InRepair.Items) { string str = item.Text; var toRemoveFromList = NotWorkedList.FindItemWithText(str); NotWorkedList.Items.Remove(toRemoveFromList); } }
private void FillForm() { UserLabel.Text = worker.Family + " " + worker.Name + " " + worker.Patronymic; PersonnelNumberlLabel.Text = worker.PersonnelNumber.ToString(); PositionLabel.Text = worker.Position.name; PersonnelNumberlLabel.Location = new Point(UserLabel.Location.X + UserLabel.Width + 20, PersonnelNumberlLabel.Location.Y); PositionLabel.Location = new Point(UserLabel.Location.X + UserLabel.Width + 20, PositionLabel.Location.Y); using (kipEntities context = new kipEntities()) { DateTime date = DateTime.Today.Date; var shed = context.SheduleSet.Where(b => b.date == date).SingleOrDefault(); dayMVPSList.Items.Clear(); if (shed != null) { foreach (var to3 in shed.MVPS_Maintenance) { dayMVPSList.Items.Add("ТО3 " + to3.GetSeries()); } foreach (var tr1 in shed.MVPS_Repair) { dayMVPSList.Items.Add("ТР1 " + tr1.GetSeries()); } } else { dayMVPSList.Items.Add("Рассписания пока нет"); } } }
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(); } } } }
private void Replacing(kipEntities context, Guid InEquipment, Guid OutEquipment, MVPS mvps, string input) { bool onShed = false; if (input == "По сроку.") { onShed = true; } Equipment InEq = context.EquipmentSet.Where(b => b.Id == InEquipment).Single(); Equipment OutEq = context.EquipmentSet.Where(b => b.Id == OutEquipment).Single(); Worker performer = context.WorkerSet.Where(b => b.Id == worker.Id).Single(); ReplacingLog replacing = new ReplacingLog { date = DateTime.Now, description = input, Installed = InEq, MVPS = mvps, onShedule = onShed, Removed = OutEq, Worker = performer }; context.ReplacingLogSet.Add(replacing); }
private void FillEntity(int id) { using (kipEntities context = new kipEntities()) { rule = context.EquipmentRuleSet.Where(b => b.Id == id).SingleOrDefault(); for (int i = 0; i < MVPSRoleBox_.Items.Count; i++) { if (MVPSRoleBox_.Items[i].ToString() == rule.MVPSRole.name) { MVPSRoleBox_.SelectedIndex = i; } } for (int i = 0; i < MVPSTypeBox_.Items.Count; i++) { if (MVPSTypeBox_.Items[i].ToString() == rule.MVPSType.name) { MVPSTypeBox_.SelectedIndex = i; } } foreach (EquipmentType eq in rule.EquipmentType) { EquipmentTypeBox.Items.Add(eq.name); InRuleEqId.Add(eq.Id); } AddButton.Text = "Сохранить"; } }
private void FillForm() { using (kipEntities context = new kipEntities()) { try { var mvpsRole = context.MVPSRoleSet.ToList(); var mvpsType = context.MVPSTypeSet.ToList(); var systemType = context.SystemTypeSet.ToList(); roleId.Clear(); typeId.Clear(); sysTypeId.Clear(); foreach (MVPSRole role in mvpsRole) { MVPSRoleBox_.Items.Add(role.name); roleId.Add(role.Id); } foreach (MVPSType type in mvpsType) { MVPSTypeBox_.Items.Add(type.name); typeId.Add(type.Id); } foreach (SystemType type in systemType) { SystemTypeBox.Items.Add(type.name); sysTypeId.Add(type.Id); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void FillForm() { using (kipEntities context = new kipEntities()) { try { var positions = context.PositionSet.ToList(); PositionBox.Items.Clear(); foreach (Position pos in positions) { PositionBox.Items.Add(pos.name); } if (worker != null) { NameBox.Text = worker.Name; FamilyBox.Text = worker.Family; PatronymicBox.Text = worker.Patronymic; PersonnelNumberBox.Text = worker.PersonnelNumber.ToString(); worker = null; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void FillEntity(int id) { using (kipEntities context = new kipEntities()) { type = context.EquipmentTypeSet.Where(b => b.Id == id).SingleOrDefault(); for (int i = 0; i < SysTypeBox.Items.Count; i++) { if (SysTypeBox.Items[i].ToString() == type.SystemType.name) { SysTypeBox.SelectedIndex = i; } } for (int i = 0; i < ManufactBox.Items.Count; i++) { if (ManufactBox.Items[i].ToString() == type.Manufacturer.name) { ManufactBox.SelectedIndex = i; } } DescriptionBox.Text = type.description; NameBox.Text = type.name; VerificationPeriodBox.Text = type.verfPeriod.ToString(); ServicePeriodBox.Text = type.servicePeriod.ToString(); AddButton.Text = "Сохранить"; } }
private void FillEntity(Guid id) { using (kipEntities context = new kipEntities()) { mVPS = context.MVPSSet.Where(b => b.Id == id).SingleOrDefault(); NumberBox.Text = mVPS.number; SeriesBox.Text = mVPS.series; for (int i = 0; i < RoleBox.Items.Count; i++) { if (RoleBox.Items[i].ToString() == mVPS.MVPSRole.name) { RoleBox.SelectedIndex = i; } } for (int i = 0; i < TypeBox.Items.Count; i++) { if (TypeBox.Items[i].ToString() == mVPS.MVPSType.name) { TypeBox.SelectedIndex = i; } } AddButton.Text = "Сохранить"; IdBox.Text = mVPS.Id.ToString(); } }
private void RuleBox_SelectedIndexChanged(object sender, EventArgs e) { using (kipEntities context = new kipEntities()) { try { if ((TypeBox.SelectedIndex == -1) || (RoleBox.SelectedIndex == -1)) { throw new Exception("Необходимо выбрать роль и тип МВПС"); } int key = currentRules[RuleBox.SelectedIndex].Id; var types = context.EquipmentRuleSet.Where(b => b.Id == key).SingleOrDefault(); RuleList.Items.Clear(); foreach (EquipmentType type in types.EquipmentType) { RuleList.Items.Add(type.name); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void DoServiceButton_Click(object sender, EventArgs e) { if (CheckAllInRepair(false)) { var result = MessageBox.Show("Открыть дефектные ведомости?", "Ремонт оборудования", MessageBoxButtons.YesNo); foreach (ListViewItem item in InRepair.Items) { string[] vs = item.Text.Split(' '); using (kipEntities context = new kipEntities()) { string type = vs[0], number = vs[1]; var eq = context.EquipmentSet.Where(b => b.EquipmentType.name == type && b.number == number).SingleOrDefault(); if (eq == null) { throw new Exception("Что-то пошло не так, не найден блок с типом " + vs[0] + " и номером" + vs[1]); } else { Items.CreateItem(vs[0], vs[1], eq.Id.ToString(), false); } } } if (result == DialogResult.Yes) { Docs.OpenDocs(Items.GetItems); } Repair.DoRepairOrCheck(worker, Comments, false); Comments.Clear(); InRepair.Clear(); FillNotWorkedList(LastSystemType); } }
private void FillList() { using (kipEntities context = new kipEntities()) { DateTime date = dateTimePicker1.Value.Date; var shed = context.SheduleSet.Where(b => b.date == date).SingleOrDefault(); DayMVPSList.Items.Clear(); if (shed != null) { foreach (var to3 in shed.MVPS_Maintenance) { DayMVPSList.Items.Add("ТО3 " + to3.GetSeries()); } foreach (var tr1 in shed.MVPS_Repair) { DayMVPSList.Items.Add("ТР1 " + tr1.GetSeries()); } } else { DayMVPSList.Items.Add("Рассписания пока нет"); } } }
private void FillForm(Guid id) { using (kipEntities context = new kipEntities()) { var eq = context.EquipmentSet.Where(b => b.Id == id).SingleOrDefault(); FillByEquipment(eq); } }
private void AddButton_Click(object sender, EventArgs e) { using (kipEntities context = new kipEntities()) { try { CheckFields(); if (manufacturer != null) { int key = manufacturer.Id; Manufacturer freshMan = context.ManufacturerSet.Where(b => b.Id == key).SingleOrDefault(); string str = ManufacturerNameBox.Text; if ((freshMan.name != str) && (str != "")) { freshMan.name = str; } if ((ManufacturerAddressBox.Text != "") && (ManufacturerAddressBox.Text != freshMan.address)) { freshMan.address = ManufacturerAddressBox.Text; } if ((ManufacturerPhoneBox.Text != "") && (ManufacturerPhoneBox.Text != freshMan.phone)) { freshMan.phone = ManufacturerPhoneBox.Text; } if ((ManufacturerEmailBox.Text != "") && (ManufacturerEmailBox.Text != freshMan.email)) { freshMan.email = ManufacturerEmailBox.Text; } context.SaveChanges(); } else { CheckFields(); string str = ManufacturerNameBox.Text; if (str != "") { Manufacturer freshMan = new Manufacturer { name = str, address = ManufacturerAddressBox.Text, phone = ManufacturerPhoneBox.Text, email = ManufacturerEmailBox.Text, }; context.ManufacturerSet.Add(freshMan); context.SaveChanges(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Close(); } } }
private void FillForm(int id) { using (kipEntities context = new kipEntities()) { var service = context.ServiceLogSet.Where(b => b.Id == id).SingleOrDefault(); var eq = service.Equipment; FillByEquipment(eq); } }
private void AddButton_Click(object sender, EventArgs e) { using (kipEntities context = new kipEntities()) { try { if (SystemTypeNameBox.Text == "Введите название системы") { throw new Exception("Введите коректное название системы"); } if (SystemTypeDescriptionBox.Text == "Введите описание системы") { throw new Exception("Введите коректное описание системы"); } if (type != null) { int key = type.Id; SystemType freshSysType = context.SystemTypeSet.Where(b => b.Id == key).SingleOrDefault(); string str = SystemTypeNameBox.Text; if (str != "") { if (str != freshSysType.name) { freshSysType.name = str; } if (SystemTypeDescriptionBox.Text != freshSysType.description) { freshSysType.description = SystemTypeDescriptionBox.Text; } context.SaveChanges(); } } else { string str = SystemTypeNameBox.Text; if (str != "") { SystemType freshSysType = new SystemType { name = str, description = SystemTypeDescriptionBox.Text }; context.SystemTypeSet.Add(freshSysType); context.SaveChanges(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Close(); } } }
private void FillEntity(int id) { using (kipEntities context = new kipEntities()) { role = context.MVPSRoleSet.Where(b => b.Id == id).SingleOrDefault(); MVPSRoleBox.Text = role.name; } AddButton.Text = "Сохранить"; }
private void FillForm() { using (kipEntities context = new kipEntities()) { try { var roles = context.MVPSRoleSet.ToList(); var types = context.MVPSTypeSet.ToList(); var seriesSet = context.MVPSSet.Select(b => b.series).ToList(); List <string> unicalSeries = new List <string>(); MVPSRoleBox.Items.Add("Любой"); MVPSTypeBox.Items.Add("Любой"); foreach (MVPSRole role in roles) { MVPSRoleBox.Items.Add(role.name); } foreach (MVPSType type in types) { MVPSTypeBox.Items.Add(type.name); } foreach (string series in seriesSet) { if (unicalSeries.Find(b => b == series) != series) { unicalSeries.Add(series); } } DateTime date = DateTime.Today.Date; var todayShedule = context.SheduleSet.Where(b => b.date == date).SingleOrDefault(); foreach (string str in unicalSeries) { if (worker != null) { if (todayShedule != null) { if (todayShedule.ContainSeries(str)) { MVPSSeriesBox.Items.Add(str); } } } else { MVPSSeriesBox.Items.Add(str); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void FillEntity(int id) { using (kipEntities context = new kipEntities()) { type = context.SystemTypeSet.Where(b => b.Id == id).SingleOrDefault(); SystemTypeNameBox.Text = type.name; SystemTypeDescriptionBox.Text = type.description; } AddButton.Text = "Сохранить"; }
private void FillForm() { using (kipEntities context = new kipEntities()) { try { IdBox.Text = Guid.NewGuid().ToString(); //TypeBox & RoleBox var types = context.MVPSTypeSet.ToList(); var roles = context.MVPSRoleSet.ToList(); var currentRules = context.EquipmentRuleSet.ToList(); foreach (MVPSRole role in roles) { RoleBox.Items.Add(role.name); roleIds.Add(role.Id); } foreach (MVPSType type in types) { TypeBox.Items.Add(type.name); typeIds.Add(type.Id); } if (mVPS != null) { for (int i = 0; i < RoleBox.Items.Count; i++) { if (RoleBox.Items[i].ToString() == mVPS.MVPSRole.name) { RoleBox.SelectedIndex = i; } } for (int i = 0; i < TypeBox.Items.Count; i++) { if (TypeBox.Items[i].ToString() == mVPS.MVPSType.name) { TypeBox.SelectedIndex = i; } } GetRuleList(); SeriesBox.Text = mVPS.series; } mVPS = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void FillEntity(int id) { using (kipEntities context = new kipEntities()) { manufacturer = context.ManufacturerSet.Where(b => b.Id == id).SingleOrDefault(); ManufacturerNameBox.Text = manufacturer.name; ManufacturerAddressBox.Text = manufacturer.address; ManufacturerPhoneBox.Text = manufacturer.phone; ManufacturerEmailBox.Text = manufacturer.email; } AddButton.Text = "Сохранить"; }
private void FillForm() { using (kipEntities context = new kipEntities()) { var types = context.EquipmentTypeSet.ToList(); typeIds.Clear(); foreach (var type in types) { TypeBox.Items.Add(type.name); typeIds.Add(type.Id); } IdBox.Text = Guid.NewGuid().ToString(); if (eq != null) { try { IsWorking.Checked = eq.isWorking; IsFree.Checked = eq.isFree; for (int i = 0; i < TypeBox.Items.Count; i++) { if (TypeBox.Items[i].ToString() == eq.EquipmentType.name) { TypeBox.SelectedIndex = i; } } DateTime date; if (eq.nextVerificationDate.HasValue) { date = eq.nextVerificationDate.Value; VerificationDate.Text = date.ToString("dd.MM.yy"); } if (eq.termDate.HasValue) { date = eq.termDate.Value; TerminationDate.Text = date.ToString("dd.MM.yy"); } RepairDate.Text = eq.repairDate.ToString("dd.MM.yy"); ServiceDate.Text = eq.serviceDate.ToString("dd.MM.yy"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { eq = null; } } } }
private bool checkUnStaffed(MVPS mvp, kipEntities context) { var mvps = context.MVPSSet.Where(b => b.series == mvp.series); foreach (var m in mvps) { if (!m.IsStaffed()) { return(false); } } return(true); }
private void FillGrid() { mvpsGuid = Guid.Empty; if (CheckAllSelected()) { using (kipEntities context = new kipEntities()) { try { var type = MVPSTypeBox.SelectedItem.ToString(); var series = MVPSSeriesBox.SelectedItem.ToString(); var number = MVPSNumberBox.SelectedItem.ToString(); MVPS mvps = context.MVPSSet.Where(b => (b.series == series) && (b.MVPSType.name == type) && (b.number == number)).SingleOrDefault(); mvpsGuid = mvps.Id; var rules = mvps.EquipmentRule.EquipmentType.ToList(); int i = 0; mvpsGrid.Rows.Clear(); foreach (var rule in rules) { string cell1 = null, cell2 = null, cell3 = null, cell4 = null; var block = mvps.Equipment.Where(b => b.EquipmentType == rule).SingleOrDefault(); Guid? cell0 = null; cell1 = rule.name; cell2 = rule.SystemType.name; if (block != null) { cell0 = block.Id; cell3 = block.number; cell4 = block.serviceDate.ToString("dd.MM.yy"); } mvpsGrid.Rows.Add(cell0, cell1, cell2, cell3, cell4); i++; } FillEquipmentGrid(mvpsGrid[1, 0].Value.ToString()); //var equipments = mvps.Equipment } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void MvpsGrid_CellDoubleClick(Object sender, DataGridViewCellEventArgs e) { if (CheckAllSelected() && !CheckEmpty()) { using (kipEntities context = new kipEntities()) { Guid id = Guid.Parse(mvpsGrid[0, e.RowIndex].Value.ToString()); Equipment equipment = context.EquipmentSet.Where(b => b.Id == id).SingleOrDefault(); DialogResult result = MessageBox.Show("Нажмите \"Да\", если блок снимается по неисправности. Если блок снимается по другой причине - нажмите \"Нет\"", "Снимаем " + equipment.EquipmentType.name + " № " + equipment.number, MessageBoxButtons.YesNoCancel); MVPS mvps = context.MVPSSet.Where(b => b.Id == mvpsGuid).SingleOrDefault(); equipment.isFree = true; mvps.Equipment.Remove(equipment); context.SaveChanges(); switch (result) { case DialogResult.Yes: equipment.isWorking = false; equipment.isFree = true; mvps.Equipment.Remove(equipment); if (worker != null) { OutGuid = equipment.Id; input = Microsoft.VisualBasic.Interaction.InputBox("Введите комментарий к замене", "Замена оборудования", "По сроку.", -1, -1); } context.SaveChanges(); break; case DialogResult.No: equipment.isFree = true; mvps.Equipment.Remove(equipment); if (worker != null) { OutGuid = equipment.Id; input = Microsoft.VisualBasic.Interaction.InputBox("Введите комментарий к замене", "Замена оборудования", "По сроку.", -1, -1); } context.SaveChanges(); break; case DialogResult.Cancel: break; } } FillGrid(); } }
private void FillForm() { UserLabel.Text = worker.Family + " " + worker.Name + " " + worker.Patronymic; PersonnelNumberlLabel.Text = worker.PersonnelNumber.ToString(); PositionLabel.Text = worker.Position.name; PersonnelNumberlLabel.Location = new Point(UserLabel.Location.X + UserLabel.Width + 20, PersonnelNumberlLabel.Location.Y); PositionLabel.Location = new Point(UserLabel.Location.X + UserLabel.Width + 20, PositionLabel.Location.Y); using (kipEntities context = new kipEntities()) { ServiceableEquipmentCount.Text = context.EquipmentSet.Where(b => b.isFree && b.isWorking).Count().ToString(); InstalledEquipmentCount.Text = context.EquipmentSet.Where(b => !b.isFree && b.isWorking).Count().ToString(); FaultyEquipment.Text = context.EquipmentSet.Where(b => !b.isWorking).Count().ToString(); } }
public DataGridViewRow GetRow() { var row = new DataGridViewRow(); using (kipEntities context = new kipEntities()) { string remStr = null; string insStr = null; string mvpsStr = null; string workerStr = null; //тут что то не так. Equipment rem = context.EquipmentSet.Where(b => b.Id == Removed.Id).SingleOrDefault(); Equipment ins = context.EquipmentSet.Where(b => b.Id == Installed.Id).SingleOrDefault(); if (rem != null) { remStr = rem.EquipmentType.name + " № " + rem.number; } if (ins != null) { insStr = ins.EquipmentType.name + " № " + ins.number; } mvpsStr = MVPS.MVPSType.name + " " + MVPS.series + " " + MVPS.number; workerStr = Worker.GetFIO(); row.Cells.Add(new DataGridViewTextBoxCell { Value = Id }); row.Cells.Add(new DataGridViewTextBoxCell { Value = date.ToString("dd.MM.yy H:mm") }); row.Cells.Add(new DataGridViewTextBoxCell { Value = remStr }); row.Cells.Add(new DataGridViewTextBoxCell { Value = insStr }); row.Cells.Add(new DataGridViewTextBoxCell { Value = description }); row.Cells.Add(new DataGridViewTextBoxCell { Value = mvpsStr }); row.Cells.Add(new DataGridViewTextBoxCell { Value = workerStr }); } return(row); }
private void TypeBox_SelectedIndexChanged(object sender, EventArgs e) { using (kipEntities context = new kipEntities()) { int typeId = typeIds[TypeBox.SelectedIndex]; var type = context.EquipmentTypeSet.Where(b => b.Id == typeId).SingleOrDefault(); if ((!type.verfPeriod.HasValue) || (type.verfPeriod.Value == 0)) { VerificationDate.Enabled = false; } else { VerificationDate.Enabled = true; } } }
private void FillEquipmentGrid(string v) { using (kipEntities context = new kipEntities()) try { var equipments = context.EquipmentSet.Where(b => (b.EquipmentType.name == v) && (b.isFree) && (b.isWorking)).ToList(); equipmentGrid.Rows.Clear(); foreach (var eq in equipments) { equipmentGrid.Rows.Add(eq.Id, eq.EquipmentType.name, eq.number.ToString(), eq.serviceDate.ToString("dd.MM.yy")); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }