-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedulesForm.cs
152 lines (130 loc) · 4.5 KB
/
schedulesForm.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
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;
using System.Data.SqlClient;
using System.Data.Common;
namespace Hospital
{
public partial class schedulesForm : Form
{
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
CurrencyManager cr;
public schedulesForm()
{
InitializeComponent();
}
void showSurgeryData(string s = "select * from surgery")
{
conn.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\C#\Hospital\surgery.mdf;Integrated Security=True";
cmd.CommandText = s;
da.SelectCommand = cmd;
cmd.Connection = conn;
ds.Clear();
da.Fill(ds, "surgery");
dataGridView1.DataBindings.Clear();
dataGridView1.DataBindings.Add("datasource", ds, "surgery");
cr = (CurrencyManager)this.BindingContext[ds, "surgery"];
}
public void showGeneralStaffData(string s = "select * from generalStaff")
{
conn.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\C#\Hospital\generalStaff.mdf;Integrated Security=True";
cmd.CommandText = s;
da.SelectCommand = cmd;
cmd.Connection = conn;
ds.Clear();
da.Fill(ds, "G");
dataGridView1.DataBindings.Clear();
dataGridView1.DataBindings.Add("datasource", ds, "G");
cr = (CurrencyManager)this.BindingContext[ds, "G"];
}
void srgSearch()
{
mainClass mainClass = new mainClass();
string command;
command = "Select * from surgery where " + comboBox1.Text + " like '" + txtsearch.Text + "%'";
showSurgeryData(command);
}
void generalSearch()
{
string command;
command = "Select * from generalStaff where " + comboBox1.Text + " like '" + txtsearch.Text + "%'";
showGeneralStaffData(command);
}
private void schedulesForm_Load(object sender, EventArgs e)
{
}
private void btnsurgeries_Click(object sender, EventArgs e)
{
Show();
mainClass main = new mainClass();
comboBox1.Items.Add("surgery");
comboBox1.Items.Add("operationroom");
comboBox1.Items.Add("time");
comboBox1.Items.Remove("lastname");
comboBox1.Items.Remove("respon");
showSurgeryData();
lbldata.Text = "Surgery Chart";
lbldata.Visible = true;
}
private void btngeneralstaff_Click(object sender, EventArgs e)
{
comboBox1.Items.Add("lastname");
comboBox1.Items.Add("respon");
comboBox1.Items.Add("time");
comboBox1.Items.Remove("surgery");
comboBox1.Items.Remove("operationroom");
comboBox1.Items.Remove("time");
showGeneralStaffData();
lbldata.Text = "General Staff";
lbldata.Visible = true;
}
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "")
{
MessageBox.Show("DropDown list must be Choosed first", "Choose form Dropdownlist", MessageBoxButtons.OK);
}
else
{
srgSearch();
}
}
private void txtsearch_TextChanged(object sender, EventArgs e)
{
button1_Click(null, null);
}
private void btnnewstaff_Click(object sender, EventArgs e)
{
sch frm = new sch();
frm.Show();
this.Close();
}
private void btnnewsrg_Click(object sender, EventArgs e)
{
schSurgery frm = new schSurgery();
frm.Show();
this.Close();
}
private void btnreport_Click(object sender, EventArgs e)
{
ReportsList frmreport = new ReportsList();
frmreport.Show();
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
adminForm admin = new adminForm();
admin.Show();
this.Close();
}
}
}