-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmSearchKids.cs
735 lines (545 loc) · 27.9 KB
/
frmSearchKids.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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KIDS_CheckIn_System
{
public partial class frmSearchKids : Form
{
string fetcherImage = "";
Connector js = new Connector();
//Connector2 js2 = new Connector2();
string fldAddressDetails = "";
string fldContactDetails = "";
int fldFetcherID = 0;
string fldNationality = "";
string fldKidsID = "";
string KidsPicture = "";
string [] fetcherID = new string [3];
public frmSearchKids()
{
InitializeComponent();
}
private void cboSearch_SelectedIndexChanged(object sender, EventArgs e)
{
if(cboSearch.Text=="Birth Day")
{
txtSearch.Visible = false;
dtSearch.Visible = true;
txtSearch.Tag = "";
dtSearch.Tag = cboSearch.Text;
}
else
{
txtSearch.Visible = true;
dtSearch.Visible = false;
txtSearch.Tag = cboSearch.Text;
dtSearch.Tag = "";
}
}
private void btnBrowse_Click(object sender, EventArgs e)
{
if(txtLastName.Text == "" && txtLastName.Text =="")
{
MessageBox.Show("Kids First Name and Last Name Required", "Importing Picture", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
openFileDialog1.FilterIndex = 1;
openFileDialog1.Filter = "JPEG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|PNG Files (*.png)|*.png";
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var filename = openFileDialog1.FileName;
//System.IO.File.Copy(filename, Application.StartupPath + "/Pictures/Kids/" + txtFirstName.Text + txtLastName.Text + ".jpg", true);
//pbImage.Image = System.Drawing.Image.FromFile(Application.StartupPath + "/Pictures/Kids/" + txtFirstName.Text + txtLastName.Text + ".jpg");
pbImage.Image = System.Drawing.Image.FromFile(filename);
openFileDialog1.Dispose();
}
}
private void btnBrowse2_Click(object sender, EventArgs e)
{
if (txtFetcherFN.Text == "" && txtFetcherLN.Text == "")
{
MessageBox.Show("Fetcher's First Name and Last Name Required", "Importing Picture", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
openFileDialog2.FilterIndex = 1;
openFileDialog2.Filter = "JPEG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|PNG Files (*.png)|*.png";
if (openFileDialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var filename = openFileDialog2.FileName;
//System.IO.File.Copy(filename, Application.StartupPath + "/Pictures/Fetchers/" + txtFetcherFN.Text + txtFetcherLN.Text + ".jpg", true);
//pbFetcher.Image = System.Drawing.Image.FromFile(Application.StartupPath + "/Pictures/Fetchers/" + txtFetcherFN.Text + txtFetcherLN.Text + ".jpg");
pbFetcher.Image = System.Drawing.Image.FromFile(filename);
openFileDialog2.Dispose();
}
}
private void btnSave_Click(object sender, EventArgs e)
{
if(fldKidsID=="")
{
MessageBox.Show("Cannot Save Empty Record","Check-In Update", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
string aID = SaveUpdateAddressDetails(fldAddressDetails, txtAddress1.Text, txtAddress2.Text, txtCity.Text, txtZipCode.Text);
string cID = SaveUpdateContactDetails(fldContactDetails, txtContactNo.Text);
int GenderID =Convert.ToInt32(js.Lookup("fldID", "tblGender", "fldGender='" + cboGender.Text + "'"));
string NationalityID = js.Lookup("fldID", "tblNationality", "fldNationality='" + cboNationality.Text + "'");
KidsPicture = Application.StartupPath + "/Pictures/Kids/" + txtFirstName.Text + txtLastName.Text + ".jpg";
if(System.IO.File.Exists(KidsPicture))
{
System.IO.File.Delete(KidsPicture);
}
pbImage.Image.Save(Application.StartupPath + "/Pictures/Kids/" + txtFirstName.Text + txtLastName.Text + ".jpg");
string q = "UPDATE tblKids SET fldFirstName='" + txtFirstName.Text + "',fldLastName='" + txtLastName.Text + "'," +
"fldMiddleName='" + txtMiddleName.Text + "',fldNickName='" + txtNickName.Text + "'," +
"fldBirthday='" + dtBirthdate.Value.ToShortDateString() + "',fldAddressDetails='" + aID + "'," +
"fldContactDetails='" + cID + "',fldPicture='" + KidsPicture + "',fldGender='" + GenderID + "'," +
"fldNationality='" + NationalityID + "',fldUpdateStatus='1' WHERE fldID='" + fldKidsID + "'";
js.ExecuteNonQuery(q);
GetFectchers();
tabControl1.SelectTab(1);
for (int i = 0; i <= (fetcherID.Length - 1);i++ )
{
string qry = "SELECT f.*,a.*,r.fldRelationship as Relationship,c.fldContactNumber FROM tblFetcher f " +
" LEFT OUTER JOIN tblAddress a ON a.fldID=f.fldAddressDetails " +
" LEFT OUTER JOIN tblContactDetails c ON c.fldID = f.fldContactDetails " +
" LEFT OUTER JOIN tblRelationship r ON r.fldID = f.fldRelationship" +
" WHERE f.fldID = '" + fetcherID[i] + "'";
js.ExecuteQuery(qry);
js.RiD.Read();
if(js.RiD.HasRows)
{
dgvFetchers.Rows.Add(js.RiD["fldFirstName"], js.RiD["fldLastName"], js.RiD["fldMiddleName"],js.RiD["fldEmail"], js.RiD["Relationship"], js.RiD["fldContactNumber"], js.RiD["fldAddress1"], js.RiD["fldAddress2"], js.RiD["fldCity"], js.RiD["fldZipCode"], js.RiD["fldPicture"]);
}
}
fldKidsID = "";
//MessageBox.Show(fetcherID.Length.ToString());
//MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
private void btnFinish_Click(object sender, EventArgs e)
{
if (dgvFetchers.Rows.Count == 0)
{
MessageBox.Show("No record to save", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (!chkAgree.Checked)
{
MessageBox.Show("You have to check the I agree on the Terms and Condition", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string kidid = js.Lookup("fldID", "tblKids", "fldStudentID='" + lblStudentID.Text + "'");
js.ExecuteNonQuery("DELETE FROM tblKidFetcher WHERE fldKidID='" + kidid + "'");
for(int i=0;i<= (dgvFetchers.Rows.Count -1);i++)
{
string Addr1 = dgvFetchers.Rows[i].Cells["Address1"].Value.ToString();
string Addr2 = dgvFetchers.Rows[i].Cells["Address2"].Value.ToString();
string city = dgvFetchers.Rows[i].Cells["City"].Value.ToString();
string ZipCode = dgvFetchers.Rows[i].Cells["ZipCode"].Value.ToString();
// MessageBox.Show(dgvFetchers.Rows[i].Cells["ZipCode"].Value.ToString());
//return;
string addrID = js.Lookup("fldID", "tblAddress", "fldAddress1='" + Addr1 + "' AND fldAddress2='" + Addr2 + "' AND fldCity='" + city + "' AND fldZipCode='" + ZipCode + "'");
addrID = SaveUpdateAddressDetails(addrID, Addr1, Addr2, city, ZipCode);
string contactno = dgvFetchers.Rows[i].Cells["ContactNo"].Value.ToString();
string cID = js.Lookup("fldID", "tblContactDetails", "fldContactNumber='" + contactno + "'");
cID = SaveUpdateContactDetails(cID, contactno);
string rID = js.Lookup("fldID", "tblRelationship", "fldRelationship='" + dgvFetchers.Rows[i].Cells["Relationship"].Value.ToString() + "'");
string picture = dgvFetchers.Rows[i].Cells["Picture"].Value.ToString();
string q = "";
string FN = dgvFetchers.Rows[i].Cells["FirstName"].Value.ToString();
string LN = dgvFetchers.Rows[i].Cells["LastName"].Value.ToString();
string MN = dgvFetchers.Rows[i].Cells["MiddleName"].Value.ToString();
string Email = dgvFetchers.Rows[i].Cells["Email"].Value.ToString();
string fID = js.Lookup("fldID", "tblFetcher", "fldFirstName='" + FN + "' AND fldLastName='" + LN + "' AND fldMiddleName='" + MN + "'");
//js.ExecuteNonQuery("DELETE FROM tblFetcher WHERE fldID='" + fID + "'");
if (fID != "")
{
q = "UPDATE tblFetcher SET fldFirstName='" + FN + "',fldLastName='" + LN + "',fldMiddleName='" + MN + "',fldAddressDetails='" + addrID + "', fldContactDetails='" + cID + "',fldEmail='" + Email + "',fldRelationship='" + rID + "',fldPicture='" + picture + "' WHERE fldID='" + fID + "'";
}
else
{
q = "INSERT INTO tblFetcher(fldFirstName,fldLastName,fldMiddleName,fldAddressDetails,fldContactDetails,fldRelationship,fldPicture,fldEmail) VALUES('" + FN +
"','" + LN + "','" + MN + "','" + addrID + "','" + cID + "','" + rID + "','" + picture + "','" + Email + "')";
}
js.ExecuteNonQuery(q);
//js2.ExecuteNonQuery(q);
fID = js.Lookup("fldID", "tblFetcher", "fldFirstName='" + FN + "' AND fldLastName='" + LN + "' AND fldMiddleName='" + MN + "'");
if(fID!="")
{
string qry = "INSERT INTO tblKidFetcher(fldKidID,fldFetcherID) VALUES('" + kidid + "','" + fID + "')";
js.ExecuteNonQuery(qry);
//.ExecuteNonQuery(qry);
}
}
MessageBox.Show("Kid & Fetchers Successfully Updated","", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtAddress1.Text = "";
txtAddress2.Text = "";
txtChurch.Text = "";
txtCity.Text = "";
txtContactNo.Text = "";
txtEmail.Text = "";
txtFirstName.Text = "";
txtLastName.Text = "";
txtMiddleName.Text = "";
txtNickName.Text = "";
txtPoints.Text = "";
txtSearch.Text = "";
txtZipCode.Text = "";
cboGender.Text = "";
cboNationality.Text = "";
cboRelationship.Text = "";
lblStudentID.Text = "000000000000";
dgvFetchers.Rows.Clear();
pbFetcher.Image.Dispose();
pbFetcher.Image = Image.FromFile(Application.StartupPath + "/Pictures/download.jpg");
pbImage.Image.Dispose();
pbImage.Image = Image.FromFile(Application.StartupPath + "/Pictures/download.jpg");
tabControl1.SelectTab(0);
}
private void btnBack_Click(object sender, EventArgs e)
{
tabControl1.SelectTab(0);
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (txtFetcherFN.Text == "")
{
MessageBox.Show("Fetcher First Name Required!","", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if(txtFetcherLN.Text =="")
{
MessageBox.Show("Fetcher Last Name Required!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if(txtFetcherContact.Text =="")
{
MessageBox.Show("Fetcher Contact No Required!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if(btnEdit.Tag !=null)
{
int dgvIndex = Convert.ToInt32(btnEdit.Tag);
pbFetcher.Image.Save(Application.StartupPath + "/Pictures/Fetchers/" + txtFetcherFN.Text + txtFetcherLN.Text + ".jpg");
fetcherImage = Application.StartupPath + "/Pictures/Fetchers/" + txtFetcherFN.Text + txtFetcherLN.Text + ".jpg";
dgvFetchers.Rows[dgvIndex].Cells["FirstName"].Value = txtFetcherFN.Text;
dgvFetchers.Rows[dgvIndex].Cells["LastName"].Value = txtFetcherLN.Text;
dgvFetchers.Rows[dgvIndex].Cells["MiddleName"].Value = txtFetcherMN.Text;
dgvFetchers.Rows[dgvIndex].Cells["Relationship"].Value = cboRelationship.Text;
dgvFetchers.Rows[dgvIndex].Cells["ContactNo"].Value = txtFetcherContact.Text;
dgvFetchers.Rows[dgvIndex].Cells["Address1"].Value = txtFetcherAddr1.Text;
dgvFetchers.Rows[dgvIndex].Cells["Address2"].Value = txtFetcherAddr2.Text;
dgvFetchers.Rows[dgvIndex].Cells["City"].Value = txtFetcherCity.Text;
dgvFetchers.Rows[dgvIndex].Cells["ZipCode"].Value = txtFetcherZip.Text;
dgvFetchers.Rows[dgvIndex].Cells["Picture"].Value = fetcherImage;
dgvFetchers.Rows[dgvIndex].Cells["Email"].Value = txtEmail.Text;
btnEdit.Tag = null;
}
else
{
pbFetcher.Image.Save(Application.StartupPath + "/Pictures/Fetchers/" + txtFetcherFN.Text + txtFetcherLN.Text + ".jpg");
fetcherImage = Application.StartupPath + "/Pictures/Fetchers/" + txtFetcherFN.Text + txtFetcherLN.Text + ".jpg";
dgvFetchers.Rows.Add(txtFetcherFN.Text,txtFetcherLN.Text,txtFetcherMN.Text,txtEmail.Text,cboRelationship.Text,txtFetcherContact.Text,txtFetcherAddr1.Text,txtFetcherAddr2.Text,txtFetcherCity.Text,txtFetcherZip.Text,fetcherImage);
}
txtFetcherFN.Text = "";
txtFetcherLN.Text = "";
txtFetcherMN.Text = "";
cboRelationship.Text = "";
txtFetcherContact.Text = "";
txtFetcherAddr1.Text = "";
txtFetcherAddr2.Text = "";
txtFetcherCity.Text = "";
txtFetcherZip.Text = "";
pbFetcher.Image.Dispose();
pbFetcher.Image = System.Drawing.Image.FromFile(Application.StartupPath + "/Pictures/download.jpg");
}
private void btnSearch_Click(object sender, EventArgs e)
{
string qry = "";
if(cboSearch.Text == "First Name")
{
qry = "SELECT k.*,g.fldGender as Gender FROM tblKids k " +
"LEFT OUTER JOIN tblGender g ON g.fldID=k.fldGender" +
" WHERE fldFirstName='" + txtSearch.Text + "'";
}
if(cboSearch.Text == "Last Name")
{
qry = "SELECT k.*,g.fldGender as Gender FROM tblKids k " +
"LEFT OUTER JOIN tblGender g ON g.fldID=k.fldGender" +
" WHERE fldLastName='" + txtSearch.Text + "'";
}
if (cboSearch.Text == "Nick Name")
{
qry = "SELECT k.*,g.fldGender as Gender FROM tblKids k " +
"LEFT OUTER JOIN tblGender g ON g.fldID=k.fldGender" +
" WHERE fldNickName='" + txtSearch.Text + "'";
}
if (cboSearch.Text == "Birth Day")
{
qry = "SELECT k.*,g.fldGender as Gender FROM tblKids k " +
"LEFT OUTER JOIN tblGender g ON g.fldID=k.fldGender" +
" WHERE fldBirthday='" + dtSearch.Value.ToShortDateString() + "'";
}
if (cboSearch.Text == "Barcode")
{
qry = "SELECT k.*,g.fldGender as Gender FROM tblKids k " +
"LEFT OUTER JOIN tblGender g ON g.fldID=k.fldGender" +
" WHERE fldStudentID='" + txtSearch.Text + "'";
string q = qry;
js.ExecuteQuery(q);
js.RiD.Read();
lblStudentID.Text = js.RiD["fldStudentID"].ToString();
txtFirstName.Text = js.RiD["fldFirstName"].ToString();
txtLastName.Text = js.RiD["fldLastName"].ToString();
txtMiddleName.Text = js.RiD["fldMiddleName"].ToString();
txtNickName.Text = js.RiD["fldNickName"].ToString();
dtBirthdate.Value = Convert.ToDateTime(js.RiD["fldBirthday"].ToString());
cboGender.Text = js.RiD["Gender"].ToString();
txtChurch.Text = js.Lookup("fldChurch", "tblChurch", "fldID='" + js.RiD["fldChurch"].ToString() + "'");
fldAddressDetails = js.RiD["fldAddressDetails"].ToString();
fldContactDetails = js.RiD["fldContactDetails"].ToString();
fldNationality = js.RiD["fldNationality"].ToString();
cboNationality.Text = js.Lookup("fldNationality", "tblNationality", "fldID='" + js.RiD["fldNationality"].ToString() + "'");
txtPoints.Text = js.RiD["fldPoints"].ToString();
fldKidsID = js.RiD["fldID"].ToString();
//FOR LOADING PICTURE
string picture = js.RiD["fldPicture"].ToString();
string temppic = Application.StartupPath + "/Pictures/tmp/Kids/tmp1.jpg";
if(System.IO.File.Exists(picture))
{
pbImage.Image.Dispose();
System.IO.File.Copy(picture, temppic,true);
pbImage.Image = System.Drawing.Image.FromFile(temppic);
}
js.CloseConnection();
//For the Address Details
q = "SELECT * FROM tblAddress WHERE fldID='" + fldAddressDetails + "'";
js.ExecuteQuery(q);
js.RiD.Read();
if(js.RiD.HasRows)
{
txtAddress1.Text = js.RiD["fldAddress1"].ToString();
txtAddress2.Text = js.RiD["fldAddress2"].ToString();
txtCity.Text = js.RiD["fldCity"].ToString();
txtZipCode.Text = js.RiD["fldZipCode"].ToString();
}
js.CloseConnection();
//For Contact Details
q = "SELECT * FROM tblContactDetails WHERE fldID='" + fldContactDetails + "'";
js.ExecuteQuery(q);
js.RiD.Read();
if (js.RiD.HasRows)
{
txtContactNo.Text = js.RiD["fldContactNumber"].ToString();
}
js.CloseConnection();
return;
}
//js.searchquery = qry;
frmResults frm = new frmResults();
frm.Tag = qry;
if (frm.ShowDialog()== System.Windows.Forms.DialogResult.OK)
{
string q = frm.Tag.ToString();
js.ExecuteQuery(q);
js.RiD.Read();
lblStudentID.Text = js.RiD["fldStudentID"].ToString();
txtFirstName.Text = js.RiD["fldFirstName"].ToString();
txtLastName.Text = js.RiD["fldLastName"].ToString();
txtMiddleName.Text = js.RiD["fldMiddleName"].ToString();
txtNickName.Text = js.RiD["fldNickName"].ToString();
dtBirthdate.Value = Convert.ToDateTime(js.RiD["fldBirthday"].ToString());
cboGender.Text = js.RiD["Gender"].ToString();
txtChurch.Text = js.Lookup("fldChurch", "tblChurch", "fldID='" + js.RiD["fldChurch"].ToString() + "'");
fldAddressDetails = js.RiD["fldAddressDetails"].ToString();
fldContactDetails = js.RiD["fldContactDetails"].ToString();
fldNationality = js.RiD["fldNationality"].ToString();
cboNationality.Text = js.Lookup("fldNationality", "tblNationality", "fldID='" + js.RiD["fldNationality"].ToString() + "'");
txtPoints.Text = js.RiD["fldPoints"].ToString();
fldKidsID = js.RiD["fldID"].ToString();
//FOR LOADING PICTURE
string picture = js.RiD["fldPicture"].ToString();
string temppic = Application.StartupPath + "/Pictures/tmp/Kids/tmp1.jpg";
if (System.IO.File.Exists(picture))
{
//pbImage.Dispose();
pbImage.Image.Dispose();
System.IO.File.Copy(picture, temppic, true);
pbImage.Image = System.Drawing.Image.FromFile(temppic);
}
js.CloseConnection();
//For the Address Details
q = "SELECT * FROM tblAddress WHERE fldID='" + fldAddressDetails + "'";
js.ExecuteQuery(q);
js.RiD.Read();
if(js.RiD.HasRows)
{
txtAddress1.Text = js.RiD["fldAddress1"].ToString();
txtAddress2.Text = js.RiD["fldAddress2"].ToString();
txtCity.Text = js.RiD["fldCity"].ToString();
txtZipCode.Text = js.RiD["fldZipCode"].ToString();
}
js.CloseConnection();
//For Contact Details
q = "SELECT * FROM tblContactDetails WHERE fldID='" + fldContactDetails + "'";
js.ExecuteQuery(q);
js.RiD.Read();
if (js.RiD.HasRows)
{
txtContactNo.Text = js.RiD["fldContactNumber"].ToString();
}
js.CloseConnection();
}
}
private void frmSearchKids_Load(object sender, EventArgs e)
{
LoadGender();
LoadNationality();
LoadRelationship();
}
private void LoadGender()
{
string q = "SELECT * FROM tblGender";
js.ExecuteQuery(q);
cboGender.Items.Clear();
while(js.RiD.Read())
{
cboGender.Items.Add(js.RiD["fldGender"]);
}
js.CloseConnection();
}
private void LoadNationality()
{
string q = "SELECT * FROM tblNationality";
js.ExecuteQuery(q);
cboNationality.Items.Clear();
while(js.RiD.Read())
{
cboNationality.Items.Add(js.RiD["fldNationality"]);
}
}
private void LoadRelationship()
{
string q = "SELECT * FROM tblRelationship";
js.ExecuteQuery(q);
cboRelationship.Items.Clear();
while(js.RiD.Read())
{
cboRelationship.Items.Add(js.RiD["fldRelationship"]);
}
}
private string SaveUpdateAddressDetails(string fldAddressID,string Address1,string Address2,string City,string ZipCode)
{
//Connector2 js2 = new Connector2();
string qry = "";
string aID = "";
if(fldAddressID=="")
{
qry = "INSERT INTO tblAddress(fldAddress1,fldAddress2,fldCity,fldZipCode) VALUES('" + Address1 + "','" + Address2 + "','" + City + "','" + ZipCode + "')";
js.ExecuteNonQuery(qry);
//js2.ExecuteNonQuery(qry);
aID = js.Lookup("fldID", "tblAddress", "fldAddress1='" + Address1 + "' AND fldAddress2='" + Address2 + "' AND fldCity='" + City + "' AND fldZipCode='" + ZipCode + "'");
}
else
{
qry = "UPDATE tblAddress SET fldAddress1='" + Address1 + "',fldAddress2='" + Address2 + "',fldCity='" + City + "',fldZipCode='" + ZipCode + "' WHERE fldID='" + fldAddressID + "'";
js.ExecuteNonQuery(qry);
//js2.ExecuteNonQuery(qry);
aID = fldAddressID;
}
return aID;
}
private string SaveUpdateContactDetails(string fldContactID,string ContactNo)
{
//Connector2 js2 = new Connector2();
string qry = "";
string cID = "";
if(fldContactID=="")
{
qry = "INSERT INTO tblContactDetails(fldContactNumber) VALUES('" + ContactNo + "')";
js.ExecuteNonQuery(qry);
//js2.ExecuteNonQuery(qry);
cID = js.Lookup("fldID", "tblContactDetails", "fldContactNumber='" + ContactNo + "'");
}
else
{
qry = "UPDATE tblContactDetails SET fldContactNumber='" + ContactNo + "' WHERE fldID='" + fldContactID + "'";
js.ExecuteNonQuery(qry);
//js.ExecuteNonQuery(qry);
cID = fldContactID;
}
return cID;
}
private void GetFectchers()
{
string q = "SELECT * FROM tblKidFetcher WHERE fldKidID='" + fldKidsID + "'";
js.ExecuteQuery(q);
int i = 0;
while(js.RiD.Read())
{
fetcherID[i] = js.RiD["fldFetcherID"].ToString();
i += 1;
}
js.CloseConnection();
}
private void tabControl1_TabIndexChanged(object sender, EventArgs e)
{
if(tabControl1.SelectedIndex==1)
{
MessageBox.Show(Convert.ToString(fetcherID.Length));
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if(dgvFetchers.Rows.Count==0)
{
MessageBox.Show("No record to edit","", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
txtFetcherFN.Text = dgvFetchers.CurrentRow.Cells["FirstName"].Value.ToString();
txtFetcherLN.Text = dgvFetchers.CurrentRow.Cells["LastName"].Value.ToString();
txtFetcherMN.Text = dgvFetchers.CurrentRow.Cells["MiddleName"].Value.ToString();
cboRelationship.Text = dgvFetchers.CurrentRow.Cells["Relationship"].Value.ToString();
txtFetcherContact.Text = dgvFetchers.CurrentRow.Cells["ContactNo"].Value.ToString();
txtFetcherAddr1.Text = dgvFetchers.CurrentRow.Cells["Address1"].Value.ToString();
txtFetcherAddr2.Text = dgvFetchers.CurrentRow.Cells["Address2"].Value.ToString();
txtFetcherCity.Text = dgvFetchers.CurrentRow.Cells["City"].Value.ToString();
txtFetcherZip.Text = dgvFetchers.CurrentRow.Cells["ZipCode"].Value.ToString();
txtEmail.Text = dgvFetchers.CurrentRow.Cells["Email"].Value.ToString();
pbFetcher.Image.Dispose();
string temppic2 = Application.StartupPath + "/Pictures/tmp/Fetchers/tmp1.jpg";
System.IO.File.Copy(dgvFetchers.CurrentRow.Cells["Picture"].Value.ToString(), temppic2, true);
pbFetcher.Image = System.Drawing.Image.FromFile(temppic2);
btnEdit.Tag = dgvFetchers.CurrentRow.Index;
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (dgvFetchers.Rows.Count == 0)
{
MessageBox.Show("No record to delete", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
dgvFetchers.Rows.Remove(dgvFetchers.CurrentRow);
}
private void btnPicture_Click(object sender, EventArgs e)
{
}
private void tabPage1_Click(object sender, EventArgs e)
{
}
private void label33_Click(object sender, EventArgs e)
{
}
private void chkAgree_CheckedChanged(object sender, EventArgs e)
{
}
private void tabPage2_Click(object sender, EventArgs e)
{
}
}
}