private string GetID(string username, string pass) { string id = ""; try { con.MoKetNoi(); // SqlCommand cmd = new SqlCommand("SELECT * FROM TaiKhoan WHERE TenDangNhap ='" + username + "' and MatKhau='" + pass + "'", connect); // SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = con.LayDuLieuBang("SELECT * FROM TaiKhoan WHERE TenDangNhap ='" + username + "' and MatKhau='" + pass + "'"); if (dt != null) { foreach (DataRow dr in dt.Rows) { id = dr["id"].ToString(); } } } catch (Exception) { MessageBox.Show("Lỗi xảy ra khi truy vấn dữ liệu hoặc kết nối với server thất bại !"); } finally { con.DongKetNoi(); } return(id); }
public FNhanphong() { InitializeComponent(); con.MoKetNoi(); HienThiDS(); con.DongKetNoi(); Khoadieukhien(); }
void HienThi() { con.MoKetNoi(); dskh.DataSource = BUS.TaoBang("SELECT * FROM KhachHang"); con.DongKetNoi(); }
void HienThi() { con.MoKetNoi(); msds.DataSource = BUS.TaoBang("SELECT * FROM Phong1"); con.DongKetNoi(); }
void HienThi() { con.MoKetNoi(); dsnv.DataSource = BUS.TaoBang("SELECT * FROM NhanVien"); con.DongKetNoi(); }