Exemple #1
0
        private void btCapNhat_Click(object sender, EventArgs e)
        {
            if (btCapNhat.Text == "OK")
            {
                //--thuc hien tao du lieu cho doi tuong sach
                #region set giá trị
                TaiLieu taiLieu = new TaiLieu();

                taiLieu.IDTaiLieu  = Convert.ToInt32(txtMaTL.Tag);
                taiLieu.MaTaiLieu  = txtMaTL.Text;
                taiLieu.NhanDe     = txtNhanDe.Text;
                taiLieu.SoTrang    = int.Parse(txtSoTrang.Text);
                taiLieu.SoLuong    = int.Parse(txtSoLuong.Text);
                taiLieu.NamXuatBan = int.Parse(txtnamxuatban.Text);
                taiLieu.LanXuatBan = int.Parse(txtlanxuatban.Text);
                taiLieu.NgayNhap   = DateTime.Parse(txtNgayNhap.Text);
                taiLieu.IDTheLoai  = cbloaisach.SelectedValue.ToString();
                taiLieu.IDNgonNgu  = (int)cbNgonNgu.SelectedValue;
                taiLieu.IDTacGia   = (int)cbTacGia.SelectedValue;
                taiLieu.IDNXB      = (int)cbNhaXuatBan.SelectedValue;
                taiLieu.TheThuc    = String.IsNullOrEmpty(cbTheThuc.Text) ? "Không mượn về nhà" : cbTheThuc.Text;
                taiLieu.IDGiaXep   = (int)cbGiaXep.SelectedValue;

                if (TaiLieu.CapNhat(taiLieu))
                {
                    MessageBox.Show("Cập nhật thành công");
                    Load_treeview();
                    set_enable(false);
                    btnThemMoi.Enabled     = btxoa.Enabled = true;
                    btCapNhat.Text         = "Cập nhật";
                    trvListTaiLieu.Enabled = true;
                }

                #endregion
            }
            else
            {
                trvListTaiLieu.Enabled = false;
                set_enable(true);
                btnThemMoi.Enabled = false;
                btxoa.Enabled      = false;
                btCapNhat.Text     = "OK";
            }
        }