-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTA_Teacher.cs
60 lines (56 loc) · 2.08 KB
/
TA_Teacher.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace EducationManagementSystem
{
public partial class TA_Teacher : UserControl
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-OUS5TJV\SQLEXPRESS;database=OOPProject;UID=helloworld;password=hello");
int stdid;
public TA_Teacher()
{
InitializeComponent();
}
public void get(int stdid)
{
this.stdid=stdid;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
dataGridView1.Rows.Clear();
SqlCommand cmd = new SqlCommand();
if (comboBox1.Text == "")
{
cmd = new SqlCommand("SELECT t.t_id,tt.Name,t.Date,t.Attendance from T_Attendance t join Teacher tt on t.t_id=tt.id where tt.id=@id ", con);
cmd.Parameters.AddWithValue("@id", stdid);
}
else if (comboBox1.Text == "Date")
{
string searchValue = dateTimePicker1.Value.ToString("yyyy-MM-dd");
cmd = new SqlCommand("SELECT t.t_id,tt.Name,t.Date,t.Attendance from T_Attendance t join Teacher tt on t.t_id=tt.id where tt.id=@id AND t.Date=@date", con);
cmd.Parameters.AddWithValue("@id", stdid);
cmd.Parameters.AddWithValue("@date", searchValue);
}
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
foreach (DataRow dr in dt.Rows)
{
dataGridView1.Rows.Add(dr.ItemArray);
}
con.Close();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}