public bool ChoMuonSach(MuonSach temp) { OpenConnection(); SqlCommand command = new SqlCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "ChoMuonSach"; command.Connection = conn; command.Parameters.Add("@masach", SqlDbType.NChar).Value = temp.MaSach; command.Parameters.Add("@madocgia", SqlDbType.Int).Value = temp.MaDG; command.Parameters.Add("@manhanvien", SqlDbType.Int).Value = temp.MaNV; command.Parameters.Add("@ngaytra", SqlDbType.DateTime).Value = temp.NgayTra; int kq = command.ExecuteNonQuery(); return(kq > 0); }
public bool ThemMuonSach(MuonSachDTO muonSachDTO) { try { MuonSach muonSach = new MuonSach(); muonSach.MaMuon = muonSachDTO.MaMuon; muonSach.SoThe = muonSachDTO.SoThe; muonSach.MaNV = muonSachDTO.MaNV; muonSach.NgayMuon = muonSachDTO.NgayMuon; muonSach.NgayPhaiTra = muonSachDTO.NgayPhaiTra; muonSach.TrangThai = true; data.MuonSaches.Add(muonSach); data.SaveChanges(); return(true); }catch (Exception) { return(false); } }