-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShowCheckForm.cs
123 lines (106 loc) · 3.83 KB
/
ShowCheckForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace FireEquipment2
{
public partial class ShowCheckForm : Form
{
public int curDepartment;
public bool isManager;
public string desc;
private int CurId;
public ShowCheckForm()
{
InitializeComponent();
}
private void ShowCheckForm_Load(object sender, EventArgs e)
{
this.Text += curDepartment;
CommonFunction.ClearDgv(dgvCheck);
dgvCheck.DataSource = CommonFunction.SelectChechData(curDepartment);
CurId = CommonFunction.GetLastIdCheck() + 1;
if (isManager)
{
this.btnPrintDocument.Text = "Просмотр отчёта";
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
AddCheckForm addForm = new AddCheckForm
{
Text = "Добавление проверки к отделу №" + curDepartment,
isInsert = true,
};
addForm.tbId.Text = CurId.ToString();
addForm.tbDepartment.Text = curDepartment.ToString();
addForm.ShowDialog();
CommonFunction.ClearDgv(dgvCheck);
CurId = CommonFunction.GetLastIdCheck() + 1;
dgvCheck.DataSource = CommonFunction.SelectChechData(curDepartment);
}
private void btnUpdate_Click(object sender, EventArgs e)
{
var index = dgvCheck.CurrentCell.RowIndex;
try
{
AddCheckForm addForm = new AddCheckForm
{
Text = "Изменение проверки отдела №" + curDepartment,
isInsert = false,
};
addForm.tbId.Text = dgvCheck[0, index].Value.ToString();
addForm._type = dgvCheck[1, index].Value.ToString();
addForm.tbCheckDate.Text = DateTime.Parse(dgvCheck[2, index]
.Value.ToString()).ToString("yyyy-MM-dd");
addForm.tbDepartment.Text = dgvCheck[3, index].Value.ToString();
addForm.tbResult.Text = dgvCheck[4, index].Value.ToString();
addForm.tbDesc.Text = dgvCheck[5, index].Value.ToString();
addForm.ShowDialog();
CommonFunction.ClearDgv(dgvCheck);
dgvCheck.DataSource = CommonFunction.SelectChechData(curDepartment);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void ShowCheckForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (isManager)
{
MainManagerForm mainAdmin = new MainManagerForm();
mainAdmin.Show();
}
else
{
MainUserForm mainUser = new MainUserForm()
{
department = curDepartment,
Desc = desc,
};
mainUser.Show();
}
}
private void PrintDocument_Click(object sender, EventArgs e)
{
if (isManager)
{
try
{
Process process = new Process();
process.StartInfo.FileName = Manager.GetCheckPath(curDepartment);
process.StartInfo.Verb = "open";
process.Start();
}
catch (Exception)
{
MessageBox.Show("Документ не сформирован!");
}
}
else
{
Respondent.PrintCheckDocument(curDepartment, dgvCheck);
}
}
}
}