示例#1
0
        private void btnLuu_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (them)
            {
                try
                {
                    BLDocGia blDG = new BLDocGia();
                    if (pic1.Image == null)
                    {
                        blDG.ThemDocGia(MaDG, TenDG, GioiTinh, NgaySinh, CMND, DiaChi, SDT, null, ref err);
                    }
                    else
                    {
                        blDG.ThemDocGia(MaDG, TenDG, GioiTinh, NgaySinh, CMND, DiaChi, SDT, imageToByteArray(pic1.Image), ref err);
                    }

                    LoadData();

                    XtraMessageBox.Show("Đã thêm xong!");
                }
                catch
                {
                    XtraMessageBox.Show("Không thêm được. Lỗi rồi!");
                }
            }
            else
            {
                BLDocGia blDG = new BLDocGia();
                if (pic1.Image == null)
                {
                    blDG.CapNhatDocGia(MaDG, TenDG, GioiTinh, NgaySinh, CMND, DiaChi, SDT, null, ref err);
                }
                else
                {
                    blDG.CapNhatDocGia(MaDG, TenDG, GioiTinh, NgaySinh, CMND, DiaChi, SDT, imageToByteArray(pic1.Image), ref err);
                }

                LoadData();

                XtraMessageBox.Show("Đã sửa xong!");
            }
        }