-
Notifications
You must be signed in to change notification settings - Fork 0
/
Students.cs
65 lines (57 loc) · 1.75 KB
/
Students.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MOF_ATMS
{
public partial class Students : Form
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\user\Documents\dbMATMS.mdf;Integrated Security=True;Connect Timeout=30");
SqlCommand com = new SqlCommand();
SqlDataReader dr;
public Students()
{
InitializeComponent();
LoadStudent();
}
public void LoadStudent()
{
int i = 0;
dgvStudent.Rows.Clear();
com = new SqlCommand("SELECT name, studentNum, createdAt FROM tbAsset ", con);
con.Open();
dr = com.ExecuteReader();
while (dr.Read())
{
i++;
dgvStudent.Rows.Add(i, dr[0].ToString(), dr[1].ToString(), dr[2].ToString());
}
dr.Close();
con.Close();
}
private void addNew_Click(object sender, EventArgs e)
{
AssetModule formModule = new AssetModule();
//formModule.btnSave.Enabled = true;
//formModule.btnUpdate.Enabled = false;
formModule.ShowDialog();
LoadStudent();
}
private void dgvAsset_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void txtSearch_TextChanged(object sender, EventArgs e)
{
LoadStudent();
}
}
}