static void Main() { Process[] proc = Process.GetProcessesByName(Application.ProductName); if (proc.Length > 1) { MessageBox.Show("应用程序已经打开..."); Thread.Sleep(1000); Environment.Exit(1); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); fmain = new frmmain(); vi = new verifyInstall(); string ds = Apphelper.GetCPUSerialNumber(); if (Apphelper.IsRegistryKeyExist() && Apphelper.IsRegistryValueNameExist("name") && Apphelper.IsRegistryValueNameExist("passwd") && Apphelper.IsRegistryValueNameExist("hash")) { string name = Apphelper.getNameValue(); string passwd = Apphelper.getPassValue(); string hashSaved = Apphelper.getHashValue(); string n_p = ds + name + passwd;// "serversalessongSzamxkjsfp780208"; string hash = Apphelper.GetSha1Hash(n_p); if (!hashSaved.Equals(hash)) { fmain.frmlit.dt = new DateTime(2008, 8, 21); vi.StartPosition = FormStartPosition.CenterParent; vi.ShowDialog(); } } else { fmain.frmlit.dt = new DateTime(2008, 8, 21); vi = new verifyInstall(); vi.StartPosition = FormStartPosition.CenterParent; vi.ShowDialog(); } skey = new softkeyyt(); if (!getkey()) { Application.Exit(); return; } ; Application.Run(fmain); } }
private void btnDangNhap_Click(object sender, EventArgs e) { NguoiDungDTO nd = new NguoiDungDTO(); nd.TenNguoiDung = txtTaiKhoan.Text; nd.MatKhau = txtMatKhau.Text; nd.PhanQuyen = cmbphanquyen.Text; bool isLogin = NguoiDungDAO.KiemTraNguoiDung(nd); if (isLogin == true) { this.Hide(); frmmain f1 = new frmmain(); f1.ShowDialog(); this.Close(); } else { MessageBox.Show("Bạn đã nhập sai tên người dùng, mật khẩu hoặc quyền đăng nhập!", "Cảnh báo"); txtTaiKhoan.Text = ""; txtMatKhau.Text = ""; } }