private void kháchHàngToolStripMenuItem_Click(object sender, EventArgs e) { try { conn.Open(); // command SqlDataAdapter dta = new SqlDataAdapter("Select Count (*) From DANGNHAP ", conn); DataTable dtb = new DataTable(); dta.Fill(dtb); if (dtb.Rows[0][0].ToString() == "1") { this.Hide(); khachhang ql = new khachhang(); ql.Show(); } else { this.Hide(); DNNV tc = new DNNV(); tc.Show(); } } catch (Exception ex) { MessageBox.Show("Loi ket noi " + ex.Message, "Thong bao");// thong bao loi } conn.Close(); }
private void loginToolStripMenuItem_Click(object sender, EventArgs e) { try { conn.Open(); SqlCommand cmd = new SqlCommand("SP_LogOut", conn); cmd.CommandType = CommandType.StoredProcedure; if (cmd.ExecuteNonQuery() > 0) { //MessageBox.Show("Dang Xuat thanh cong"); } else { //MessageBox.Show("Dang Xuat that bai"); } } catch (Exception ex) { MessageBox.Show("Loi ket noi" + ex.Message, "Thong Bao"); } conn.Close(); this.Hide(); DNNV tc = new DNNV(); tc.Show(); }