Esempio n. 1
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            tenDangNhap = txtTenDN.Text.Trim();
            matKhau     = txtMatKhau.Text.Trim();
            dataSource  = cbbIP.Text.ToString().Trim();
            PropertiesCls.connectionStringLogin = "******" + dataSource + ",1433\\sqlexpress; Initial Catalog = DangKyQuanLyMonHoc"
                                                  + ";User ID=" + tenDangNhap + ";Password="******";";
            PropertiesCls.tenDangNhap   = tenDangNhap;
            PropertiesCls.matkhau       = matKhau;
            PropertiesCls.quyenDangNhap = qlMH.Lay_quyen_dang_nhap(tenDangNhap).ToString();
            SqlConnection cnt = new SqlConnection(PropertiesCls.connectionStringLogin);

            try
            {
                cnt.Open();
                this.Hide();
                fMain main = new fMain();
                main.Show();
                MessageBox.Show("Open connection! ");
            }
            catch
            {
                txtTenDN.ResetText();
                txtMatKhau.ResetText();
                txtTenDN.Focus();
                PropertiesCls.connectionStringLogin = null;
                MessageBox.Show("Can not open connection! ");
            }
        }