-
Notifications
You must be signed in to change notification settings - Fork 0
/
Projects.cs
225 lines (180 loc) · 6.89 KB
/
Projects.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
using System.Data.SqlClient;
using System.Data;
namespace Cet301_ProjectManagement
{
public partial class Projects : Form
{
public Projects()
{
InitializeComponent();
displacingProjectss();
}
// sql connection
public string connString = "Data Source=DESKTOP-HQGO42H\\SQLEXPRESS01;Initial Catalog=ProjectManagement;Integrated Security=True;Encrypt=False";
SqlConnection conn = new SqlConnection();
//bu kod bloðu data gitme kod bloðunun üstündedir çünkü
public void displacingProjectss()
{
try
{
//mssqlden data çekme
conn.Open();
string query = "select * from Project";
SqlDataAdapter adapter = new SqlDataAdapter(query, conn);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
var dataset = new DataSet();
adapter.Fill(dataset);
dataGridView1.DataSource = dataset.Tables[0];
conn.Close();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
private void Form1_Load(object sender, EventArgs e)
{
pnlAddition.Enabled = false;
panel3.Enabled = false;
string query = "select EmployeeName from Employee";
conn.Open();
SqlCommand command = new SqlCommand(query, conn);
SqlDataReader reader = command.ExecuteReader();
cmbPersonnel.Items.Add(reader.GetString(0));
cmbPersonnel.Items.Add(reader.GetString(1));
string q1 = "select JobDesc from Employee";
conn.Open();
SqlCommand cmd = new SqlCommand(q1, conn);
SqlDataReader rdr = cmd.ExecuteReader();
cmbPartners.Items.Add(rdr.GetString(0));
cmbPartners.Items.Add(rdr.GetString(1));
conn.Close();
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void btnProjects_Click(object sender, EventArgs e)
{
btnProjects.BackColor = SystemColors.ControlLightLight;
}
private void btnProjects_MouseHover(object sender, EventArgs e)
{
btnProjects.BackColor = Color.BlueViolet;
}
private void btnTasks_Click(object sender, EventArgs e)
{
btnTasks.BackColor = SystemColors.ControlLightLight;
Tasks tasks = new Tasks();
tasks.Show();
this.Hide();
}
private void btnTasks_MouseHover(object sender, EventArgs e)
{
btnTasks.BackColor = Color.BlueViolet;
}
private void btnTasks_MouseLeave(object sender, EventArgs e)
{
btnTasks.BackColor = Color.FromArgb(123, 49, 245);
}
private void btnUsers_Click(object sender, EventArgs e)
{
btnUsers.BackColor = SystemColors.ControlLightLight;
Members users = new Members();
users.Show();
this.Hide();
}
private void btnUsers_MouseHover(object sender, EventArgs e)
{
btnUsers.BackColor = Color.BlueViolet;
}
private void btnUsers_MouseLeave(object sender, EventArgs e)
{
btnUsers.BackColor = Color.FromArgb(123, 49, 245);
}
private void btnCalendar_Click(object sender, EventArgs e)
{
btnCalendar.BackColor = SystemColors.ControlLightLight;
Calender calender = new Calender();
calender.Show();
this.Hide();
}
private void btnCalendar_MouseHover(object sender, EventArgs e)
{
btnCalendar.BackColor = Color.BlueViolet;
}
private void btnCalendar_MouseLeave(object sender, EventArgs e)
{
btnCalendar.BackColor = Color.FromArgb(123, 49, 245);
}
private void btnSettings_Click(object sender, EventArgs e)
{
btnSettings.BackColor = SystemColors.ControlLightLight;
}
private void btnSettings_MouseHover(object sender, EventArgs e)
{
btnSettings.BackColor = Color.BlueViolet;
}
private void btnSettings_MouseLeave(object sender, EventArgs e)
{
btnSettings.BackColor = Color.FromArgb(123, 49, 245);
}
private void btnLogout_Click(object sender, EventArgs e)
{
Giris giris = new Giris();
giris.Show();
this.Hide();
}
private void btnkapat_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnNewAdd_Click(object sender, EventArgs e)
{
pnlAddition.Enabled = true;
panel3.Enabled = true;
projectID++;
}
int projectID = 0;
private void btnAdd1_Click(object sender, EventArgs e)
{
try
{
//using the connecition
conn.Open();
//control id any missing value
if (txtProjectName.Text == "" || txtOwner.Text == "" || dateTimePicker1.Text == "")
{
MessageBox.Show("!! please fill all blanks !!");
}
else
{
try
{
DateTime duedate = dateTimePicker1.Value;
DateTime date = dateTimePicker2.Value;
string name = txtProjectName.Text;
string ownmer = txtOwner.Text;
string query = $"insert into Project (ProjectID, projectName, OwnerName, startDate, dueDate) values('{projectID}', '{name}', '{ownmer}','{date}', '{duedate}' )";
SqlCommand command = new SqlCommand(query, conn);
command.ExecuteNonQuery();
MessageBox.Show("Done");
}
catch (Exception ex) { MessageBox.Show(ex.Message + " 111"); }
}
conn.Close();
}
catch (Exception ex) { MessageBox.Show(ex.Message + " 222"); }
}
private void btnAdd2_Click(object sender, EventArgs e)
{
string job = cmbPartners.Text;
string member = cmbPersonnel.Text;
string q1 = $"select count(*) from Employee where EmployeeName='{member}' AND JobDesc= '{job}'";
SqlCommand command = new SqlCommand(q1, conn);
int match = (int)command.ExecuteScalar();
if(match == 0)
{
string query = "insert into Employee (EmployeeName,JobDesc) values('" + cmbPersonnel + "', '" + cmbPartners + "')";
SqlCommand command2 = new SqlCommand(query, conn);
command2.ExecuteNonQuery();
}
}
}
}