Exemplo n.º 1
0
        void hamDangky()
        {
            if (!string.IsNullOrEmpty(txttaikhoan.Text) && !string.IsNullOrEmpty(txtmatkhau.Text))
            {
                var conmy   = ketnoi.Instance();
                var conlite = ketnoisqlite.khoitao();

                string tk = conmy.kiemtraTaikhoan(txttaikhoan.Text);
                if (tk == null)
                {
                    conmy.taotaikhoanmoi(txttaikhoan.Text, txtmatkhau.Text);
                    conmy.themcotmoi_hangduocban(txttaikhoan.Text);
                    conlite.updatetaikhoan(txttaikhoan.Text, txtmatkhau.Text);

                    MessageBox.Show("Tạo tài khoản thành công\nTên tài khoản là: \"" + txttaikhoan.Text + "\"");

                    usdangnhap = new dangnhap();
                    this.Controls.Add(usdangnhap);
                    usdangnhap.BringToFront();
                }
                else
                {
                    MessageBox.Show("Tên tài khoản: \" " + tk + " \" đã tồn tại\nChọn tên khác");
                    txttaikhoan.Clear();
                    txtmatkhau.Clear();
                    txttaikhoan.Focus();
                }
            }
            else
            {
                MessageBox.Show("Không được để trống trường dữ liệu nào");
                txttaikhoan.Clear();
                txtmatkhau.Clear();
                txttaikhoan.Focus();
            }
        }