Дипломная работа: Автоматизация процесса приема техники на ремонтные работы в ООО "Сервисный центр Samsung"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
91
var q = (from a in db.Detal
where a.naim_det == Convert.ToString(cellval)
select a).SingleOrDefault();
try
{
db.Detal.DeleteOnSubmit(q);
db.SubmitChanges();
}
catch (Exception ex)
{
throw ex;
}
ViewDet();
}
}
//нажатие кнопки отмена
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
//событие при изменении выбора ячейки
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
try
{
cellval = Convert.ToString(dataGridView1[1,
dataGridView1.CurrentRow.Index].Value);
textBox2.Text = Convert.ToString(dataGridView1[4,
dataGridView1.CurrentRow.Index].Value);
textBox3.Text = Convert.ToString(dataGridView1[5,
dataGridView1.CurrentRow.Index].Value);
textBox4.Text = Convert.ToString(dataGridView1[1,
dataGridView1.CurrentRow.Index].Value);
comboBox1.Text = Convert.ToString(dataGridView1[2,
dataGridView1.CurrentRow.Index].Value);
numericUpDown1.Value = Convert.ToInt32(dataGridView1[3,
dataGridView1.CurrentRow.Index].Value);
numericUpDown2.Value = Convert.ToInt32(dataGridView1[6,
dataGridView1.CurrentRow.Index].Value);
}
catch (Exception ex)
{
throw ex;
}
}
//добавление номера записи
private void dataGridView1_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 0)
{
e.Value = e.RowIndex + 1;
}
}
//закрытие формы
private void Det_FormClosing(object sender, FormClosingEventArgs e)
{
instance = null;
}
92
//загрузка формы
private void Det_Load(object sender, EventArgs e)
{
DataClasses1DataContext db = new DataClasses1DataContext();
this.comboBox1.DataSource = from a in db.GDetal
select new
{
pID = a.id_gdet,
pName = a.naim_gdet
};
this.comboBox1.DisplayMember = "pName";
this.comboBox1.ValueMember = "pID";
this.comboBox1.Text = "";
ViewDet();
}
}
}
DU.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SRemont
{
public partial class DU : Form
{
private static DU instance = null;
private int nz;
public DU()
{
InitializeComponent();
}
//запрет вызова второй копии окна
public static DU GetInstance()
{
if (instance == null)
instance = new DU();
return instance;
}
//нажатие кнопки ок
private void button1_Click(object sender, EventArgs e)
{
DataClasses1DataContext db = new DataClasses1DataContext();
try
{
ZakRab item = new ZakRab();
item.id_zak = nz;
item.id_rab = Convert.ToInt32(comboBox1.SelectedValue);
db.ZakRab.InsertOnSubmit(item);
db.SubmitChanges();
Form1.SelfRef.GetRab();
Form1.SelfRef.ViewData();
93
this.Close();
}
catch (Exception ex)
{
throw ex;
}
}
//нажатие кнопки отмена
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
//получение номера заказа
public void DobD(int n)
{
nz = n;
}
//закрытие формы
private void DU_FormClosing(object sender, FormClosingEventArgs e)
{
instance = null;
}
//закгрузка формы
private void DU_Load(object sender, EventArgs e)
{
DataClasses1DataContext db = new DataClasses1DataContext();
this.comboBox1.DataSource = from a in db.Rabota
select new
{
pID = a.id_rab,
pName = a.naim_rab
};
this.comboBox1.DisplayMember = "pName";
this.comboBox1.ValueMember = "pID";
this.comboBox1.Text = "";
}
}
}
GT.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SRemont
{
public partial class GT : Form
{
private static GT instance = null;
private string cellval; //значение столбца1, выбранной строки
94
public GT()
{
InitializeComponent();
}
//запрет вызова второй копии окна
public static GT GetInstance()
{
if (instance == null)
instance = new GT();
return instance;
}
//построение сетки
public void ViewGT()
{
DataClasses1DataContext db = new DataClasses1DataContext();
var q = from a in db.GDetal
select a;
dataGridView1.DataSource = q;
textBox1.Text = "";
}
//нажатие кнопки добавить
private void button1_Click(object sender, EventArgs e)
{
DataClasses1DataContext db = new DataClasses1DataContext();
try
{
bool b = true;
if (textBox1.Text != "")
{
foreach (var v in db.GDetal)
{
if (v.naim_gdet == textBox1.Text) b = false;
}
if (b)
{
GDetal item = new GDetal();
item.naim_gdet = textBox1.Text;
db.GDetal.InsertOnSubmit(item);
db.SubmitChanges();
ViewGT();
}
else MessageBox.Show
("Повторный ввод данных", "Ошибка");
}
else MessageBox.Show
("Введите данные для добавления", "Ошибка");
}
catch (Exception ex)
{
throw ex;
}
}
//нажатие кнопки изменить
private void button2_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show(
"Изменить данные о группе товаров: " + cellval + " ?",
"Изменение записи", MessageBoxButtons.OKCancel);
if (result == DialogResult.OK)
{
95
DataClasses1DataContext db = new DataClasses1DataContext();
var q = (from a in db.GDetal
where a.naim_gdet == Convert.ToString(cellval)
select a).SingleOrDefault();
try
{
if (textBox1.Text != "")
{
q.naim_gdet = textBox1.Text;
db.SubmitChanges();
ViewGT();
}
else MessageBox.Show("Введите название группы товаров", "Ошибка");
}
catch (Exception ex)
{
throw ex;
}
}
}
//нажатие кнопки удалить
private void button3_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show(
"Удалить группу товаров: " + cellval + " ?",
"Удаление записи", MessageBoxButtons.OKCancel);
if (result == DialogResult.OK)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var q = (from a in db.GDetal
where a.naim_gdet == Convert.ToString(cellval)
select a).SingleOrDefault();
try
{
db.GDetal.DeleteOnSubmit(q);
db.SubmitChanges();
}
catch (Exception ex)
{
throw ex;
}
ViewGT();
}
}
//нажатие кнопки отмена
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
//событие при изменении выбора ячейки
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
try
{
cellval = Convert.ToString(dataGridView1[1,
dataGridView1.CurrentRow.Index].Value);
textBox1.Text = Convert.ToString(dataGridView1[1,
dataGridView1.CurrentRow.Index].Value);
}
catch (Exception ex)
Источник: https://baza.diplomsite.ru/previewfile/2121