Beispiel #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            Sach   _s  = new Sach();
            Random rdm = new Random();

            _s.MaSach     = rdm.Next(0, 1000).ToString();
            _s.TenSach    = txtTen.Text;
            _s.TacGia     = txtTacGia.Text;
            _s.NhaXuatBan = txtNxb.Text;
            _s.TheLoai    = txtTheLoai.Text;
            if (txtGia.Text != "")
            {
                _s.GiaSach = int.Parse(txtGia.Text);
            }
            _s.SoLuong = Convert.ToInt32(numericUpDown1.Value);

            //kiem tra loi madocgia

            if (s.Them(_s) == true)
            {
                MessageBox.Show("Thêm thành công!!!");
                QuanLySach_Load(sender, e);
                ResetGridview();
            }
            else
            {
                MessageBox.Show("Thêm thất bại!!!");
            }
            //load lai
        }
Beispiel #2
0
        private void BtnThem_Click(object sender, EventArgs e)
        {
            Sach Sach = new Sach(txtTenSach.Text, txtTacGia.Text, txtNamXuatBan.Text, txtNhaXuatBan.Text, txtTriGia.Text, dateNgayNhap.Value.ToShortDateString());

            if (bus_Sach.Them(Sach))
            {
                MessageBox.Show("Thêm thành công!");
            }
            else
            {
                MessageBox.Show("Thêm thất bại!");
            }

            listV.Items.Clear();
            loadLV();

            //Sach _Sach = new Sach();
            //_Sach.TenSach = txtTenSach.Text.ToString();
            //_Sach.TacGia = txtTacGia.Text.ToString();
            //_Sach.NamXuatBan = Int32.Parse(txtNamXuatBan.Text);
            //_Sach.NhaXuatBan = txtNhaXuatBan.Text.ToString();
            //_Sach.TriGia = Int32.Parse(txtTriGia.Text);
            //_Sach.NgayNhap = dateNgayNhap.Value;
            //QLTVData.Saches.InsertOnSubmit(_Sach);
            //QLTVData.SubmitChanges();
            //listV.Items.Clear();
            //loadLV();
        }