示例#1
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (txtThemTenNXB.Text.Length == 0)
     {
         MessageBox.Show("Bạn Chưa Nhập Tên Nhà Xuất Bản!", "Cảnh báo!");
     }
     else
     {
         NhaXuatBanDTO NXB = new NhaXuatBanDTO();
         NXB.TenNXB = txtThemTenNXB.Text;
         NhaXuatBanBUS.Insert(NXB);
         MessageBox.Show("Thêm thành công!", "Thông báo!");
         this.Close();
     }
 }
        private void btThem_Click(object sender, RoutedEventArgs e)
        {
            NhaXuatBan nhaXuatBan = new NhaXuatBan()
            {
                MaNXB = (++id).ToString(), TenNXB = tbTenTacGia.Text, DiaChiNXB = tbDiaChi.Text, SoDienThoai = tbSoDienThoai.Text
            };

            NhaXuatBanBUS bus = new NhaXuatBanBUS();

            try
            {
                bus.Insert(nhaXuatBan);

                MessageBox.Show("Thêm thành công !");
            }
            catch (Exception)
            {
                MessageBox.Show("Thêm thất bại !");
            }

            LoadData();
        }