private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.ZIPPMonStock.Count() == 0 ? 0 : TablesModel.entities.ZIPPMonStock.Max(x => x.zipPM_on_stock_id) + 1; TablesModel.entities.ZIPPMonStock.Add(new Models.ZIPPMonStock() { zipPM_on_stock_id = addId, count = int.Parse(textBoxSize.Text), zipPM_element_id = (int)comboBoxZIPPM.SelectedValue, other = ".." }); } else { var el = TablesModel.entities.ZIPPMonStock.Where(x => x.zipPM_on_stock_id == id).First(); el.count = int.Parse(textBoxSize.Text); el.zipPM_element_id = (int)comboBoxZIPPM.SelectedValue; } TablesModel.entities.SaveChanges(); var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.ZIPPMMoves.Count() == 0 ? 0 : TablesModel.entities.ZIPPMMoves.Max(x => x.zipPM_move_id) + 1; var el = new Models.ZIPPMMoves() { zipPM_move_id = addId, date_move = dateTimePickerMoved.Value, zipPM_element_id = (int)comboBoxZIPPm.SelectedValue, model_element_id = (int)comboBoxModel.SelectedValue }; TablesModel.entities.ZIPPMMoves.Add(el); TablesModel.entities.SaveChanges(); var element_ZIPPM = TablesModel.entities.ZIPPMonStock.Where(x => x.sp_ZIP_AND_PM_Element.zipPM_element_id == el.zipPM_element_id).FirstOrDefault(); if (element_ZIPPM.count <= 0) { throw new ArgumentException(); } else { element_ZIPPM.count -= 1; } TablesModel.entities.SaveChanges(); } else { var el = TablesModel.entities.ZIPPMMoves.Where(x => x.zipPM_move_id == id).First(); el.date_move = dateTimePickerMoved.Value; el.zipPM_element_id = (int)comboBoxZIPPm.SelectedValue; el.model_element_id = (int)comboBoxModel.SelectedValue; } TablesModel.entities.SaveChanges(); var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (ArgumentException ee) { MessageBox.Show("детали закончились на складе!"); return; } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.ModelElement.Count() == 0 ? 0 : TablesModel.entities.ModelElement.Max(x => x.model_element_id) + 1; TablesModel.entities.ModelElement.Add(new Models.ModelElement() { model_element_id = addId, inventory_number = textBoxInventaryNumber.Text, serial_number = textBoxSerialNumber.Text, date_creation = dateTimePickerCreated.Value, date_utilisation = dateTimePickerWriteOff.Value, model_type_id = (int)comboBoxModelType.SelectedValue, reason_write_off_id = (int)comboBoxWriteOffReason.SelectedValue, other = textBoxName.Text, is_mo = checkBox1.Checked ? 1 : 0, date_mo = dateTimePickerMO.Value, date_to = dateTimePickerTO.Value }); TablesModel.entities.SaveChanges(); } else { var el = TablesModel.entities.ModelElement.Where(x => x.model_element_id == id).First(); el.inventory_number = textBoxInventaryNumber.Text; el.serial_number = textBoxSerialNumber.Text; el.date_creation = dateTimePickerCreated.Value; el.date_utilisation = dateTimePickerWriteOff.Value; el.model_type_id = (int)comboBoxModelType.SelectedValue; el.reason_write_off_id = (int)comboBoxWriteOffReason.SelectedValue; el.other = textBoxName.Text; TablesModel.entities.SaveChanges(); } var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.FaticalPhysicalPeoplePositions.Count() == 0 ? 0 : TablesModel.entities.FaticalPhysicalPeoplePositions.Max(x => x.fatical_physical_people_position_id) + 1; TablesModel.entities.FaticalPhysicalPeoplePositions.Add(new Models.FaticalPhysicalPeoplePositions() { fatical_physical_people_position_id = addId, date_begin = dateTimePickerBegin.Value, date_end = dateTimePickerEnd.Value, salary = int.Parse(textBoxSalary.Text), people_position_id = (int)comboBoxPosition.SelectedValue, physical_people_id = (int)comboBoxFIO.SelectedValue, organisation_id = (int)comboBoxOrganisation.SelectedValue }); TablesModel.entities.SaveChanges(); } else { var el = TablesModel.entities.FaticalPhysicalPeoplePositions.Where(x => x.fatical_physical_people_position_id == id).First(); el.date_begin = dateTimePickerBegin.Value; el.date_end = dateTimePickerEnd.Value; el.salary = int.Parse(textBoxSalary.Text); el.people_position_id = (int)comboBoxPosition.SelectedValue; el.physical_people_id = (int)comboBoxFIO.SelectedValue; el.organisation_id = (int)comboBoxOrganisation.SelectedValue; TablesModel.entities.SaveChanges(); } var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.PhysicalPeople.Count() == 0 ? 0 : TablesModel.entities.PhysicalPeople.Max(x => x.physical_people_id) + 1; TablesModel.entities.PhysicalPeople.Add(new Models.PhysicalPeople() { physical_people_id = addId, name = textBoxName.Text, family = textBoxFam.Text, patronumic = textBoxPatr.Text, contacts = textBoxContacts.Text, organisation_department_id = (int)comboBoxDep.SelectedValue, Gender = comboBoxGender.SelectedIndex }); TablesModel.entities.SaveChanges(); } else { var el = TablesModel.entities.PhysicalPeople.Where(x => x.physical_people_id == id).First(); el.name = textBoxName.Text; el.family = textBoxFam.Text; el.patronumic = textBoxPatr.Text; el.contacts = textBoxContacts.Text; el.organisation_department_id = (int)comboBoxDep.SelectedValue; el.Gender = comboBoxGender.SelectedIndex; TablesModel.entities.SaveChanges(); } var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.PersonalOnService.Count() == 0 ? 0 : TablesModel.entities.PersonalOnService.Max(x => x.personal_on_service_id) + 1; TablesModel.entities.PersonalOnService.Add(new Models.PersonalOnService() { personal_on_service_id = addId, physical_people_id = (int)comboBoxFIO.SelectedValue, service_type_id = (int)comboBoxServiceType.SelectedValue, service_operation_type_id = (int)comboBoxServiceOperation.SelectedValue, service_operation_personal_role_id = (int)comboBoxRole.SelectedValue, model_element_id = (int)comboBoxModelElement.SelectedValue }); TablesModel.entities.SaveChanges(); } else { var el = TablesModel.entities.PersonalOnService.Where(x => x.personal_on_service_id == id).First(); el.physical_people_id = (int)comboBoxFIO.SelectedValue; el.service_type_id = (int)comboBoxServiceType.SelectedValue; el.service_operation_type_id = (int)comboBoxServiceOperation.SelectedValue; el.service_operation_personal_role_id = (int)comboBoxRole.SelectedValue; el.physical_people_id = (int)comboBoxFIO.SelectedValue; el.model_element_id = (int)comboBoxModelElement.SelectedValue; TablesModel.entities.SaveChanges(); } var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.MOExpluatation.Count() == 0 ? 0 : TablesModel.entities.MOExpluatation.Max(x => x.mo_expluatation_id) + 1; TablesModel.entities.MOExpluatation.Add(new Models.MOExpluatation() { mo_expluatation_id = addId, date_begin = dateTimePickerBegin.Value, date_end = dateTimePickerEnd.Value, service_operation_personal_role_id = (int)comboBoxRole.SelectedValue, physical_people_id = (int)comboBoxFIO.SelectedValue, model_element_id = (int)comboBoxModel.SelectedValue }); TablesModel.entities.SaveChanges(); } else { var el = TablesModel.entities.MOExpluatation.Where(x => x.mo_expluatation_id == id).First(); el.date_begin = dateTimePickerBegin.Value; el.date_end = dateTimePickerEnd.Value; el.model_element_id = (int)comboBoxModel.SelectedValue; el.physical_people_id = (int)comboBoxFIO.SelectedValue; el.service_operation_personal_role_id = (int)comboBoxRole.SelectedValue; TablesModel.entities.SaveChanges(); } var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.ElementsPlaces.Count() == 0 ? 0 : TablesModel.entities.ElementsPlaces.Max(x => x.element_place_id) + 1; TablesModel.entities.ElementsPlaces.Add(new Models.ElementsPlaces() { element_place_id = addId, date_begin = dateTimePickerMoved.Value, date_end = dateTimePickerMoved.Value, corpus_id = (int)comboBoxCorpus.SelectedValue, floor = 0, room = "..", model_element_id = (int)comboBoxModelElement.SelectedValue, move_reason_id = (int)comboBoxMoveReason.SelectedValue }); } else { var el = TablesModel.entities.ElementsPlaces.Where(x => x.element_place_id == id).First(); el.date_begin = dateTimePickerMoved.Value; el.date_end = dateTimePickerMoved.Value; el.corpus_id = (int)comboBoxCorpus.SelectedValue; el.model_element_id = (int)comboBoxModelElement.SelectedValue; el.move_reason_id = (int)comboBoxMoveReason.SelectedValue; } TablesModel.entities.SaveChanges(); var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.BrokenRequest.Count() == 0 ? 0 : TablesModel.entities.BrokenRequest.Max(x => x.broken_request_id) + 1; TablesModel.entities.BrokenRequest.Add(new Models.BrokenRequest() { broken_request_id = addId, date_to_repair = dateTimePickerMoved.Value, model_element_id = (int)comboBoxModel.SelectedValue, physical_people_id = (int)comboBoxPeople.SelectedValue, broken_request_reason_id = (int)comboBoxBroken.SelectedValue, isFinished = checkBox1.Checked ? 1 : 0 }); } else { var el = TablesModel.entities.BrokenRequest.Where(x => x.broken_request_id == id).First(); el.date_to_repair = dateTimePickerMoved.Value; el.broken_request_id = (int)comboBoxBroken.SelectedValue; el.model_element_id = (int)comboBoxModel.SelectedValue; el.physical_people_id = (int)comboBoxPeople.SelectedValue; el.isFinished = checkBox1.Checked ? 1 : 0; } TablesModel.entities.SaveChanges(); var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.PurchaseElements.Count() == 0 ? 0 : TablesModel.entities.PurchaseElements.Max(x => x.purchase_element_id) + 1; TablesModel.entities.PurchaseElements.Add(new Models.PurchaseElements() { purchase_element_id = addId, isPurchasing = checkBox1.Checked ? 1 : 0, count = int.Parse(textBoxCount.Text), money = int.Parse(textBoxMoney.Text), model_element_id = int.Parse((string)comboBoxModelElement.SelectedValue), planned_date = dateTimePickerMoved.Value }); } else { var el = TablesModel.entities.PurchaseElements.Where(x => x.purchase_element_id == id).First(); el.isPurchasing = checkBox1.Checked ? 1 : 0; el.count = int.Parse(textBoxCount.Text); el.money = int.Parse(textBoxMoney.Text); el.model_element_id = int.Parse((string)comboBoxModelElement.SelectedValue); el.planned_date = dateTimePickerMoved.Value; } TablesModel.entities.SaveChanges(); var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.ModelType.Count() == 0 ? 0 : TablesModel.entities.ModelType.Max(x => x.model_type_id) + 1; TablesModel.entities.ModelType.Add(new Models.ModelType() { model_type_id = addId, expluatation_role_id = (int)comboBoxExpluatation.SelectedValue, organisation_id = (int)comboBoxOrganisation.SelectedValue, functionaly_use_model_id = (int)comboBoxFunc.SelectedValue, model_type_name = textBoxName.Text }); TablesModel.entities.SaveChanges(); } else { var el = TablesModel.entities.ModelType.Where(x => x.model_type_id == id).First(); el.model_type_name = textBoxName.Text; el.organisation_id = (int)comboBoxOrganisation.SelectedValue; el.functionaly_use_model_id = (int)comboBoxFunc.SelectedValue; el.expluatation_role_id = (int)comboBoxExpluatation.SelectedValue; TablesModel.entities.SaveChanges(); } var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.ZIPPMDocumentsOnPurchase.Count() == 0 ? 0 : TablesModel.entities.ZIPPMDocumentsOnPurchase.Max(x => x.zipPM_documents_purchase_id) + 1; TablesModel.entities.ZIPPMDocumentsOnPurchase.Add(new Models.ZIPPMDocumentsOnPurchase() { zipPM_documents_purchase_id = addId, zipPM_element_id = (int)comboBoxModelElement.SelectedValue, count = int.Parse(textBoxCount.Text), date_coming_in = dateTimePickerPlanned.Value, date_to_end_possible_use = dateTimePickerFactical.Value }); } else { var el = TablesModel.entities.ZIPPMDocumentsOnPurchase.Where(x => x.zipPM_documents_purchase_id == id).First(); el.date_coming_in = dateTimePickerPlanned.Value; el.date_to_end_possible_use = dateTimePickerFactical.Value; el.count = int.Parse(textBoxCount.Text); el.zipPM_element_id = (int)comboBoxModelElement.SelectedValue; } TablesModel.entities.SaveChanges(); var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.ElementsDragMetal.Count() == 0 ? 0 : TablesModel.entities.ElementsDragMetal.Max(x => x.elements_drag_metal_id) + 1; TablesModel.entities.ElementsDragMetal.Add(new Models.ElementsDragMetal() { elements_drag_metal_id = addId, model_element_id = (int)comboBoxModel.SelectedValue, drag_metal_id = (int)comboBoxDragMetal.SelectedValue, size = int.Parse(textBoxSize.Text) }); TablesModel.entities.SaveChanges(); } else { var el = TablesModel.entities.ElementsDragMetal.Where(x => x.elements_drag_metal_id == id).First(); el.model_element_id = (int)comboBoxModel.SelectedValue; el.drag_metal_id = (int)comboBoxDragMetal.SelectedValue; el.size = int.Parse(textBoxSize.Text); TablesModel.entities.SaveChanges(); } var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }
private void button1_Click(object sender, EventArgs e) { try { if (id == -1) { int addId = TablesModel.entities.Purchase.Count() == 0 ? 0 : TablesModel.entities.Purchase.Max(x => x.purchase_id) + 1; TablesModel.entities.Purchase.Add(new Models.Purchase() { purchase_id = addId, date_apply = dateTimePickerCreated.Value, purchase_document_number = textBoxDocNumber.Text, purchase_type_id = (int)comboBoxPurchaseType.SelectedValue }); } else { var el = TablesModel.entities.Purchase.Where(x => x.purchase_id == id).First(); el.date_apply = dateTimePickerCreated.Value; el.purchase_document_number = textBoxDocNumber.Text; el.purchase_type_id = (int)comboBoxPurchaseType.SelectedValue; } TablesModel.entities.SaveChanges(); var frm = DBEditing.getInstanceDB(); if (frm != null) { frm.UPdateDB(); } MessageBox.Show("изменения успешно приняты"); this.Close(); } catch (Exception ee) { MessageBox.Show("Введены некорректные данные"); } }