EG









How do I use E G
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: frmCapNhat.cs Copy
19         public frmCapNhat()
20         {
21             sqlcon = new SqlConnection("server=.\\sqlexpress;database=QL_Thitracnghiem;integrated security =true");
22             sqlcon.Open();
23             InitializeComponent();
24         }
File name: frmDienTenTS.cs Copy
16         public frmDienTenTS()
17         {
18             string strCon = "server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security=true";
19             ObjCon = new SqlConnection(strCon);
20             ObjCon.Open();
21             InitializeComponent();
22
23         }
File name: frmKetQua.cs Copy
18         public frmKetQua(string strten, string strma, string strdiem, string strsocaudung)
19         {
20             string strCon = "server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security=true";
21             ObjCon = new SqlConnection(strCon);
22             ObjCon.Open();
23             InitializeComponent();
24
25
26             getvalueformdienten = strten;//ten
27             getvalueformdienma = strma;//ma thi sinh
28             getvaluediem = strdiem;//diem
29             getvaluesocaudung = strsocaudung;//so cau dung
30             socausai = 50 - int.Parse(strsocaudung);//so cau sai
31             lbsocausai.Text = socausai.ToString();
32         }
File name: frmLogin.cs Copy
58         private void btReg_Click(object sender, EventArgs e)
59         {
60             frmReg fReg = new frmReg();
61             fReg.Focus();
62             fReg.ShowDialog(this);
63
64         }
File name: frmLogin.cs Copy
66         private void btLog_Click(object sender, EventArgs e)
67         {
68             try
69             {
70                 if (txtdangnhap.Text == "" || txtmatkhau.Text == "")
71                 {
72                     MessageBox.Show("Bạn chưa điền đầy đủ thông tin", "Có lỗi xảy ra!");
73                     txtdangnhap.Focus();
74                     return;
75                 }
76                     if(txtdangnhap.Text=="admin" && txtmatkhau.Text=="admin")
77                     {
78                         if (MessageBox.Show("Chào mừng bạn đã đến với mục quản lý dành cho giáo viên", "Thông báo", MessageBoxButtons.OK) == DialogResult.OK)
79                         {
80                             this.Hide();
81                             frmQuanLy_Admin admin = new frmQuanLy_Admin();
82                             admin.ShowDialog();
83
84                         }
85
86                     }
87                 else
88                 {
89                     SqlConnection con = new SqlConnection("server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security=true");
90                     con.Open();
91                     SqlCommand cmd = new SqlCommand("Select MatKhau from THISINH where TenDangNhap ='" + txtdangnhap.Text + "'", con);
92                     SqlDataReader reader = cmd.ExecuteReader();
93                     reader.Read();
94                     if (txtmatkhau.Text == reader.GetValue(0).ToString())
95                     {
96                         MessageBox.Show("Bạn đã đăng nhập thành công!", "Thành công");
97                         reader.Close();
98                         con.Close();
99                         this.Close();
100                         frmLuaChon frmChon = new frmLuaChon();
101                         frmChon.ShowDialog();
102                         this.Hide();
103
104                     }
105                     else
106                     {
107                         MessageBox.Show("Sai Mật Khẩu");
108                         txtmatkhau.Focus();
109                     }
110                     reader.Close();
111                     con.Close();
112                 }
113
114             }
115
116             catch (Exception)
117             {
118
119                 MessageBox.Show("Tên đăng nhập và mật khẩu không hợp lệ","Có lỗi xảy ra");
120                 txtdangnhap.Focus();
121
122             }
123         }
File name: frmMain.cs Copy
34         private void xemĐápÁnToolStripMenuItem_Click(object sender, EventArgs e)
35         {
36             frmReg fReg = new frmReg();
37             fReg.MdiParent = this;
38             fReg.Show();
39         }
File name: frmMain.cs Copy
71         private void đăngKýToolStripMenuItem_Click(object sender, EventArgs e)
72         {
73             frmReg reg = new frmReg();
74             reg.ShowDialog();
75         }
File name: frmQuanLySinhVien.cs Copy
18         public frmQuanLySinhVien()
19         {
20             sqlcon = new SqlConnection("server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security =true");
21             sqlcon.Open();
22             InitializeComponent();
23         }
File name: frmReg.cs Copy
17         public frmReg()
18         {
19             string strCon ="server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security=true";
20             ObjCon = new SqlConnection(strCon);
21             ObjCon.Open();
22             InitializeComponent();
23         }
File name: frmThiThat.cs Copy
34         void Load_DeThiThat()
35         {
36             try
37             {
38                 SqlConnection cnn = new SqlConnection("server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security =true");
39                 SqlDataAdapter da = new SqlDataAdapter("select cauhoi.mach,cauhoi,a,b,c,d ,dapan from cauhoi,DAPAN where cauhoi.mach=DAPAN.mach", cnn);
40                 DataTable BangQuestion = new DataTable();
41                 da.Fill(BangQuestion);
42                 TaoBangRandomCauHoi(BangQuestion);
43             }
44             catch (Exception ex)
45             { MessageBox.Show(ex.Message); }
46             p = 60;//nhap thoi gian thi
47             s = 60;
48             h = 0;
49         }

Download file with original file name:EG

EG 114 lượt xem

Gõ tìm kiếm nhanh...