-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clinics_f.cs
286 lines (223 loc) · 9.89 KB
/
Clinics_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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Forms;
using System.Data.SqlClient;
using DLibraryUtils;
namespace PIHO_DENTIST_SOFTWARE
{
public partial class Clinics_f : Form
{
int str1 = 0;
public int usercodexml;
public DLibraryUtils.DLUtils DLUtilsobj;
public Clinics_f()
{
InitializeComponent();
}
dentistryEntities database = new dentistryEntities();
ClinicType currentclinictype = new ClinicType();
private void Clinics_f_Load(object sender, EventArgs e)
{
DLUtilsobj = new DLibraryUtils.DLUtils();
ClinicType_combobox.DisplayMember = "ClinictypeName";
ClinicType_combobox.ValueMember = "ClinicTypecode";
ClinicType_combobox.DataSource = database.ClinicTypes.ToList();
radGridView1.DataSource = database.Clinics.Where(p => p.deleted == false).ToList();
radGridView1.Columns[0].HeaderText = "کد کلینیک";
radGridView1.Columns[1].HeaderText = "نام کلینیک";
radGridView1.Columns[2].HeaderText = "نام بخش";
radGridView1.Columns[3].HeaderText = "شماره اطاق";
radGridView1.Columns[4].IsVisible = false;
radGridView1.Columns[5].IsVisible = false;
radGridView1.Columns[6].IsVisible = false;
radGridView1.Columns[7].IsVisible = false;
ClinicType_combobox.SelectedIndex = 0;
}
private void Ins_Button_Click(object sender, EventArgs e)
{
if (panel2.Enabled==false)
{
panel2.Enabled = true;
cancel_button.Enabled = true;
Clinicname_textbox.Focus();
edit_Button.Enabled = false;
Del_Button.Enabled = false;
}
else if (panel2.Enabled==true)
{
//error cheking.................
if (Clinicname_textbox.Text.ToString() == "")
{
MessageBox.Show("لطفا نام کلینیک را وارد نمائید", "خطا", MessageBoxButtons.OK);
}
else {
Clinic clinictable = new Clinic
{
ClinicName=Clinicname_textbox.Text,
Depatrment=Department_textBox.Text,
RoomNO=RoomNO_textbox.Text,
ClinicType=byte.Parse(ClinicType_combobox.SelectedValue.ToString()),
Comment=Comment_textBox.Text ,
deleted= false
};
database.Clinics.Add(clinictable);
database.SaveChanges();
MessageBox.Show("اطلاعات مورد نظر ثبت گردید", "Information", MessageBoxButtons.OK);
DLUtilsobj.EventsLogobj.insertEventsLog(usercodexml.ToString(), DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(), 6, Environment.MachineName,0);
panel2.Enabled = false;
cancel_button.Enabled = false;
edit_Button.Enabled = true;
Del_Button.Enabled = true;
Clinicname_textbox.Text="";
Department_textBox.Text="";
RoomNO_textbox.Text="";
Comment_textBox.Text = "";
ClinicType_combobox.SelectedIndex = 0;
radGridView1.DataSource = database.Clinics.ToList();
}
}
}
private void Del_Button_Click(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)
{
//if در planvst تعریف نشده بود قابل حذف می باشد.
DLUtilsobj = new DLibraryUtils.DLUtils();
if ((DLUtilsobj.planvisitobj.selectclinicinplanvisit("cliniccode", "cliniccode= " + a.ToString())) == false)
{
DLUtilsobj.clinicsobj.deleteClinic(a);
DLUtilsobj.EventsLogobj.insertEventsLog(usercodexml.ToString(), DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(), 8, Environment.MachineName,a);
radGridView1.DataSource = database.Clinics.ToList();
}
else
MessageBox.Show("شما مجاز به حذف این کلینیک نمی باشید", "information", MessageBoxButtons.OK);
}
}
}
private void Clinicname_textbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void Department_textBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void RoomNO_textbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void ClinicTypeName_combobox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void edit_Button_Click_1(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());
Clinic clinictable = database.Clinics.First(i => i.ClinicCode == a);
str1 = str1 + 1;
if ((panel2.Enabled == false) && (str1 % 2 != 0))
{
panel2.Enabled = true;
Clinicname_textbox.Text = clinictable.ClinicName;
Department_textBox.Text = clinictable.Depatrment;
RoomNO_textbox.Text = clinictable.RoomNO;
Comment_textBox.Text = clinictable.Comment;
ClinicType_combobox.SelectedValue = clinictable.ClinicType.Value;
}
if ((panel2.Enabled == true) && (str1 % 2 == 0))
{
if (MessageBox.Show("تغییرات مورد نظر ثبت گردد؟", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
clinictable.ClinicName = Clinicname_textbox.Text;
clinictable.Depatrment = Department_textBox.Text;
clinictable.RoomNO = RoomNO_textbox.Text;
clinictable.ClinicType = byte.Parse(ClinicType_combobox.SelectedValue.ToString());
clinictable.Comment = Comment_textBox.Text;
database.SaveChanges();
DLUtilsobj.EventsLogobj.insertEventsLog(usercodexml.ToString(), DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(), 7, Environment.MachineName, a);
radGridView1.DataSource = database.Clinics.ToList();
Del_Button.Enabled = true;
Ins_Button.Enabled = true;
radGridView1.Enabled = true;
panel2.Enabled = false;
cancel_button.Enabled = false;
Clinicname_textbox.Text = "";
Department_textBox.Text = "";
RoomNO_textbox.Text = "";
Comment_textBox.Text = "";
ClinicType_combobox.SelectedIndex = 0;
str1 = 0;
}
}
}
}
private void cancel_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;
Clinicname_textbox.Text = "";
Department_textBox.Text = "";
RoomNO_textbox.Text = "";
Comment_textBox.Text = "";
ClinicType_combobox.SelectedIndex = 0;
radGridView1.Enabled = true;
str1 = 0;
}
}
private void Clinics_f_FormClosing(object sender, FormClosingEventArgs e)
{
database.Dispose();
this.Dispose();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
Ins_Button_Click(toolStripMenuItem1, e);
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
edit_Button_Click_1(toolStripMenuItem2, e);
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
Del_Button_Click(toolStripMenuItem3, e);
}
private void ClinicType_combobox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
}
}