예제 #1
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            try
            {
                Tre tre = new Tre();

                tre.MaTre    = maTre;
                tre.HoTenTre = txtHoTen.Text;

                if (rdoNam.Checked)
                {
                    tre.GioiTinh = "Nam";
                }
                else
                {
                    tre.GioiTinh = "Nu";
                }

                tre.NgaySinh = dtNgaySinh.Value;
                tre.HoTenCha = txtHoTenBo.Text;
                tre.HoTenMe  = txtHoTenMe.Text;
                tre.DiaChi   = txtDiaChi.Text;
                tre.SoDT     = txtDienThoai.Text;

                MessageBox.Show(tre.MaTre);

                TreBLL.CapNhatThongTinTre(tre);
                MessageBox.Show("Cập nhật thành công", "Thông báo");
                GetDataGridView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Thông báo");
            }
        }
예제 #2
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtHoTen.Text.Length > 50 ||
                    txtHoTenCha.Text.Length > 50 ||
                    txtHoTenMe.Text.Length > 50 ||
                    txtDiaChi.Text.Length > 100)
                {
                    MessageBox.Show("Các trường họ tên không được quá dài (ít hơn 50 ký tự)", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (String.IsNullOrEmpty(txtHoTen.Text) ||
                    String.IsNullOrEmpty(txtHoTenCha.Text) ||
                    String.IsNullOrEmpty(txtHoTenMe.Text) ||
                    String.IsNullOrEmpty(txtDiaChi.Text) ||
                    String.IsNullOrEmpty(txtSDT.Text))
                {
                    MessageBox.Show("Phải nhập đầy đủ trưởng thông tin. Không có ghi rõ: 'Không có'", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if ((DateTime.Now - dateNgaySinh.Value).TotalDays <= 1095 || (DateTime.Now - dateNgaySinh.Value).TotalDays >= 2190)
                {
                    MessageBox.Show("Nhà trường chỉ nhận trẻ từ 3 đến 6 tuổi vào học", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                Tre tre = new Tre();

                tre.MaTre = maTre;
                tre.HoTen = txtHoTen.Text;

                if (rdbNam.Checked)
                {
                    tre.GioiTinh = (int)GioiTinh.Nam;
                }
                else
                {
                    tre.GioiTinh = (int)GioiTinh.Nu;
                }

                tre.NgaySinh  = dateNgaySinh.Value;
                tre.TenCha    = txtHoTenCha.Text;
                tre.TenMe     = txtHoTenMe.Text;
                tre.DiaChi    = txtDiaChi.Text;
                tre.DienThoai = txtSDT.Text;

                TreBLL.CapNhatThongTinTre(tre);
                MessageBox.Show("Cập nhật thành công", "Thông báo");
                loadDataGridView();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cập nhật không thành công.\nHãy xem lại thông tin nhập", "Thông báo");
            }
        }
예제 #3
0
        private void btnCapNhat_Click(object sender, System.EventArgs e)
        {
            Tre tempTre = new Tre(txtMaTre.Text,
                                  txtHoTen.Text,
                                  rdoNam.Checked ? 1 : 0,
                                  dtNgaySinh.Value,
                                  txtHoTenCha.Text,
                                  txtHoTenMe.Text,
                                  txtDiaChi.Text,
                                  txtSDT.Text);

            if (TreBLL.CapNhatThongTinTre(tempTre))
            {
                MessageBox.Show("Cập nhật thông tin trẻ thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadDataGirdView();
            }
        }