示例#1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn thêm thông tin này không!", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    nd.tenND = txtTenND.Text;
                    if (rBtnNam.Checked == true)
                    {
                        nd.gioiTinhND = "Nam";
                    }
                    if (rBtnNu.Checked == true)
                    {
                        nd.gioiTinhND = "Nữ";
                    }
                    nd.ngaySinhND = dateTimeNgaySinh.Value;
                    nd.ngayLam    = datTimeNgayLam.Value;
                    nd.maVT       = int.Parse(cbVaiTro.SelectedValue.ToString());
                    nd.taiKhoan   = txtTaiKhoan.Text;
                    nd.matKhau    = txtMatKhau.Text;
                    nd.ghiChu     = txtGhiChu.Text;

                    ndBus.Insert(nd);

                    MessageBox.Show("Thêm thành công");
                    if (LamMoi != null)
                    {
                        LamMoi(sender, e);
                    }
                    //XoaText();
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Bạn chưa nhập thông tin!" + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }