private void bttrasach_Click(object sender, EventArgs e) { laydulieu dl = new laydulieu(); DataSet d = dl.getdata("select * from phieumuon where maphieumuon='" + maphieumuon + "' and GETdate()- phieumuon.ngaymuon > day(7)"); while (true) { if (d.Tables[0].Rows.Count > 0) { if (MessageBox.Show("Sách này đã quá hạn bạn có thật sự muốn tiếp tục thực hiện thao tác này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { Frmmain.hf.set_text("Sách quá hạn là sách mượn vượt quá 7 ngày không xét trường hợp sách mượn đọc tại chỗ"); Frmmain.hf.set_anh(2); Frmmain.hf.timer5.Enabled = true; break; } } Lsachmuon sm = new Lsachmuon(maphieumuon); Lsach s = new Lsach(); s.set_masach(txtmasach.Text); if (s.trasach(txtsosachmuon.Text)) { if (sm.xoabo()) { if (checkBox1.Checked) { if (MessageBox.Show("Sách này có thật sự bị hỏng không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { L_Ketnoi.ThietlapketNoi(); SqlDataReader dr = dl.lay_reader("select masachhong from sachhong"); string strtam = ""; while (dr.Read()) { strtam = dr[0].ToString(); } L_Ketnoi.HuyKetNoi(); Lsachhong sh = new Lsachhong(masachhong(strtam), txtmasach.Text); if (sh.taomoi() == false) { MessageBox.Show("Quá trình cập nhật sách hỏng bị lỗi hãy chuyển qua mục thông tin sách hỏng để làm", "Thông báo"); } } } bthuytt_Click(sender, e); MessageBox.Show("Thao tác trả hoàn thành", "Thông báo"); } else { MessageBox.Show("Thao tác xoá gặp lỗi thành", "Thông báo"); } } else { MessageBox.Show("Thao tác xoá gặp lỗi thành", "Thông báo"); } break; } }
private void button2_Click(object sender, EventArgs e) { Frmthongbao tb = new Frmthongbao(); tb.ShowDialog(this); if (tb.DialogResult == DialogResult.OK) { laydulieu dl = new laydulieu(); SqlDataReader dr = dl.lay_reader("select masach from sach where masach='" + Frmthongbao.tam + "' "); string tam = ""; while (dr.Read()) { tam = dr[0].ToString(); } L_Ketnoi.HuyKetNoi(); if (tam != "") { L_Ketnoi.ThietlapketNoi(); SqlDataReader dr1 = dl.lay_reader("select masachhong from sachhong"); string strtam = ""; while (dr1.Read()) { strtam = dr1[0].ToString(); } L_Ketnoi.HuyKetNoi(); Lsachhong sh = new Lsachhong(masachhong(strtam), Frmthongbao.tam); if (sh.taomoi()) { load_grid(); MessageBox.Show("Thao tác thành công", "Thông báo"); } else { MessageBox.Show("Lỗi trong tạo mới", "Thông báo"); } } else { if (MessageBox.Show("Không có đối tượng sách này hãy nhập lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Question) == DialogResult.OK) { tb.ShowDialog(this); } } } }