コード例 #1
0
        public void btnLuu_Click(object sender, EventArgs e)
        {
            TaiKhoan_DTO nd = new TaiKhoan_DTO();

            if (txtMatKhau.Text != txtMatKhau2.Text)
            {
                MessageBox.Show("Mật khẩu không trùng nhau");
                return;
            }
            if (txtMatKhau.Text == "")
            {
                MessageBox.Show("Mật khẩu không được để trống");
                return;
            }
            nd.MatKhau = Convert.ToString(txtMatKhau.Text);
            nd.Ten     = Convert.ToString(txtNguoiDung.Text);
            if (txtTaiKhoan.Text == "")
            {
                MessageBox.Show("Tài khoản không được trống");
            }
            nd.TaiKhoan = Convert.ToString(txtTaiKhoan.Text);
            nd.MaVaiTro = Convert.ToInt32(lkpVaiTro.EditValue);
            nd.GhiChu   = Convert.ToString(txtGhiChu.Text);

            int test = TaiKhoan_BUS.ThemNguoiDung(nd);

            switch (test)
            {
            case 0:
                MessageBox.Show("Thêm người dùng thành công");
                if (eventThemXongEvent != null)
                {
                    eventThemXongEvent();
                }
                break;

            case -1:
                MessageBox.Show("Tài khoản này đã tồn tại, xin chọn tài khoản khác");
                return;

            case -2:
                MessageBox.Show("Lỗi khi lưu xuống cơ sở dữ liệu");
                return;
            }
        }