1
| using System;
|
2
| using System.IO;
|
3
| using System.Collections.Generic;
|
4
| using System.Data.SqlClient;
|
5
| using System.Drawing;
|
6
| using System.Windows.Forms;
|
7
| using System.Text;
|
8
|
|
9
| namespace testWork
|
10
| {
|
11
| public partial class Menu_men : Form
|
12
| {
|
13
| SqlConnection sqlConn;
|
14
| bool dostoop = true;
|
15
| int brigade = 0;
|
16
| public Menu_men(bool dostoop, int brigade)
|
17
| {
|
18
| InitializeComponent();
|
19
|
|
20
| this.dostoop = dostoop;
|
21
|
|
22
| this.brigade = brigade;
|
23
| }
|
24
|
|
25
|
|
26
|
|
27
| private async void Menu_men_Load_1(object sender, EventArgs e)
|
28
| {
|
29
| string ConnStr = @"Data Source=62.63.74.62,1433;Initial Catalog=testWork;User ID=work;Password=0303";//строка подключения
|
30
|
|
31
|
|
32
| sqlConn = new SqlConnection(ConnStr);
|
33
|
|
34
| await sqlConn.OpenAsync();
|
35
|
|
36
| R_update_tasks();
|
37
| R_update_employee();
|
38
|
|
39
| CheckBtnActivity1();
|
40
| CheckBtnActivity2();
|
41
|
|
42
| if (!dostoop)//скрытие элементов для обычных сотрудников
|
43
| {
|
44
| add_task.Visible = false;
|
45
| add_employee.Visible = false;
|
46
|
|
47
| ybrati1.Visible = false;
|
48
| ybrati2.Visible = false;
|
49
|
|
50
| update_task.Visible = false;
|
51
| update_employee.Visible = false;
|
52
| }
|
53
|
|
54
|
|
55
| }
|
56
| private void Menu_men_Closing(object sender, FormClosingEventArgs e)
|
57
| {
|
58
| Application.Exit();
|
59
| }
|
60
|
|
61
| //task
|
62
|
|
63
| public void R_update_tasks()
|
64
| {
|
65
| listView1.Items.Clear();//очишаем таблицу
|
66
|
|
67
|
|
68
| SqlDataReader sqlRead = null;//перемеена для хранение вывода запроса
|
69
|
|
70
| SqlCommand comend = new SqlCommand();//перемеена для хранение запроса
|
71
|
|
72
|
|
73
|
|
74
| string comond = "SELECT " +
|
75
| "[tasks].[id] AS id_ta," +
|
76
| " [industry], " +
|
77
| "[tasks].[name] AS na_ta," +
|
78
| " [brigade].[name] AS na_br " +
|
79
| "FROM [tasks], [brigade]" +
|
80
| " WHERE [tasks].[brigade] = [brigade].[id] ";
|
81
|
|
82
| if (!dostoop)
|
83
| comond += "AND [tasks].[brigade] = @brigade";
|
84
|
|
85
| comend = new SqlCommand(comond, sqlConn);
|
86
|
|
87
| if (!dostoop)
|
88
| comend.Parameters.AddWithValue("@brigade", brigade);
|
89
|
|
90
|
|
91
| if (sqlRead != null)
|
92
| sqlRead.Close();//проверка на откратасть
|
93
|
|
94
| try
|
95
| {
|
96
| sqlRead = comend.ExecuteReader();//создаем запрос
|
97
|
|
98
|
|
99
| while (sqlRead.Read())
|
100
| {
|
101
| listView1.Items.Add
|
102
| (new ListViewItem(new string[]
|
103
| {
|
104
| Convert.ToString(sqlRead["id_ta"]),
|
105
| Convert.ToString(sqlRead["industry"]),
|
106
| Convert.ToString(sqlRead["na_ta"]),
|
107
| Convert.ToString(sqlRead["na_br"])
|
108
|
|
109
| })//водим результат в таблицу
|
110
| );
|
111
|
|
112
| }
|