-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathForm1.cs
More file actions
681 lines (612 loc) · 32.3 KB
/
Form1.cs
File metadata and controls
681 lines (612 loc) · 32.3 KB
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
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 Excel = Microsoft.Office.Interop.Excel;
using System.Threading;
using System.Drawing.Printing;
using System.IO;
using System.Data.OleDb;
using System.Text.RegularExpressions;
using System.Data.Odbc;
using Microsoft.VisualStudio.Data;
using System.Windows.Forms.DataVisualization.Charting;
using Dynamsoft.UVC;
using Dynamsoft.Core;
using Dynamsoft.Common;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Drawing.Imaging;
using WebcamDemo;
using BusinessRefinery.Barcode;
using ZXing.Common;
using ZXing;
using ZXing.QrCode;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
SqlConnection lsConnstr = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=EX;Data Source=HP-UP\\SQLEXPRESS");
SqlCommand cmd;
String gsUserName;
dbClss gObjDBClss = new dbClss();
DataSet gObjDS = new DataSet();
int lnPrgInc = 0;
int counter = 5000;
QrCodeEncodingOptions options = new QrCodeEncodingOptions();
public Form1(string lsUserName)
{
InitializeComponent();
gsUserName = lsUserName;
}
private void nameT_TextChanged(object sender, EventArgs e)
{
if (System.Text.RegularExpressions.Regex.IsMatch(nameT.Text, "[^a-z||^A-Z]"))
{
nameT.Text = "";
}
progressBar1.Value = nameT.TextLength;
if (progressBar1.Value > 0)
lnPrgInc = 10;
progressBar1.Value = lnPrgInc;
int per = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
progressBar1.Refresh();
progressBar1.CreateGraphics().DrawString(per.ToString() + "%", new Font("Arial", (float)10, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
}
private void nameT_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar) && (e.KeyChar != '.'))
{
e.Handled = true;
}
}
private void salT_TextChanged(object sender, EventArgs e)
{
if (progressBar1.Value > 0)
lnPrgInc = 40;
progressBar1.Value = lnPrgInc;
int per = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
progressBar1.Refresh();
progressBar1.CreateGraphics().DrawString(per.ToString() + "%", new Font("Arial", (float)10, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
}
private void dateoB_ValueChanged(object sender, EventArgs e)
{
if (progressBar1.Value > 0)
lnPrgInc = 20;
progressBar1.Value = lnPrgInc;
int per = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
progressBar1.Refresh();
progressBar1.CreateGraphics().DrawString(per.ToString() + "%", new Font("Arial", (float)10, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
}
private void occupT_SelectedIndexChanged(object sender, EventArgs e)
{
if (progressBar1.Value > 0)
lnPrgInc = 30;
progressBar1.Value = lnPrgInc;
int per = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
progressBar1.Refresh();
progressBar1.CreateGraphics().DrawString(per.ToString() + "%", new Font("Arial", (float)10, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
}
private void marital1_SelectedIndexChanged(object sender, EventArgs e)
{
if (progressBar1.Value > 0)
lnPrgInc = 50;
progressBar1.Value = lnPrgInc;
int per = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
progressBar1.Refresh();
progressBar1.CreateGraphics().DrawString(per.ToString() + "%", new Font("Arial", (float)10, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
}
private void healthy_SelectedIndexChanged(object sender, EventArgs e)
{
if (progressBar1.Value > 0)
lnPrgInc = 60;
progressBar1.Value = lnPrgInc;
int per = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
progressBar1.Refresh();
progressBar1.CreateGraphics().DrawString(per.ToString() + "%", new Font("Arial", (float)10, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
}
private void children_SelectedIndexChanged(object sender, EventArgs e)
{
if (progressBar1.Value > 0)
lnPrgInc = 70;
progressBar1.Value = lnPrgInc;
int per = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
progressBar1.Refresh();
progressBar1.CreateGraphics().DrawString(per.ToString() + "%", new Font("Arial", (float)10, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
}
private void register_Click(object sender, EventArgs e)
{
CreateTable();
SqlConnection lsConnstr = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=EX;Data Source=HP-UP\\SQLEXPRESS");
SqlCommand cmd;
lsConnstr.Open();
string filepath = Application.StartupPath + "\\capturedimg.bmp";
FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
br.Close();
fs.Close();
string s = "Insert into T_" + gsUserName + " values(@nameT,@marital1,@dateoB,@healthy,@occupT,@children,@salT,@profile_photo,@id_txtbx)";
cmd = new SqlCommand(s, lsConnstr);
cmd.Parameters.AddWithValue("@nameT", nameT.Text);
cmd.Parameters.AddWithValue("@marital1", marital1.Text);
cmd.Parameters.AddWithValue("@dateoB", dateoB.Text);
cmd.Parameters.AddWithValue("@healthy", healthy.Text);
cmd.Parameters.AddWithValue("@occupT", occupT.Text);
cmd.Parameters.AddWithValue("@children", children.Text);
cmd.Parameters.AddWithValue("@salT", salT.Text);
cmd.Parameters.AddWithValue("@profile_photo",bytes);
cmd.Parameters.AddWithValue("@id_txtbx", id_txtbx.Text);
progressBar1.PerformStep();
cmd.CommandType = CommandType.Text;
int i = cmd.ExecuteNonQuery();
lsConnstr.Close();
{
MessageBox.Show(" data entered successfully ");
}
}
public void CreateTable()
{
try
{
SqlConnection lsConnstr = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=EX;Data Source=HP-UP\\SQLEXPRESS");
SqlCommand cmd;
lsConnstr.Open();
string s = "";
s = "Create table T_" + gsUserName + "(name nchar(20) ,marital_status nchar(20) ,date_of_birth nchar(20) ,health_status nchar(20) ,occupation nchar(20) ,no_of_children nchar(20) ,salary nchar(20),ID_no nchar(10)";
cmd = new SqlCommand(s, lsConnstr);
cmd.ExecuteNonQuery();
}
catch (Exception )
{
}
}
private void clear_Click(object sender, EventArgs e)
{
nameT.Text = "\0";
salT.Text = "\0";
marital1.Text = "\0";
occupT.Text = "\0";
healthy.Text = "\0";
children.Text = "\0";
id_txtbx.Text = "\0";
}
private void tablegridinside_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
DataGridView lObjDtGrdView = (DataGridView)sender;
int index = e.RowIndex;
name2.Text = lObjDtGrdView.Rows[index].Cells[0].Value.ToString();
dateTimePicker2.Text = lObjDtGrdView.Rows[index].Cells[2].Value.ToString();
occupS.Text = "\0";
occupS.SelectedText = lObjDtGrdView.Rows[index].Cells[4].Value.ToString();
MaritS.Text = "\0";
MaritS.SelectedText = lObjDtGrdView.Rows[index].Cells[1].Value.ToString();
comboBox4.Text = lObjDtGrdView.Rows[index].Cells[3].Value.ToString();
textBox3.Text = lObjDtGrdView.Rows[index].Cells[5].Value.ToString();
SalS.Text = lObjDtGrdView.Rows[index].Cells[6].Value.ToString();
id_srch.Text = lObjDtGrdView.Rows[index].Cells[8].Value.ToString();
if (!lObjDtGrdView.Rows[index].Cells[7].Value.ToString().Equals(""))
{
var photo = (Byte[])(lObjDtGrdView.Rows[index].Cells[7].Value);
var fs = new MemoryStream(photo);
prof_photoMang.Image = Image.FromStream(fs);
prof_photoMang.SizeMode = PictureBoxSizeMode.StretchImage;
}
}
private void Form1_Load(object sender, EventArgs e)
{
options = new QrCodeEncodingOptions()
{
DisableECI = true,
CharacterSet = "UTF-8",
Width = 107,
Height = 107,
Margin=0,
};
var writer = new BarcodeWriter();
writer.Format = BarcodeFormat.QR_CODE;
writer.Options = options;
try
{
string lsQuery = "Select * from T_" + gsUserName + "";
gObjDS = gObjDBClss.GetData(lsQuery);
if (gObjDS.Tables[0].Rows.Count > 0)
{
tablegridinside.DataSource = gObjDS.Tables[0];
}
backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.RunWorkerAsync();
timer1.Enabled = true;
timer1.Start();
timer1.Tick += new EventHandler(timer1_Tick);
}
catch (Exception )
{
}
}
void timer1_Tick(object sender, EventArgs e)
{
counter--;
countdown.Text = counter.ToString();
if (Formwebcam.imgflag == 1)
profile_photo.ImageLocation = Application.StartupPath + "\\capturedimg.bmp";
profile_photo.SizeMode = PictureBoxSizeMode.StretchImage;
if (counter == 0)
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
string query1;
if (or.SelectedItem.Equals("OR"))
{
if (comboBox2.SelectedIndex==-1)
{
query1 = "Select * from T_" + gsUserName + " where marital_status='" + comboBox3.SelectedItem.ToString() + "'";
}
else
{
query1 = "Select * from T_" + gsUserName + " where occupation='" + comboBox2.SelectedItem.ToString() + "'";
}
}
else
{
query1 = "Select * from T_" + gsUserName + " where occupation='" + comboBox2.SelectedItem.ToString() + "' and marital_status='" + comboBox3.SelectedItem.ToString() + "'";
}
gObjDS = gObjDBClss.GetData(query1);
if (gObjDS.Tables[0].Rows.Count > 0)
{
tablegridinside.DataSource = null;
tablegridinside.DataSource = gObjDS.Tables[0];
}
}
private void button2_Click(object sender, EventArgs e)
{
string lsQuery = "Delete from T_" + gsUserName + " where name='" + name2.Text + "'";
gObjDBClss.InsertUpdateData(lsQuery);
}
private void refresh_Click(object sender, EventArgs e)
{
string lsQuery = "Select * from T_" + gsUserName + "";
gObjDS = gObjDBClss.GetData(lsQuery);
if (gObjDS.Tables[0].Rows.Count > 0)
{
tablegridinside.DataSource = null;
tablegridinside.DataSource = gObjDS.Tables[0];
}
}
private void copyAlltoClipboard()
{
tablegridinside.RowHeadersVisible = false;
tablegridinside.SelectAll();
DataObject dataObj = tablegridinside.GetClipboardContent();
if (dataObj != null)
Clipboard.SetDataObject(dataObj);
}
private void export_Click(object sender, EventArgs e)
{
copyAlltoClipboard();
Microsoft.Office.Interop.Excel.Application xlexcel;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlexcel = new Excel.Application();
xlexcel.Visible = true;
xlWorkBook = xlexcel.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
Excel.Range CR = (Excel.Range)xlWorkSheet.Cells[1, 1];
CR.Select();
xlWorkSheet.PasteSpecial(CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true);
}
private void print_Click(object sender, EventArgs e)
{
printDocument1.Print();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bm = new Bitmap(this.tablegridinside.Width, this.tablegridinside.Height);
tablegridinside.DrawToBitmap(bm, new Rectangle(0, 0, this.tablegridinside.Width, this.tablegridinside.Height));
e.Graphics.DrawImage(bm, 0, 0);
}
private void update_Click(object sender, EventArgs e)
{
if (nameT.Text != " ")
{
string filepath = Application.StartupPath + "\\capturedimg.bmp";
FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
br.Close();
fs.Close();
cmd = new SqlCommand("update T_" + gsUserName + " set marital_status=@marital1,date_of_birth=@dateoB,health_status=@healthy,occupation=@occupT, no_of_children=@children,salary=@salT,photo=@prof_photoMang,ID_no=@id_txtbx where name=@nameT", lsConnstr);
lsConnstr.Open();
cmd.Parameters.AddWithValue("@nameT", name2.Text);
cmd.Parameters.AddWithValue("@marital1", MaritS.Text);
cmd.Parameters.AddWithValue("@dateoB", dateTimePicker2.Text);
cmd.Parameters.AddWithValue("@healthy", comboBox4.Text);
cmd.Parameters.AddWithValue("@occupT", occupS.Text);
cmd.Parameters.AddWithValue("@children", textBox3.Text);
cmd.Parameters.AddWithValue("@salT", SalS.Text);
cmd.Parameters.AddWithValue("@prof_photoMang",bytes);
cmd.Parameters.AddWithValue("@id_txtbx", id_srch.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("record updated successfully");
lsConnstr.Close();
}
else
{
MessageBox.Show("please select record");
}
}
public DataTable readexcel(string filename, string fileext)
{
string lsConnstr = string.Empty;
DataTable dtexcel = new DataTable();
if (fileext.CompareTo(".xls") == 0)
{
lsConnstr = "Provider=Microsoft.Jet.OLEDB.8.0;Data source=" + filename + ";Extended Properties='Excel 8.0;HRD=Yes;IMEX=1';";
}
else
{
lsConnstr = "Provider=Microsoft.Ace.OLEDB.12.0;Data source=" + filename + ";Extended Properties='Excel 12.0;HRD=No';";
}
using (OleDbConnection con = new OleDbConnection(lsConnstr))
{
try
{
OleDbDataAdapter oleadpt = new OleDbDataAdapter("select * from [sheet1$]", con);
oleadpt.Fill(dtexcel);
}
catch { }
}
return dtexcel;
}
private void button3_Click(object sender, EventArgs e)
{
try
{
openFileDialog1.Filter = "XML Files(*.xml;*.xls;*.xlsx;*.xlsm;*.xlsb)|*.xml;*.xls;*.xlsx;*.xlsm;*.xlsb";
openFileDialog1.FilterIndex = 3;
openFileDialog1.Multiselect = false;
openFileDialog1.Title = "open text file";
openFileDialog1.InitialDirectory = @"Desktop";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string pathname = openFileDialog1.FileName;
textBox1.Text = pathname;
String lsSheetSelected = "sheet1";
String lsExcelQuery = "select * from [" + lsSheetSelected + "$]";
OleDbConnection lObjOledbConn;
DataSet lObjOledbDataSet;
OleDbDataAdapter lObjOledbAdptr;
String lObjConnStr = "";
if (textBox1.Text.Split('.')[1] == "xls")
lObjConnStr =@"Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Persist Security Info=False";
else
lObjConnStr =@"Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 8.0 Xml;HDR=YES';Persist Security Info=False";
lObjConnStr = lObjConnStr + "Data Source=" + textBox1.Text.ToString();
lObjOledbConn = new OleDbConnection(lObjConnStr);
if (lObjOledbConn.State != ConnectionState.Open)
lObjOledbConn.Open();
lObjOledbAdptr = new OleDbDataAdapter(lsExcelQuery, lObjOledbConn);
lObjOledbConn.ConnectionString = "Data Source=.\\SQLExpress;" + "User Instance=true;" + "User Id=username;" + "Password=password;" + "AttachDbFileName=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\EX.mdf;";
lObjOledbAdptr.TableMappings.Add("Table","TestTable");
lObjOledbDataSet = new DataSet();
lObjOledbAdptr.Fill(lObjOledbDataSet);
tablegridinside.DataSource = lObjOledbDataSet.Tables[0];
MessageBox.Show("File Imported successfully..!!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void go_Click(object sender, EventArgs e)
{
chart1.Series.Clear();
chart1.Series.Add("children");
chart1.Titles.Clear();
SqlConnection lsConnstr = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=EX;Data Source=HP-UP\\SQLEXPRESS");
DataSet ds = new DataSet();
lsConnstr.Open();
if (gphslct1.SelectedItem.Equals("Name") && gphslct2.SelectedItem.Equals("No. of Children"))
{
SqlDataAdapter adapt = new SqlDataAdapter("Select name,no_of_children from T_" + gsUserName + "", lsConnstr);
adapt.Fill(ds);
chart1.DataSource = ds;
chart1.Series["children"].XValueMember = "name";
chart1.Series["children"].YValueMembers = "no_of_children";
chart1.Titles.Add("CHILDREN CHART");
chart1.ChartAreas[0].AxisX.Title = "NAME";
chart1.ChartAreas[0].AxisY.Title = "CHILDREN";
chart1.ChartAreas[0].AxisX.IsMarginVisible = true;
chart1.ChartAreas[0].AxisX.Minimum = 1;
chart1.ChartAreas[0].AxisX.Maximum = ds.Tables[0].Rows.Count;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
chart1.ChartAreas[0].AxisX.Minimum = double.NaN;
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
chart1.ChartAreas[0].RecalculateAxesScale();
}
else
if (gphslct1.SelectedItem.Equals("Name") && gphslct2.SelectedItem.Equals("date of birth"))
{
SqlDataAdapter adapt = new SqlDataAdapter("Select name,Floor(DateDiff(d, date_of_birth, GetDate()) / 365.25) as date_of_birth from T_" + gsUserName + "", lsConnstr);
adapt.Fill(ds);
chart1.DataSource = ds;
chart1.Series["children"].XValueMember = "name";
chart1.Series["children"].YValueMembers = "date_of_birth";
chart1.Titles.Add("AGE CHART");
chart1.ChartAreas[0].AxisX.Title = "NAME";
chart1.ChartAreas[0].AxisY.Title = "DATE OF BIRTH";
chart1.ChartAreas[0].AxisX.IsMarginVisible = true;
chart1.ChartAreas[0].AxisX.Minimum = 1;
chart1.ChartAreas[0].AxisX.Maximum = ds.Tables[0].Rows.Count;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
chart1.ChartAreas[0].AxisX.Minimum = double.NaN;
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
chart1.ChartAreas[0].RecalculateAxesScale();
}
else
if (gphslct1.SelectedItem.Equals("Name") && gphslct2.SelectedItem.Equals("Salary"))
{
SqlDataAdapter adapt = new SqlDataAdapter("Select name,salary from T_" + gsUserName + "", lsConnstr);
adapt.Fill(ds);
chart1.DataSource = ds;
chart1.Series["children"].XValueMember = "name";
chart1.Series["children"].YValueMembers = "salary";
chart1.Titles.Add("SALARY CHART");
chart1.ChartAreas[0].AxisX.Title = "NAME";
chart1.ChartAreas[0].AxisY.Title = "SALARY";
chart1.ChartAreas[0].AxisX.IsMarginVisible = true;
chart1.ChartAreas[0].AxisX.Minimum = 1;
chart1.ChartAreas[0].AxisX.Maximum = ds.Tables[0].Rows.Count;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
chart1.ChartAreas[0].AxisX.Minimum = double.NaN;
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
chart1.ChartAreas[0].RecalculateAxesScale();
}
else
if (gphslct1.SelectedItem.Equals("Occupation") && gphslct2.SelectedItem.Equals("No. of Children"))
{
SqlDataAdapter adapt = new SqlDataAdapter("Select occupation,no_of_children from T_" + gsUserName + "", lsConnstr);
adapt.Fill(ds);
chart1.DataSource = ds;
chart1.Series["children"].XValueMember = "occupation";
chart1.Series["children"].YValueMembers = "no_of_children";
chart1.Titles.Add("OCCUPATION-CHILDREN CHART");
chart1.ChartAreas[0].AxisX.Title = "OCCUPATION";
chart1.ChartAreas[0].AxisY.Title = "CHILDREN";
chart1.ChartAreas[0].AxisX.IsMarginVisible = true;
chart1.ChartAreas[0].AxisX.Minimum = 1;
chart1.ChartAreas[0].AxisX.Maximum = ds.Tables[0].Rows.Count;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
chart1.ChartAreas[0].AxisX.Minimum = double.NaN;
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
chart1.ChartAreas[0].RecalculateAxesScale();
}
else
if (gphslct1.SelectedItem.Equals("Occupation") && gphslct2.SelectedItem.Equals("date of birth"))
{
SqlDataAdapter adapt = new SqlDataAdapter("Select occupation,Floor(DateDiff(d, date_of_birth, GetDate()) / 365.25) as date_of_birth from T_" + gsUserName + "", lsConnstr);
adapt.Fill(ds);
chart1.DataSource = ds;
chart1.Series["children"].XValueMember = "occupation";
chart1.Series["children"].YValueMembers = "date_of_birth";
chart1.Titles.Add("OCCUPATION-AGE CHART");
chart1.ChartAreas[0].AxisX.Title = "OCCUPATION";
chart1.ChartAreas[0].AxisY.Title = "DATE OF BIRTH";
chart1.ChartAreas[0].AxisX.IsMarginVisible = true;
chart1.ChartAreas[0].AxisX.Minimum = 1;
chart1.ChartAreas[0].AxisX.Maximum = ds.Tables[0].Rows.Count;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
chart1.ChartAreas[0].AxisX.Minimum = double.NaN;
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
chart1.ChartAreas[0].RecalculateAxesScale();
}
else
if (gphslct1.SelectedItem.Equals("Occupation") && gphslct2.SelectedItem.Equals("Salary"))
{
SqlDataAdapter adapt = new SqlDataAdapter("Select occupation,salary from T_" + gsUserName + "", lsConnstr);
adapt.Fill(ds);
chart1.DataSource = ds;
chart1.Series["children"].XValueMember = "occupation";
chart1.Series["children"].YValueMembers = "salary";
chart1.Titles.Add("OCCUPATION-SALARY CHART");
chart1.ChartAreas[0].AxisX.Title = "OCCUPATION";
chart1.ChartAreas[0].AxisY.Title = "SALARY";
chart1.ChartAreas[0].AxisX.IsMarginVisible = true;
chart1.ChartAreas[0].AxisX.Minimum = 1;
chart1.ChartAreas[0].AxisX.Maximum = ds.Tables[0].Rows.Count;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
chart1.ChartAreas[0].AxisX.Minimum = double.NaN;
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
chart1.ChartAreas[0].RecalculateAxesScale();
}
lsConnstr.Close();
}
private void capturepic_Click(object sender, EventArgs e)
{
Formwebcam frmwbcam = new Formwebcam();
frmwbcam.ShowDialog();
}
private void tabPage1_Click(object sender, EventArgs e)
{
if (Formwebcam.imgflag == 1)
profile_photo.ImageLocation = Application.StartupPath + "\\capturedimg.bmp";
}
private void profile_photo_Click(object sender, EventArgs e)
{
Formwebcam fwbcm = new Formwebcam();
fwbcm.Show();
ImageCore m_ImageCore = new ImageCore();
}
private void updt_phto_Click(object sender, EventArgs e)
{
prof_photoMang.Image = null;
Formwebcam frmwbcam = new Formwebcam();
frmwbcam.ShowDialog();
counter--;
countdown.Text = counter.ToString();
if (Formwebcam.imgflag == 1)
prof_photoMang.ImageLocation = Application.StartupPath + "\\capturedimg.bmp";
prof_photoMang.SizeMode = PictureBoxSizeMode.StretchImage;
if (counter == 0)
this.Close();
}
private void button1_Click_1(object sender, EventArgs e)
{
if (String.IsNullOrEmpty (id_srch.Text) || String.IsNullOrEmpty(id_srch.Text))
{
qr_code.Image = null;
MessageBox.Show("Text not found", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
var qr = new ZXing.BarcodeWriter();
qr.Options = options;
qr.Format = ZXing.BarcodeFormat.QR_CODE;
var result = new Bitmap(qr.Write(id_srch.Text.Trim()));
qr_code.Image = result;
}
prof_photoMang_cpy.Image = prof_photoMang.Image;
prof_photoMang_cpy.SizeMode = PictureBoxSizeMode.StretchImage;
qr_code_cpy.Image = qr_code.Image;
id_srch_cpy.Text = id_srch.Text;
name2_cpy.Text = name2.Text;
dateTimePicker2_cpy.Text = dateTimePicker2.Text;
occupS_cpy.Text = occupS.Text;
MaritS_cpy.Text = MaritS.Text;
}
private void pnt_ID_Click(object sender, EventArgs e)
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
PrintDocument Pd = new PrintDocument();
Pd.PrintPage += printDocument2_PrintPage;
ppd.Document = Pd;
ppd.ShowDialog();
}
private void printDocument2_PrintPage(object sender, PrintPageEventArgs e)
{
Bitmap bmp = new Bitmap(identity_box.ClientRectangle.Width, identity_box.ClientRectangle.Height);
identity_box.DrawToBitmap(bmp, identity_box.ClientRectangle);
e.Graphics.DrawImage(bmp, 0, 0);
}
}
}