private void btnback_Click(object sender, EventArgs e) { this.Hide(); Qlythietbi form = new Qlythietbi(); form.ShowDialog(); }
private void btn_signin_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; SqlConnection conn = new SqlConnection(chuoiketnoi); try { conn.Open(); string user = txtuser.Text; string pass = txtpass.Text; string sql = "select *from Dangnhap where username = '******' and pass = '******' "; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader dta = cmd.ExecuteReader(); if (dta.Read() == true) { this.Hide(); Qlythietbi thietbi = new Qlythietbi(); thietbi.ShowDialog(); } else { DialogResult tb = MessageBox.Show("Dang nhap that bai! \nTai khoan khong ton tai !!!", "Thông báo", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information); if (tb == DialogResult.Retry) { txtpass.Clear(); txtpass.Focus(); } } } catch (Exception ex) { MessageBox.Show("Connect database error"); } if (chk_remember.Checked) { Properties.Settings.Default.Username = txtuser.Text; Properties.Settings.Default.Password = txtpass.Text; Properties.Settings.Default.Save(); } else { Properties.Settings.Default.Username = ""; Properties.Settings.Default.Password = ""; Properties.Settings.Default.Save(); } }