private void btnluulai_Click_1(object sender, EventArgs e) { ChiTietPhieuMuon chitiet = new ChiTietPhieuMuon(); List <Object> lst = new List <object>(); lst = da.Convert(da.Query("select ma from Sach where ten=N'" + cbbmasach.Text + "'")); chitiet.sachma = lst[0].ToString(); lst = da.Convert(da.Query("select ma from TacGia where ten=N'" + cbbtacgia.Text + "'")); chitiet.tacgiama = lst[0].ToString(); List <Object> lst3 = new List <object>(); lst3 = da.Convert(da.Query("select ma from NhaXuatBan where ten=N'" + cbbnhaxuatban.Text + "'")); chitiet.nhaxuatbanma = lst3[0].ToString(); lst = da.Convert(da.Query("select ma from TheLoai where ten=N'" + cbbtheloai.Text + "'")); chitiet.theloaima = lst[0].ToString(); string[] str = { chitiet.sachma, chitiet.theloaima, chitiet.tacgiama, chitiet.nhaxuatbanma }; if (da.Dieukhien(str) == 1) { chitiet.ThemVaoChiTietPhieuMuon(chitiet.sachma, chitiet.nhaxuatbanma, chitiet.theloaima, chitiet.tacgiama); MessageBox.Show("Thành công"); chitiet.phieumuonma = txtphieumuon.Text; DSChitietphieumuon.DataSource = da.Query("DanhSachChiTietPhieuMuon", new SqlParameter("@phieumuonma", chitiet.phieumuonma)); } else { MessageBox.Show("Chưa nhập đầy đủ thông tin"); } }
private void btnthem_Click(object sender, EventArgs e) { string[] str = { cbbdocgia.Text, txthantra.Text, txtngaymuon.Text, cbbnhanvienma.Text }; if (da.Dieukhien(str) == 1) { PhieuMuon pm = new PhieuMuon(); pm.docgiama = cbbdocgia.Text; pm.ngaymuon = DateTime.Parse(txtngaymuon.Text); pm.nhanvienma = cbbnhanvienma.Text; pm.hantra = DateTime.Parse(txthantra.Text); pm.ThemPhieuMuon(pm.docgiama, pm.ngaymuon, pm.nhanvienma, pm.hantra); frmchitietmuonsach frm = new frmchitietmuonsach(); frm.ShowDialog(); this.Close(); } else { MessageBox.Show("Vui lòng xem lại"); } }