private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Введите имя сотрудника!"); return; } try { using (CWMEntities cwm = new CWMEntities(EnCon)) { EMPLOYEE e1; e1 = (EMPLOYEE)(from t in cwm.EMPLOYEE where t.ID == emp.ID select t).First(); e1.ENAME = textBox1.Text; cwm.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Ошибка при редактировании сотрудника!", ex.Message); return; } MessageBox.Show("Сотрудник успешно изменен!"); Close(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Введите имя сотрудника!"); return; } EMPLOYEE e1 = new EMPLOYEE(); e1.ENAME = textBox1.Text; try { using (CWMEntities cwm = new CWMEntities(EnCon)) { cwm.AddToEMPLOYEE(e1); cwm.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Ошибка при добавлении сотрудника!", ex.Message); return; } MessageBox.Show("Сотрудник успешно добавлен!"); Close(); }
public EditCar(int id) { InitializeComponent(); using (CWMEntities cwm = new CWMEntities(EnCon)) { var r = (from p in cwm.CAR where p.ID == id select p).First(); textBox1.Text = ((CAR)r).CNAME; car = new CAR(); car.ID = ((CAR)r).ID; car.CNAME = ((CAR)r).CNAME; car.IDCLASS = ((CAR)r).IDCLASS; if (car.IDCLASS == 1) { radioButton1.Checked = true; } if (car.IDCLASS == 2) { radioButton2.Checked = true; } if (car.IDCLASS == 3) { radioButton3.Checked = true; } if (car.IDCLASS == 4) { radioButton4.Checked = true; } if (car.IDCLASS == 5) { radioButton5.Checked = true; } } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Ведите наименование услуги!"); return; } PRICELIST p1 = new PRICELIST(); p1.PNAME = textBox1.Text; p1.IDCLASS = 1; p1.COST = (int)numericUpDown1.Value; PRICELIST p2 = new PRICELIST(); p2.PNAME = textBox1.Text; p2.IDCLASS = 2; p2.COST = (int)numericUpDown2.Value; PRICELIST p3 = new PRICELIST(); p3.PNAME = textBox1.Text; p3.IDCLASS = 3; p3.COST = (int)numericUpDown3.Value; PRICELIST p4 = new PRICELIST(); p4.PNAME = textBox1.Text; p4.IDCLASS = 4; p4.COST = (int)numericUpDown4.Value; PRICELIST p5 = new PRICELIST(); p5.PNAME = textBox1.Text; p5.IDCLASS = 5; p5.COST = (int)numericUpDown5.Value; try { using (CWMEntities cwm = new CWMEntities(EnCon)) { cwm.AddToPRICELIST(p1); cwm.AddToPRICELIST(p2); cwm.AddToPRICELIST(p3); cwm.AddToPRICELIST(p4); cwm.AddToPRICELIST(p5); cwm.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Ошибка при добавлении услуги!", ex.Message); return; } MessageBox.Show("Услуга успешно добавлена"); Close(); }
public EditEmp(int id) { InitializeComponent(); using (CWMEntities cwm = new CWMEntities(EnCon)) { var r = (from p in cwm.EMPLOYEE where p.ID == id select p).First(); textBox1.Text = ((EMPLOYEE)r).ENAME; emp = new EMPLOYEE(); emp.ID = ((EMPLOYEE)r).ID; emp.ENAME = ((EMPLOYEE)r).ENAME; } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Введите название автомобиля!"); return; } CAR e1 = new CAR(); e1.CNAME = textBox1.Text; if (radioButton1.Checked) { e1.IDCLASS = 1; } if (radioButton2.Checked) { e1.IDCLASS = 2; } if (radioButton3.Checked) { e1.IDCLASS = 3; } if (radioButton4.Checked) { e1.IDCLASS = 4; } if (radioButton5.Checked) { e1.IDCLASS = 5; } try { using (CWMEntities cwm = new CWMEntities(EnCon)) { cwm.AddToCAR(e1); cwm.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Ошибка при добавлении автомобиля!", ex.Message); return; } MessageBox.Show("Автомобиль успешно добавлен!"); Close(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Введите название автомобиля!"); return; } try { using (CWMEntities cwm = new CWMEntities(EnCon)) { CAR e1; e1 = (CAR)(from t in cwm.CAR where t.ID == car.ID select t).First(); if (radioButton1.Checked) { e1.IDCLASS = 1; } if (radioButton2.Checked) { e1.IDCLASS = 2; } if (radioButton3.Checked) { e1.IDCLASS = 3; } if (radioButton4.Checked) { e1.IDCLASS = 4; } if (radioButton5.Checked) { e1.IDCLASS = 5; } e1.CNAME = textBox1.Text; cwm.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Ошибка при редактировании автомобиля!", ex.Message); return; } MessageBox.Show("Автомобиль успешно изменен!"); Close(); }
public EditPrice(string pn) { InitializeComponent(); using (CWMEntities cwm = new CWMEntities(EnCon)) { var r = from p in cwm.PRICELIST where p.PNAME == pn select p; foreach (PRICELIST pr in r) { if (pr.IDCLASS == 1) { numericUpDown1.Value = pr.COST; pr1 = pr; } if (pr.IDCLASS == 2) { numericUpDown2.Value = pr.COST; pr2 = pr; } if (pr.IDCLASS == 3) { numericUpDown3.Value = pr.COST; pr3 = pr; } if (pr.IDCLASS == 4) { numericUpDown4.Value = pr.COST; pr4 = pr; } if (pr.IDCLASS == 5) { numericUpDown5.Value = pr.COST; pr5 = pr; } } textBox1.Text = pr1.PNAME; } }
private void button3_Click(object sender, EventArgs e) { int id = (int)dwgEmp.SelectedRows[0].Cells["id"].Value; try { using (CWMEntities cwm = new CWMEntities(EnCon)) { EMPLOYEE e1; e1 = (EMPLOYEE)(from t in cwm.EMPLOYEE where t.ID == id select t).First(); e1.DELETED = true; cwm.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Ошибка при редактировании сотрудника!", ex.Message); return; } Employee_Load(this, new EventArgs()); MessageBox.Show("Сотрудник успешно удален!"); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Ведите наименование услуги!"); return; } pr1.PNAME = textBox1.Text; pr1.COST = (int)numericUpDown1.Value; pr2.PNAME = textBox1.Text; pr2.COST = (int)numericUpDown2.Value; pr3.PNAME = textBox1.Text; pr3.COST = (int)numericUpDown3.Value; pr4.PNAME = textBox1.Text; pr4.COST = (int)numericUpDown4.Value; pr5.PNAME = textBox1.Text; pr5.COST = (int)numericUpDown5.Value; try { using (CWMEntities cwm = new CWMEntities(EnCon)) { PRICELIST p1; PRICELIST p2; PRICELIST p3; PRICELIST p4; PRICELIST p5; p1 = (PRICELIST)(from t in cwm.PRICELIST where t.ID == pr1.ID select t).First(); p1.PNAME = pr1.PNAME; p1.COST = pr1.COST; p2 = (PRICELIST)(from t in cwm.PRICELIST where t.ID == pr2.ID select t).First(); p2.PNAME = pr2.PNAME; p2.COST = pr2.COST; p3 = (PRICELIST)(from t in cwm.PRICELIST where t.ID == pr3.ID select t).First(); p3.PNAME = pr3.PNAME; p3.COST = pr3.COST; p4 = (PRICELIST)(from t in cwm.PRICELIST where t.ID == pr4.ID select t).First(); p4.PNAME = pr4.PNAME; p4.COST = pr4.COST; p5 = (PRICELIST)(from t in cwm.PRICELIST where t.ID == pr5.ID select t).First(); p5.PNAME = pr5.PNAME; p5.COST = pr5.COST; cwm.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Ошибка при редактировании услуги!", ex.Message); return; } MessageBox.Show("Услуга успешно изменена!"); Close(); }