Esempio n. 1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (textBoxPublisherName.Text == "")
            {
                MessageBox.Show("Hãy nhập tên nhà xuất bản !");
            }
            else
            {
                var publisher = new NhaXuatBan()
                {
                    TenNXB    = textBoxPublisherName.Text,
                    DiaChi    = textBoxPublisherAddress.Text,
                    DienThoai = textBoxPublisherPhone.Text,
                };

                NhaXuatBanDao dao = new NhaXuatBanDao();
                var           res = dao.insertPublisher(publisher.TenNXB, publisher.DiaChi, publisher.DienThoai);
                if (res > 0)
                {
                    MessageBox.Show("Thêm thành công !");
                    clearAll();
                }
                else
                {
                    MessageBox.Show("Chưa thêm được !");
                }
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            var name = textBoxPubName.Text;

            if (name == "")
            {
                MessageBox.Show("Hãy nhập tên nhầ xuất bản !");
            }
            else
            {
                NhaXuatBan nxb = new NhaXuatBan()
                {
                    TenNXB    = textBoxPubName.Text,
                    DiaChi    = textBoxAddress.Text,
                    DienThoai = textBoxPhone.Text,
                };
                NhaXuatBanDao nxbDao = new NhaXuatBanDao();
                var           res    = nxbDao.insertPublisher(nxb.TenNXB, nxb.DiaChi, nxb.DienThoai);
                if (res > 0)
                {
                    MessageBox.Show("Thêm nhầ xuất bản thành công !");
                }
                bindDataToGrid();
                clearAll();
            }
        }