-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContractOutCenter_f.cs
371 lines (301 loc) · 13.4 KB
/
ContractOutCenter_f.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
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;
using System.Data.SqlClient;
using DLibraryUtils;
namespace PIHO_DENTIST_SOFTWARE
{
public partial class ContractOutCenter_f : Form
{
public DLibraryUtils.DLUtils DLUtilsobj;
dentistryEntities dentistryEntitiescontext;
int str1 = 0;
public int usercodexml;
bool status1;
public ContractOutCenter_f()
{
InitializeComponent();
}
private bool loaddata()
{
DLUtilsobj.ContractoutCenterobj.selectContractoutCenter();
SqlDataReader DataSource;
DLUtilsobj.ContractoutCenterobj.Dbconnset(true);
DataSource = DLUtilsobj.ContractoutCenterobj.ContractoutCenterclientdataset.ExecuteReader();
radGridView1.DataSource = DataSource;
DLUtilsobj.ContractoutCenterobj.Dbconnset(false);
if (radGridView1.RowCount>0)
{
radGridView1.Columns[0].HeaderText = "کد ";
radGridView1.Columns[1].HeaderText = "نام مرکز";
radGridView1.Columns[2].HeaderText = "نوع";
radGridView1.Columns[3].HeaderText = "نوع مرکز";
radGridView1.Columns[4].HeaderText = "تاریخ شروع قرارداد";
radGridView1.Columns[5].HeaderText = "تاریخ اتمام قرارداد";
radGridView1.Columns[6].HeaderText = "وضعیت";
}
return true;
}
private void ContractOutCenter_f_Load(object sender, EventArgs e)
{
dentistryEntitiescontext = new dentistryEntities();
DLUtilsobj = new DLibraryUtils.DLUtils();
Department_comboBox.DisplayMember = "departmentDesc";
Department_comboBox.ValueMember = "OutCenterDepartmentCode";
Kind_comboBox.DisplayMember = "kindDesc";
Kind_comboBox.ValueMember = "outcenterKindCode";
Department_comboBox.DataSource = dentistryEntitiescontext.OutCenterdepartments.ToList();
Kind_comboBox.DataSource = dentistryEntitiescontext.outcenterKinds.ToList();
Kind_comboBox.SelectedIndex = 0;
Department_comboBox.SelectedIndex = 0;
status_comboBox.SelectedIndex = 0;
loaddata();
}
private void Button_Click(object sender, EventArgs e)
{
if (panel2.Enabled == true)
{
panel2.Enabled = false;
edit_Button.Enabled = true;
Del_Button.Enabled = true;
Ins_Button.Enabled = true;
radGridView1.Enabled = true;
str1 = 0;
//***************
name_textBox.Text = "";
Kind_comboBox.SelectedIndex = 0;
Department_comboBox.SelectedIndex = 0;
//******************
}
}
private void Button_Click_1(object sender, EventArgs e)
{
if (radGridView1.RowCount > 0)
{
int a = int.Parse(radGridView1.CurrentRow.Cells[0].Value.ToString());
if (MessageBox.Show("آیا مطمئن به حذف رکورد انتخابی هستید؟", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
DLUtilsobj.ContractoutCenterobj.deleteContractoutCenter(a);
DLUtilsobj.EventsLogobj.insertEventsLog(usercodexml.ToString(), DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(), 14, Environment.MachineName,a);
//***************************
loaddata();
}
}
}
private void Button_Click_2(object sender, EventArgs e)
{
if (panel2.Enabled == false)
{
panel2.Enabled = true;
cancel_button.Enabled = true;
name_textBox.Focus();
edit_Button.Enabled = false;
Del_Button.Enabled = false;
}
else if (panel2.Enabled == true)
{
//error cheking.................
if (name_textBox.Text == " ")
{
MessageBox.Show("لطفا نام مرکز را وارد نمائید", "خطا", MessageBoxButtons.OK);
}
else
{
dateTimePicker1.Value = persianDateTimePicker1.Value;
dateTimePicker2.Value = persianDateTimePicker2.Value;
if (status_comboBox.SelectedIndex == 0)
{
status1 = true;
}
else
{
status1 = false;
}
outcenter outcentertable = new outcenter
{
outcenterName = name_textBox.Text,
outcenterKind = byte.Parse(Kind_comboBox.SelectedValue.ToString()),
Status = status1,
OutCenterdepartment =byte.Parse(Department_comboBox.SelectedValue.ToString()),
beginDate = persianDateTimePicker1.Value.ToString("yyyy/MM/dd"),
beginDate_Eng=dateTimePicker1.Value,
Enddate = persianDateTimePicker2.Value.ToString("yyyy/MM/dd"),
Enddate_Eng= dateTimePicker2.Value,
usercode = usercodexml,
adress = textBox1.Text,
phone = textBox2.Text,
Comment = textBox3.Text,
outcenternamePrint = textBox4.Text
};
dentistryEntitiescontext.outcenters.Add(outcentertable);
dentistryEntitiescontext.SaveChanges();
MessageBox.Show("اطلاعات مورد نظر ثبت گردید", "Information", MessageBoxButtons.OK);
DLUtilsobj.EventsLogobj.insertEventsLog(usercodexml.ToString(), DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(), 12, Environment.MachineName,0);
//***************
name_textBox.Text = "";
Kind_comboBox.SelectedIndex = 0;
Department_comboBox.SelectedIndex = 0;
//******************
edit_Button.Enabled = true;
Del_Button.Enabled = true;
panel2.Enabled = false;
//******************
loaddata();
//***************************
}
}
}
private void Button_Click_3(object sender, EventArgs e)
{
if (radGridView1.RowCount > 0)
{
Del_Button.Enabled = false;
Ins_Button.Enabled = false;
radGridView1.Enabled = false;
cancel_button.Enabled = true;
int a = int.Parse(radGridView1.CurrentRow.Cells[0].Value.ToString());
outcenter outcentertable = dentistryEntitiescontext.outcenters.First(i => i.outcenterCode == a);
str1 = str1 + 1;
if ((panel2.Enabled == false) && (str1 % 2 != 0))
{
panel2.Enabled = true;
name_textBox.Text = outcentertable.outcenterName;
Kind_comboBox.SelectedValue = outcentertable.outcenterKind.Value;
Department_comboBox.SelectedValue = outcentertable.OutCenterdepartment.Value;
dateTimePicker1.Value = outcentertable.beginDate_Eng.Value;
dateTimePicker2.Value = outcentertable.Enddate_Eng.Value;
persianDateTimePicker1.Value = dateTimePicker1.Value;
persianDateTimePicker2.Value = dateTimePicker2.Value;
textBox1.Text = outcentertable.adress;
textBox2.Text = outcentertable.phone;
textBox3.Text = outcentertable.Comment;
textBox4.Text = outcentertable.outcenternamePrint;
if (outcentertable.Status == true)
{
status_comboBox.SelectedIndex = 0;
}
else
{
status_comboBox.SelectedIndex = 1;
}
}
if ((panel2.Enabled == true) && (str1 % 2 == 0))
{
if (MessageBox.Show("اطلاعات مورد نظر ثبت گردد؟", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (status_comboBox.SelectedIndex == 0)
{
status1 = true;
}
else
{
status1 = false;
}
outcentertable.outcenterName = name_textBox.Text;
outcentertable.outcenterKind = byte.Parse(Kind_comboBox.SelectedValue.ToString());
outcentertable.Status = status1;
outcentertable.OutCenterdepartment = byte.Parse(Department_comboBox.SelectedValue.ToString());
outcentertable.beginDate = persianDateTimePicker1.Value.ToString("yyyy/MM/dd");
outcentertable.beginDate_Eng = dateTimePicker1.Value;
outcentertable.Enddate = persianDateTimePicker2.Value.ToString("yyyy/MM/dd");
outcentertable.Enddate_Eng = persianDateTimePicker2.Value;
outcentertable.usercode = usercodexml;
outcentertable.adress = textBox1.Text;
outcentertable.phone = textBox2.Text;
outcentertable.Comment = textBox3.Text;
outcentertable.outcenternamePrint = textBox4.Text;
dentistryEntitiescontext.SaveChanges();
str1 = 0;
DLUtilsobj.EventsLogobj.insertEventsLog(usercodexml.ToString(), DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(), 13, Environment.MachineName, 0);
//***************************
loaddata();
//***************************
//***************
name_textBox.Text = "";
Kind_comboBox.SelectedIndex = 0;
Department_comboBox.SelectedIndex = 0;
//******************
Del_Button.Enabled = true;
Ins_Button.Enabled = true;
radGridView1.Enabled = true;
cancel_button.Enabled = false;
}
}
}
}
private void ContractOutCenter_f_FormClosing(object sender, FormClosingEventArgs e)
{
dentistryEntitiescontext.Dispose();
this.Dispose();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
//Ins_Button_Click(toolStripMenuItem1, e);
Button_Click_2(toolStripMenuItem1, e);
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
//edit_Button_Click_1(toolStripMenuItem2, e);
Button_Click_3(toolStripMenuItem2, e);
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
//Del_Button_Click(toolStripMenuItem3, e);
Button_Click_1(toolStripMenuItem3, e);
}
private void persianDateTimePicker2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void name_textBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void Kind_comboBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void status_comboBox_KeyDown(object sender, KeyEventArgs e)
{
}
private void Department_comboBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void persianDateTimePicker1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void name_textBox_Leave(object sender, EventArgs e)
{
textBox4.Text = name_textBox.Text;
}
}
}