private void button5_Click(object sender, EventArgs e) { main f = new main(1); f.Show(); this.Close(); }
private void button1_Click(object sender, EventArgs e) { try { string pass = textBox2.Text; string repass = textBox3.Text; if (pass.Equals(repass)) { string sql = "select count(*) from tkuser where tk=N'" + textBox1.Text + "'"; if (textBox1.Text.Trim().Equals("")) { MessageBox.Show("Bạn Chưa Nhập Tên Người Dùng!", "Đăng Ký", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (textBox2.Text.Trim().Equals("")) { MessageBox.Show("Bạn Chưa Nhập Mật Khẩu!", "Đăng Ký", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { int i = (int)KetNoiCSDL.count(sql); if (i != 0) { MessageBox.Show("Tài Khoản Đã Được Đăng Ký. Vui Lòng Sử Dụng Tên Khác! ", "Đăng Ký", MessageBoxButtons.OK, MessageBoxIcon.Warning); textBox1.Clear(); textBox2.Clear(); textBox1.Focus(); } else { string them = "insert into tkuser values(N'" + textBox1.Text + "',N'" + textBox2.Text + "')"; KetNoiCSDL.themsuaxoa(them); MessageBox.Show("Đăng Ký Thành Công. Bạn Có Muốn Đăng Nhập Không?", "Đăng Ký", MessageBoxButtons.YesNo, MessageBoxIcon.Question); main f = new main(0); f.Show(); } } } else { MessageBox.Show("Mật Khẩu Bạn Nhập Không Khớp! Bạn Vui Lòng Kiểm Tra Lại!", "Đăng Ký", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox2.Clear(); textBox3.Clear(); } } catch (Exception ex) { MessageBox.Show("Thao Tác Không Thực Hiện Được! Vui Lòng Kiểm Tra Lại!", "Đăng Ký", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { try { string user = textBox1.Text; string pass = textBox2.Text; if (user.Equals("")) { MessageBox.Show("Bạn Chưa Nhập Tên Đăng Nhập", "Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox1.Clear(); this.textBox1.Focus(); } else if (pass.Equals("")) { MessageBox.Show("Bạn Chưa Nhập Mật Khẩu", "Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox2.Clear(); this.textBox2.Focus(); } else { string txt = getMD5(textBox2.Text); String sv = "select count(*) from tkad where tk = N'" + textBox1.Text + "' and mk=N'" + txt + "'"; String sv1 = "select * from tkad where tk = N'" + textBox1.Text + "' "; int i = KetNoiCSDL.count(sv); if (sai > 0) { if (i != 0) { DataTable tb = KetNoiCSDL.laybang(sv1); String ten = tb.Rows[0][0].ToString(); String status = tb.Rows[0][2].ToString(); if (status.Equals("Admin")) { this.Close(); MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Admin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); main Main_chinh = new main(1, ten); Main_chinh.Show(); } else if (status.Equals("User")) { this.Close(); MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản User!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); main Main_chinh = new main(0, ten); Main_chinh.Show(); } else if (status.Equals("Giáo viên")) { this.Close(); MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Giáo viên!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); main Main_chinh = new main(3, ten); Main_chinh.Show(); } else { this.Close(); MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Trưởng khoa!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); main Main_chinh = new main(2, ten); Main_chinh.Show(); } } else { sai = sai - 1; MessageBox.Show("Username Hoặc Password Sai! Bạn Còn " + sai + " Lần Đăng Nhập!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox1.Clear(); this.textBox2.Clear(); this.textBox1.Focus(); } } else { MessageBox.Show("Đã Hết Lượt Truy Cập, Mời Bạn Đăng Nhập Lại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); Form1 f = new Form1(); f.Show(); } } } catch (Exception ex) { MessageBox.Show("Đã Có Lỗi Xảy Ra. Vui Lòng Kiểm Tra Lại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { try { string user = textBox1.Text; string pass = textBox2.Text; if (user.Equals("")) { MessageBox.Show("Bạn Chưa Nhập Tên Đăng Nhập", "Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox1.Clear(); this.textBox1.Focus(); } else if (pass.Equals("")) { MessageBox.Show("Bạn Chưa Nhập Mật Khẩu", "Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox2.Clear(); this.textBox2.Focus(); } else { String sv = "select count(*) from tkuser where tk = N'" + textBox1.Text + "' and mk=N'" + textBox2.Text + "'"; int i = KetNoiCSDL.count(sv); String ad = "select count(*) from tkad where tk = N'" + textBox1.Text + "' and mk=N'" + textBox2.Text + "'"; int i1 = KetNoiCSDL.count(ad); String gv = "select count(*) from tkgv where tk = N'" + textBox1.Text + "' and mk=N'" + textBox2.Text + "'"; int i2 = KetNoiCSDL.count(gv); String tk = "select count(*) from tktk where tk = N'" + textBox1.Text + "' and mk=N'" + textBox2.Text + "'"; int i3 = KetNoiCSDL.count(tk); if (sai > 0) { if (i != 0) { this.Close(); MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản User!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); main Main_chinh = new main(0); Main_chinh.Show(); } else if (i1 != 0) { this.Close(); MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Admin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); main Main_chinh = new main(1); Main_chinh.Show(); } else if (i2 != 0) { this.Close(); MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Giáo Viên!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); main Main_chinh = new main(2); Main_chinh.Show(); } else if (i3 != 0) { this.Close(); MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Trưởng Khoa!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); main Main_chinh = new main(3); Main_chinh.Show(); } else { sai = sai - 1; MessageBox.Show("Username Hoặc Password Sai! Bạn Còn " + sai + " Lần Đăng Nhập!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox1.Clear(); this.textBox2.Clear(); this.textBox1.Focus(); } } else { MessageBox.Show("Đã Hết Lượt Truy Cập, Mời Bạn Đăng Nhập Lại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); Form1 f = new Form1(); f.Show(); } } } catch (Exception ex) { MessageBox.Show("Đã Có Lỗi Xảy Ra. Vui Lòng Kiểm Tra Lại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }