コード例 #1
0
ファイル: Form3.cs プロジェクト: anhcoll199/kho
        private void button1_Click(object sender, EventArgs e)
        {
            string account  = txtAcc.Text;
            string password = CreateMD5(txtPass.Text);
            var    data     = Ubus.Login(account, password);

            if (data.Rows.Count == 1)
            {
                User user = new User();
                foreach (DataRow row in data.Rows)
                {
                    user.ID   = row["Id"].ToString();
                    user.Name = row["DisplayName"].ToString();
                    user.Role = row["IdUserRole"].ToString();
                }
                LoginVar.ID   = user.ID;
                LoginVar.Name = user.Name;
                LoginVar.Role = user.Role;
                MessageBox.Show("Đăng nhập thành công - Xin chào " + user.Name, "Kho", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Form5 mainForm = new Form5();
                mainForm.FormClosed += new FormClosedEventHandler(otherForm_FormClosed);
                this.Hide();
                mainForm.Show();
            }
            else
            {
                MessageBox.Show("Đăng nhập thất bại - hãy kiểm tra lại thông tin", "Kho", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            string username = txtTaiKhoan.Text;
            string password = txtMK.Text;

            var rs = userBUS.Login(username, password);

            if (rs != null)
            {
                var listRoleForm = roleFormBUS.GetList(rs.RoleId);

                foreach (var roleform in listRoleForm)
                {
                    GlobalVar.dictRoleForm.Add(roleform.FormId, roleform);
                }

                var roleId = rs.RoleId;
                _username = rs.userName;
                Form1 form1 = new Form1(roleId);
                txtTaiKhoan.ResetText();
                txtMK.ResetText();
                username = string.Empty;
                password = string.Empty;
                this.Hide();
                form1.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu");
            }
        }
コード例 #3
0
ファイル: frmDangNhap.cs プロジェクト: NGUYENTDAM/DA_LTUD
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            string username = textEdit1.Text;
            string password = textEdit2.Text;

            var rs = userBUS.Login(username, password);

            if (rs != null)
            {
                var listRoleForm = roleFormBUS.GetList(rs.RoleId);

                foreach (var roleform in listRoleForm)
                {
                    GlobalVar.dictRoleForm.Add(roleform.FormId, roleform);
                }

                var roleId = rs.RoleId;
                GlobalVar.userName = rs.userName;
                GlobalVar.maVN     = rs.maNV;
                Form1 form1 = new Form1(roleId);

                if (checkBox1.Checked)
                {
                    Properties.Settings.Default.userName = textEdit1.Text;
                    Properties.Settings.Default.passUser = textEdit2.Text;
                    Properties.Settings.Default.Save();
                }

                textEdit1.ResetText();
                textEdit2.ResetText();
                username = string.Empty;
                password = string.Empty;

                this.Hide();
                form1.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu");
            }
        }