-
Notifications
You must be signed in to change notification settings - Fork 0
/
fSearch.cs
115 lines (106 loc) · 3.95 KB
/
fSearch.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
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 PROFILE_MANAGEMENT
{
public partial class fSearch : Form
{
public static fSearch fSearchInstance;
public DataGridView dataadd;
public fSearch()
{
InitializeComponent();
fSearchInstance = this;
dataadd = dataGridView1;
}
public void PrintData(ListContact contact, DataTable data)
{
for (int i = 0; i < contact.Count_Contact; i++)
{
DataRow row = data.NewRow();
Contact line = contact.listContact[i];
string[] words;
words = line.ToString().Split(',');
row["ID"] = words[0];
row["Name"] = words[1];
row["Contact Number"] = words[2];
row["Date"] = words[3];
data.Rows.Add(row);
dataGridView1.DataSource = data;
}
}
private void fSearch_Load(object sender, EventArgs e)
{
DataTable data = new DataTable();
data.Columns.Add("ID");
data.Columns.Add("Name");
data.Columns.Add("Contact Number");
data.Columns.Add("Date");
dataGridView1.DataSource = data;
}
private void btnimport_Click(object sender, EventArgs e)
{
DataTable data = new DataTable();
data.Columns.Add("ID");
data.Columns.Add("Name");
data.Columns.Add("Contact Number");
data.Columns.Add("Date");
ListContact contact = new ListContact();
contact.GetContact("contact.csv");
PrintData(contact, data);
}
private void btnexxit_Click(object sender, EventArgs e)
{
DialogResult warning;
warning = MessageBox.Show("Profiles Management Program Will Perform Exit !", "NOTIFICATION", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (warning == DialogResult.Yes)
{
this.Close();
}
}
private void btnnamesearch_Click(object sender, EventArgs e)
{
string name = tbname.Text;
BinarySearchTree bst = new BinarySearchTree();
bst.GetContactTree("contact.csv");
ListContact contact = bst.FindByName(name);
DataTable data = new DataTable();
data.Columns.Add("ID");
data.Columns.Add("Name");
data.Columns.Add("Contact Number");
data.Columns.Add("Date");
if (contact.Count_Contact > 0)
PrintData(contact, data);
else MessageBox.Show("You Have Entered An Invalid Name!");
}
private void btndatesearch_Click(object sender, EventArgs e)
{
string from = dtpfrom.Value.ToString("dd/MM/yyyy");
string to = dtpto.Value.ToString("dd/MM/yyyy");
BinarySearchTree bst = new BinarySearchTree();
bst.GetContactTree("contact.csv");
ListContact contact = bst.FindContactBetweenDate(from, to);
DataTable data = new DataTable();
data.Columns.Add("ID");
data.Columns.Add("Name");
data.Columns.Add("Contact number");
data.Columns.Add("Date");
if (contact.Count_Contact > 0)
PrintData(contact, data);
else MessageBox.Show("You Have Entered An Invalid Date!");
}
private void btnsetting_Click(object sender, EventArgs e)
{
fSetting fSetting = new fSetting();
this.Hide();
fSetting.ShowDialog();
this.Show();
}
}
}