private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { ModulComboBox.Items.Clear(); switch (TelesysComboBox.SelectedItem.ToString()) { case "BAKER": { using (DBTTNEntities db = new DBTTNEntities()) { ModulComboBox.Items.AddRange(db.tbl_Modul_Name.Where(x => x.Class_Modul_Name.Equals("BakerModul")).Select(x => x.Short_Name_Modul_Name).ToArray()); } break; } case "COILTRACK": { using (DBTTNEntities db = new DBTTNEntities()) { ModulComboBox.Items.AddRange(db.tbl_Modul_Name.Where(x => x.Class_Modul_Name.Equals("CoilTrackModul")).Select(x => x.Short_Name_Modul_Name).ToArray()); } break; } case "EGSS": { using (DBTTNEntities db = new DBTTNEntities()) { ModulComboBox.Items.AddRange(db.tbl_Modul_Name.Where(x => x.Class_Modul_Name.Equals("EGSSModul")).Select(x => x.Short_Name_Modul_Name).ToArray()); } break; } case "COMBO": { using (DBTTNEntities db = new DBTTNEntities()) { ModulComboBox.Items.AddRange(db.tbl_Modul_Name.Where(x => x.Class_Modul_Name.Equals("ComboModul")).Select(x => x.Short_Name_Modul_Name).ToArray()); } break; } case "Другое": { using (DBTTNEntities db = new DBTTNEntities()) { ModulComboBox.Items.AddRange(db.tbl_Modul_Name.Where(x => x.Class_Modul_Name.Equals("OtherModul")).Select(x => x.Short_Name_Modul_Name).ToArray()); } break; } } }
private void ModulComboBox_SelectedIndexChanged(object sender, EventArgs e) { string selectedModul = ModulComboBox.SelectedItem.ToString(); tbl_Modul_Name mn; using (DBTTNEntities db = new DBTTNEntities()) { mn = db.tbl_Modul_Name.Where(x => x.Short_Name_Modul_Name.Equals(selectedModul)).FirstOrDefault(); } WeightTextBox.Text = mn.Weight_Modul_Name.ToString(); WayToGetWeightTextBox.Text = mn.Way_To_Find_Weight; CatalogNumberTextBox.Text = mn.Catalog_Nomer_Modul_Name; }
private void DeleteCurrentWorkerButton_Click(object sender, EventArgs e) { if (WorkersDataGridView.SelectedRows.Count > 0) { if (MessageBox.Show("Вы уверены что хотите удалить работника?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { using (DBTTNEntities db = new DBTTNEntities()) { string tabNumber = WorkersDataGridView.SelectedRows[0].Cells[3].Value.ToString(); tbl_Kadrovii_Sostav ks = new tbl_Kadrovii_Sostav(); ks = db.tbl_Kadrovii_Sostav.Where(x => x.Tab_N_KS.Equals(tabNumber)).FirstOrDefault(); db.tbl_Kadrovii_Sostav.Remove(ks); WorkersDataGridView.Rows.Remove(WorkersDataGridView.SelectedRows[0]); db.SaveChanges(); } } } }
private void AddItemInTTNList_Load(object sender, EventArgs e) { ExistItemRadioButton.Checked = true; List <string> spPackage; List <string> spEdIzmer; using (DBTTNEntities db = new DBTTNEntities()) { //ModulComboBox.Items.AddRange(db.tbl_Modul_Name.Where(x => x.Class_Modul_Name.Equals("BakerModul")).Select(x => x.Short_Name_Modul_Name).ToArray()); spPackage = db.tbl_Spiski.Where(x => x.Name_Spiski.Equals("PackageView")).Select(x => x.Value_Spiski).ToList(); spEdIzmer = db.tbl_Spiski.Where(x => x.Name_Spiski.Equals("EdIzmer")).Select(x => x.Value_Spiski).ToList(); } PackageViewComboBox.Items.Clear(); EdIzmerComboBox.Items.Clear(); PackageViewComboBox.Items.AddRange(spPackage.ToArray()); EdIzmerComboBox.Items.AddRange(spEdIzmer.ToArray()); ResetFields(); }
private void ModulComboBox_SelectedIndexChanged(object sender, EventArgs e) { string selectedModul = ModulComboBox.SelectedItem.ToString(); tbl_Modul_Name mn; using (DBTTNEntities db = new DBTTNEntities()) { mn = db.tbl_Modul_Name.Where(x => x.Short_Name_Modul_Name.Equals(selectedModul)).FirstOrDefault(); } WeightTextBox.Text = mn.Weight_Modul_Name.ToString(); WayToGetWeightTextBox.Text = mn.Way_To_Find_Weight; CommentRichTextBox.Text = mn.Comment_Modul_Name; CatalogNumberTextBox.Text = mn.Catalog_Nomer_Modul_Name; if (mn.Image_Path != null) { var stream = new MemoryStream(mn.Image_Path); pictureBox1.Image = Image.FromStream(stream); } }
private void AdEditPartWorkers_Load(object sender, EventArgs e) { using (DBTTNEntities db = new DBTTNEntities()) { PartNumberComboBox.Items.AddRange(db.tbl_ORM.Where(x => x.Short_Name_ORM.Contains("ИТП")).Select(x => x.Short_Name_ORM).ToArray()); var partWorkers = (from orm in db.tbl_ORM join ks in db.tbl_Kadrovii_Sostav on orm.ID_ORM equals ks.Kod_ORM_KS where orm.Short_Name_ORM.Contains("ИТП") select ks).ToList(); int i = 0; while (partWorkers.Count > i) { int ormID = (int)partWorkers[i].Kod_ORM_KS; string orm = db.tbl_ORM.Where(x => x.ID_ORM == ormID).Select(x => x.Short_Name_ORM).FirstOrDefault(); WorkersDataGridView.Rows.Add(partWorkers[i].Familiya_KS, partWorkers[i].Imya_KS, partWorkers[i].Otchestvo_KS, partWorkers[i].Tab_N_KS, partWorkers[i].Dolgnost_KS, orm); i++; } } }
private void AddKadrviiSostRecord() { using (DBTTNEntities db = new DBTTNEntities()) { if (FirstNameTextBox.Text != "" && SecondNameTextBox.Text != "" && LastNameTextBox.Text != "" && TabNumberTextBox.Text != "" && DoljnostComboBox.SelectedItem.ToString() != "" && PartNumberComboBox.SelectedItem.ToString() != "") { try { string tabNumber = TabNumberTextBox.Text; tbl_Kadrovii_Sostav ks = new tbl_Kadrovii_Sostav(); //ks = db.tbl_Kadrovii_Sostav.Where(x => x.Tab_N_KS.Equals(tabNumber)).FirstOrDefault(); ks.Familiya_KS = FirstNameTextBox.Text; ks.Imya_KS = SecondNameTextBox.Text; ks.Otchestvo_KS = LastNameTextBox.Text; ks.Tab_N_KS = TabNumberTextBox.Text; ks.Dolgnost_KS = DoljnostComboBox.SelectedItem.ToString(); string pn = PartNumberComboBox.SelectedItem.ToString(); ks.Kod_ORM_KS = db.tbl_ORM.Where(x => x.Short_Name_ORM.Equals(pn)).Select(x => x.ID_ORM).FirstOrDefault(); db.tbl_Kadrovii_Sostav.Add(ks); db.SaveChanges(); WorkersDataGridView.Rows.Add(FirstNameTextBox.Text, SecondNameTextBox.Text, LastNameTextBox.Text, TabNumberTextBox.Text, DoljnostComboBox.SelectedItem.ToString(), PartNumberComboBox.SelectedItem.ToString()); ApplyButton.Visible = false; CancelButton.Visible = false; } catch (Exception e) { MessageBox.Show("Ошибка: " + e.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Одно из полей не заполнено. Пожалуйста, заполните ВСЕ поля для продолжения.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void ApplyButton_Click(object sender, EventArgs e) { using (DBTTNEntities db = new DBTTNEntities()) { //string tabNumber = TabNumberTextBox.Text; if (db.tbl_Kadrovii_Sostav.Where(x => x.Tab_N_KS.Equals(tabNumberEditWorker)).Count() > 0) { if (WorkersDataGridView.SelectedRows.Count > 0) { EditKadrviiSostRecord(); CloseBoxes(); } else { MessageBox.Show("Не выбрано ни одного работника для изменения"); } } else { AddKadrviiSostRecord(); CloseBoxes(); } } }
private void EditKadrviiSostRecord() { using (DBTTNEntities db = new DBTTNEntities()) { //string tabNumber = TabNumberTextBox.Text; tbl_Kadrovii_Sostav ks = new tbl_Kadrovii_Sostav(); ks = db.tbl_Kadrovii_Sostav.Where(x => x.Tab_N_KS.Equals(tabNumberEditWorker)).FirstOrDefault(); ks.Familiya_KS = FirstNameTextBox.Text; ks.Imya_KS = SecondNameTextBox.Text; ks.Otchestvo_KS = LastNameTextBox.Text; ks.Tab_N_KS = TabNumberTextBox.Text; ks.Dolgnost_KS = DoljnostComboBox.SelectedItem.ToString(); string pn = PartNumberComboBox.SelectedItem.ToString(); ks.Kod_ORM_KS = db.tbl_ORM.Where(x => x.Short_Name_ORM.Equals(pn)).Select(x => x.ID_ORM).FirstOrDefault(); db.SaveChanges(); WorkersDataGridView.SelectedRows[0].Cells[0].Value = FirstNameTextBox.Text; WorkersDataGridView.SelectedRows[0].Cells[1].Value = SecondNameTextBox.Text; WorkersDataGridView.SelectedRows[0].Cells[2].Value = LastNameTextBox.Text; WorkersDataGridView.SelectedRows[0].Cells[3].Value = TabNumberTextBox.Text; WorkersDataGridView.SelectedRows[0].Cells[4].Value = DoljnostComboBox.SelectedItem; WorkersDataGridView.SelectedRows[0].Cells[5].Value = PartNumberComboBox.SelectedItem; } }