-
Notifications
You must be signed in to change notification settings - Fork 6
/
CrudEmployee.cs
117 lines (104 loc) · 4.06 KB
/
CrudEmployee.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
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 OOP_Project___Hospital_Management_System
{
public partial class CrudEmployee : Form
{
public CrudEmployee()
{
InitializeComponent();
display();
}
private void buttonInsert_Click(object sender, EventArgs e)
{
Employee doctor = new Employee()
{
Name = textBoxName.Text,
Gender = comboBoxGender.Text,
Designation = rolecbx.SelectedItem.ToString(),
Department = depcbx.SelectedItem.ToString(),
Pass = password.Text,
Email = textBoxEmail.Text,
Address = textBoxAddress.Text,
Tel = textBoxTel.Text
};
DatabaseOps insertemp= new DatabaseOps();
insertemp.insert(doctor);
display();
}
public void display()
{
DatabaseOps databaseOps = new DatabaseOps();
DataTable dt = new DataTable();
dataGridView1.DataSource = databaseOps.display("EMPLOYEE");
databaseOps.Showincbx(depcbx, "Department", "DepartmentName");
databaseOps.Showincbx(rolecbx, "EmployeeRoles", "RoleName");
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
Employee doctor = new Employee()
{
ID = textBoxid.Text,
Name = textBoxName.Text,
Gender = comboBoxGender.Text,
Designation = rolecbx.SelectedItem.ToString(),
Pass = password.Text,
Department = depcbx.SelectedItem.ToString(),
Email = textBoxEmail.Text,
Address = textBoxAddress.Text,
Tel = textBoxTel.Text
};
DatabaseOps updateDoc = new DatabaseOps();
updateDoc.update(doctor);
display();
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (textBoxid.Text.Length != 0)
{
DatabaseOps databaseOps = new DatabaseOps();
databaseOps.delete("EMPLOYEE", textBoxid.Text);
display();
}
else
{
MessageBox.Show("Unable to delete Data, Select a row which you want to delete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDisplay_Click(object sender, EventArgs e)
{
display();
}
private void textBoxSearch_TextChanged(object sender, EventArgs e)
{
DatabaseOps databaseOps = new DatabaseOps();
dataGridView1.DataSource = databaseOps.search("EMPLOYEE", textBoxSearch.Text, comboBoxSearchBy.Text);
}
private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
textBoxid.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
textBoxName.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
if (dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString() == "Male")
{
comboBoxGender.Text = "Male";
}
else
{
comboBoxGender.Text = "Female";
}
password.Text= dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
depcbx.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
textBoxTel.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
textBoxEmail.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
textBoxAddress.Text = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
rolecbx.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
}
}
}