private void btBack_Click(object sender, EventArgs e) { DialogResult a = MessageBox.Show("Quay lại Màn hình chính ?", "Thông báo", MessageBoxButtons.YesNo); if (a == DialogResult.Yes) { FormGiaoDien f1 = new FormGiaoDien(); this.Hide(); } }
private void btnDangnhap_Click(object sender, EventArgs e) { try { conn = new SqlConnection(strConnection); conn.Open(); string sql = "Select Count(*) from [CAFE1].[dbo].[Account] Where UserName =@account and PassWord=@pwd"; command = new SqlCommand(sql, conn); command.Parameters.Add(new SqlParameter("@account", txtUsername.Text)); command.Parameters.Add(new SqlParameter("@pwd", txtPassword.Text)); int x = (int)command.ExecuteScalar(); if (x == 1) { // Login Success MessageBox.Show("Đăng nhập Thành công!", "Thông Báo"); lbIncorrect.Text = ""; txtUsername.Focus(); //Open new Form this.Hide(); FormGiaoDien f1 = new FormGiaoDien(); f1.Show(); } else { //Login failed lbIncorrect.Text = "Thông tin bị Trống hoặc Không chính xác !"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }