コード例 #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            lb_MDG.Visible   = false;
            lb_Trung.Visible = false;

            DocGia dg = new DocGia();

            Random rdm = new Random();

            dg.MaDocGia    = rdm.Next(0, 1000).ToString();
            dg.TenDangNhap = txt_TenDangNhap.Text;
            dg.HoTen       = txtHoTen.Text;
            dg.DiaChi      = txtDiaChi.Text;
            if (rdoBtnNam.Checked == true)
            {
                dg.GioiTinh = "Nam  ";
            }
            else if (rdoBtnNu.Checked == true)
            {
                dg.GioiTinh = "Nữ   ";
            }

            if (dateNamSinh.Text == "")
            {
                dg.NamSinh = DateTime.Now;
            }
            else
            {
                dg.NamSinh = dateNamSinh.DateTime;
            }
            //kiem tra loi madocgia
            int check = docGiaBUS.Them(dg);

            if (check == 0)
            {
                lb_MDG.Visible = true;
            }
            else if (check == -1)
            {
                lb_Trung.Visible = true;
            }
            //load lai
            ucFrmQLThanhVien_Load(sender, e);
            ResetGridview();
        }