private void frmtaothe_Load(object sender, EventArgs e) { if (dr == null) { laydulieu dl = new laydulieu(); dr = dl.lay_reader("select * from docgia order by madocgia desc"); } int tam = 0; while (dr.Read()) { try { listView1.Items.Add(dr[0].ToString()); st[tam] = listView1.Items[tam].Text; listView1.Items[tam].SubItems.Add(dr[1].ToString()); listView1.Items[tam].SubItems.Add(dr[2].ToString()); string luu = dr[4].ToString(); listView1.Items[tam].SubItems.Add(luu.Substring(0, luu.Length - 3)); listView1.Items[tam].SubItems.Add(luu.Substring(luu.Length - 3, 3)); listView1.Items[tam].SubItems.Add(dr[5].ToString()); tam++; } catch { MessageBox.Show("Lỗi dữ liệu nhập vào"); Frmmain.hf.set_text(" Kiểm tra lại dữ liệu nhập vào đi xem có đúng không"); } } L_Ketnoi.HuyKetNoi(); }
private void button1_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { string str = listView1.SelectedItems[0].Text; int i = 0; laydulieu dl = new laydulieu(); SqlDataReader dr = dl.lay_reader("select * from docgia"); while (dr.Read()) { if (dr[0].ToString() == str) { break; } else { i++; } } L_Ketnoi.HuyKetNoi(); Frmquanlybandoc.i = i; Frmquanlybandoc bd = new Frmquanlybandoc(); bd.MdiParent = this.MdiParent; bd.set_giattri(); bd.Show(); } else { MessageBox.Show("Bạn phải chọn một đối tượng độc giả"); }; }
private void Formhienthi_Load(object sender, EventArgs e) { Frmmain.tt = true; try { L_Ketnoi.ThietlapketNoi(); cmd = new SqlCommand(chuoiketnoi, L_Ketnoi.cn); da.SelectCommand = cmd; da.Fill(ds, bangketnoi); bmb = BindingContext[this.ds.Tables[0]] as CurrencyManager; this.dghienthi.DataSource = ds.Tables[0]; switch (bangketnoi) { case "tacgia": this.cbdanhmuc.Items.AddRange(new object[] { "tentacgia" }); break; case "phanloai": this.cbdanhmuc.Items.AddRange(new object[] { "loai" }); break; case "nhaxuatban": this.cbdanhmuc.Items.AddRange(new object[] { "ten" }); break; case "ngonngu": this.cbdanhmuc.Items.AddRange(new object[] { "ngonngu" }); break; case "khoa": this.cbdanhmuc.Items.AddRange(new object[] { "tenkhoa" }); break; } ; } catch { MessageBox.Show("error: ket noi du lieu "); } }
private void btkiemtratt_Click(object sender, EventArgs e) { laydulieu dl = new laydulieu(); bool tam = false; SqlDataReader dr = dl.lay_reader("select * from phieumuon where phieumuon.masach='" + txtmasach.Text + "' and phieumuon.madocgia='" + txtmadocgia.Text + "' and phieumuon.thethucmuon=N'Mượn về nhà'"); while (dr.Read()) { txtngaymuon.Text = dr["ngaymuon"].ToString(); maphieumuon = dr["maphieumuon"].ToString(); tam = true; } L_Ketnoi.HuyKetNoi(); btgiahan.Enabled = tam; if (tam) { txtmasach.Enabled = false; txtmadocgia.Enabled = false; btkiemtratt.Enabled = false; btgiahan.Enabled = true; } else { txtmasach.Enabled = true; txtmadocgia.Enabled = true; btkiemtratt.Enabled = true; btgiahan.Enabled = false; } }
private void Load_treeview() { laydulieu dl = new laydulieu(); SqlDataReader dr = dl.lay_reader("select * from phanloai"); while (dr.Read()) { TreeNode tn = new TreeNode(); tn.Tag = dr[0].ToString(); tn.Text = dr[1].ToString(); tn.ImageIndex = 1; treeView1.Nodes.Add(tn); comboBox1.Items.Add(dr[1].ToString()); } L_Ketnoi.HuyKetNoi(); foreach (TreeNode n in treeView1.Nodes) { laydulieu dl1 = new laydulieu(); SqlDataReader dr1 = dl1.lay_reader("select * from sach where maphanloai='" + n.Tag.ToString().Trim() + "'"); while (dr1.Read()) { TreeNode tn1 = new TreeNode(); tn1.Tag = dr1[0].ToString(); tn1.Text = dr1[1].ToString(); tn1.ImageIndex = 0; n.Nodes.Add(tn1); } L_Ketnoi.HuyKetNoi(); } }
private void btkiemtratt_Click(object sender, EventArgs e) { laydulieu dl = new laydulieu(); bool tam = false; SqlDataReader dr = dl.lay_reader("select * from phieumuon,sachmuon where phieumuon.maphieumuon = sachmuon.maphieumuon and phieumuon.madocgia='" + txtmadocgia.Text + "' and phieumuon.thethucmuon=N'" + comboBox1.Text + "'"); while (dr.Read()) { txtngaymuon.Text = dr["ngaymuon"].ToString(); DateTime tam1 = DateTime.Parse(dr["ngaymuon"].ToString()); txtsongaymuon.Text = ((TimeSpan)(DateTime.Now - tam1)).Days.ToString(); txtsosachmuon.Text = dr["soluong"].ToString(); maphieumuon = dr["maphieumuon"].ToString(); txtmasach.Text = dr["masach"].ToString(); tam = true; } L_Ketnoi.HuyKetNoi(); bttrasach.Enabled = tam; if (tam) { txtmadocgia.Enabled = false; comboBox1.Enabled = false; btkiemtratt.Enabled = false; } }
private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e) { DateTime dau = monthCalendar1.SelectionStart; DateTime cuoi = monthCalendar1.SelectionEnd; listView1.Items.Clear(); while (dau <= cuoi) { laydulieu dl = new laydulieu(); dr = dl.lay_reader("select phieumuon.masach,nhande,tentacgia,thethucmuon,phieumuon.madocgia,phieumuon.soluong from phieumuon,sach,tacgia where phieumuon.masach = sach.masach and sach.matacgia = tacgia.matacgia and phieumuon.thethucmuon like N'%" + comboBox1.Text + "%' and ngaymuon ='" + dau.ToShortDateString() + "'"); int i = 0; while (dr.Read()) { listView1.Items.Add(dr[0].ToString()); listView1.Items[i].SubItems.Add(dr[1].ToString()); listView1.Items[i].SubItems.Add(dr[2].ToString()); listView1.Items[i].SubItems.Add(dr[3].ToString()); listView1.Items[i].SubItems.Add(dr[4].ToString()); listView1.Items[i].SubItems.Add(dr[5].ToString()); i++; } L_Ketnoi.HuyKetNoi(); dau = dau.AddDays(1); } }
void Load_combobox() { laydulieu dl = new laydulieu(); SqlDataReader dr1 = dl.lay_reader("select loai from phanloai"); while (dr1.Read()) { cbloaisach.Items.Add(dr1[0].ToString()); } L_Ketnoi.HuyKetNoi(); L_Ketnoi.ThietlapketNoi(); SqlDataReader dr2 = dl.lay_reader("select ngonngu from ngonngu"); while (dr2.Read()) { cbngonngu.Items.Add(dr2[0].ToString()); } L_Ketnoi.HuyKetNoi(); L_Ketnoi.ThietlapketNoi(); SqlDataReader dr3 = dl.lay_reader("select tentacgia from tacgia"); while (dr3.Read()) { cbtacgiac.Items.Add(dr3[0].ToString()); } L_Ketnoi.HuyKetNoi(); }
void Load_textbox(string str) { laydulieu dl = new laydulieu(); SqlDataReader dr = dl.lay_reader("select * from tacgia,phanloai,ngonngu,sach,vitriluutru,nhaxuatban where sach.mavitri = vitriluutru.mavitri and sach.maphanloai = phanloai.maphanloai and tacgia.matacgia = sach.matacgia and sach.mangonngu = ngonngu.mangonngu and sach.manxb = nhaxuatban.manxb and sach.masach='" + str + "'"); while (dr.Read()) { txtmasach.Text = str; txtnamxuatban.Text = DateTime.Parse(dr["namxb"].ToString()).ToShortDateString(); txtngan.Text = dr["ngan"].ToString(); txtnhande.Text = dr["nhande"].ToString(); txtsolanmuon.Text = dr["solanmuon"].ToString(); txtsoluong.Text = dr["soluong"].ToString(); txtsotrang.Text = dr["sotrang"].ToString(); txtke.Text = dr["ke"].ToString(); txtkho.Text = dr["kho"].ToString(); txtlanxuatban.Text = dr["lanxb"].ToString(); cbloaisach.Text = dr["loai"].ToString(); cbngonngu.Text = dr["ngonngu"].ToString(); cbnhaxuatban.Text = dr["ten"].ToString(); cbtacgia.Text = dr["tentacgia"].ToString(); txtngaynhap.Text = DateTime.Parse(dr["ngaynhap"].ToString()).ToShortDateString(); cbthethuc.Text = dr["thethuc"].ToString(); } L_Ketnoi.HuyKetNoi(); }
string mangonngu() { laydulieu dl = new laydulieu(); string tam = ""; int i = 0; SqlDataReader dr = dl.lay_reader("select mangonngu from ngonngu"); while (dr.Read()) { tam = dr[0].ToString(); } L_Ketnoi.HuyKetNoi(); i = int.Parse(tam.Substring(2, tam.Length - 2)); i++; if (i < 10) { return("NN00" + i.ToString()); } else if (i < 100) { return("NN0" + i.ToString()); } else { return("NN" + i.ToString()); } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { string str = treeView1.SelectedNode.Tag.ToString(); laydulieu dl = new laydulieu(); SqlDataReader dr = dl.lay_reader("select * from tacgia,phanloai,ngonngu,sach,vitriluutru,nhaxuatban where sach.mavitri = vitriluutru.mavitri and sach.maphanloai = phanloai.maphanloai and tacgia.matacgia = sach.matacgia and sach.mangonngu = ngonngu.mangonngu and sach.manxb = nhaxuatban.manxb and sach.masach='" + str + "'"); while (dr.Read()) { txtmasach.Text = str; txtnamxuatban.Text = DateTime.Parse(dr["namxb"].ToString()).ToShortDateString(); txtngan.Text = dr["ngan"].ToString(); txtnhande.Text = dr["nhande"].ToString(); txtsolanmuon.Text = dr["solanmuon"].ToString(); txtsoluong.Text = dr["soluong"].ToString(); txtsotrang.Text = dr["sotrang"].ToString(); txtke.Text = dr["ke"].ToString(); txtkho.Text = dr["kho"].ToString(); txtlanxuatban.Text = dr["lanxb"].ToString(); cbloaisach.Text = dr["loai"].ToString(); cbngonngu.Text = dr["ngonngu"].ToString(); cbnhaxuatban.Text = dr["ten"].ToString(); cbtacgia.Text = dr["tentacgia"].ToString(); txtngaynhap.Text = DateTime.Parse(dr["ngaynhap"].ToString()).ToShortDateString(); } L_Ketnoi.HuyKetNoi(); }
private void bttaomoi_Click(object sender, EventArgs e) { if (bttaomoi.Text == "OK") { laydulieu dl = new laydulieu(); SqlDataReader dr = dl.lay_reader("select makhoa from khoa where tenkhoa=N'" + txttenkhoa.Text + "'"); string tam = ""; while (dr.Read()) { tam = dr[0].ToString(); } L_Ketnoi.HuyKetNoi(); if (tam == "") { MessageBox.Show("Bạn hãy kiểm tra lại giá trị khoa"); } else { try { DateTime ns = DateTime.Parse(DateTime.Parse(txtngaysinh.Text).ToShortDateString()); Lbandoc bd = new Lbandoc(txtmadocgia.Text, txthoten.Text, tam, txtvitri.Text, txtdiachi.Text, ns, DateTime.Parse(txtngaylapthe.Text)); if (bd.taomoi()) { txtdiachi.Enabled = txthoten.Enabled = txtngaysinh.Enabled = txttenkhoa.Enabled = txtvitri.Enabled = false; bttaomoi.Text = "Tạo mới"; btcapnhat.Enabled = btxoabo.Enabled = true; ctcapnhat.Enabled = cttaomoi.Enabled = ctxoabo.Enabled = ctchondoituong.Enabled = true; Frmquanlybandoc_Load(sender, e); MessageBox.Show("Quá trình tạo mới hoàn thành"); Frmmain.hf.timer5.Enabled = true; Frmmain.hf.set_text(" OK làm tốt lắm !"); Frmmain.hf.set_anh(3); } else { MessageBox.Show("Bị lỗi hãy kiểm tra lại thông tin"); } } catch { Frmmain.hf.set_anh(2); Frmmain.hf.set_text(" Chú ý ngày sinh có dạng như sau : ngày/tháng/năm nhập lại cho đúng đi "); Frmmain.hf.timer5.Enabled = true; } } } else { txtdiachi.Enabled = txthoten.Enabled = txtngaysinh.Enabled = txttenkhoa.Enabled = txtvitri.Enabled = true; txtdiachi.Text = txthoten.Text = txtngaysinh.Text = txtvitri.Text = ""; txtngaylapthe.Text = DateTime.Now.ToShortDateString(); bttaomoi.Text = "OK"; string macuoi = taoma(ds.Tables[1].Rows[cm.Count - 1]["madocgia"].ToString()); txtmadocgia.Text = macuoi; btcapnhat.Enabled = btxoabo.Enabled = false; ctcapnhat.Enabled = cttaomoi.Enabled = ctxoabo.Enabled = ctchondoituong.Enabled = false; } }
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 Frmthongtinsachtrongngay_Load(object sender, EventArgs e) { Frmmain.tt = true; laydulieu dl = new laydulieu(); dr = dl.lay_reader("select phieumuon.masach,nhande,tentacgia,phieumuon.madocgia,phieumuon.soluong from phieumuon,sach,tacgia where phieumuon.masach = sach.masach and sach.matacgia = tacgia.matacgia and phieumuon.thethucmuon like N'%" + "Mượn về nhà" + "%' and ngaymuon ='" + DateTime.Now.ToShortDateString() + "'"); int i = 0; while (dr.Read()) { listView1.Items.Add(dr[0].ToString()); listView1.Items[i].SubItems.Add(dr[1].ToString()); listView1.Items[i].SubItems.Add(dr[2].ToString()); listView1.Items[i].SubItems.Add(dr[3].ToString()); listView1.Items[i].SubItems.Add(dr[4].ToString()); i++; } L_Ketnoi.HuyKetNoi(); L_Ketnoi.ThietlapketNoi(); dr = dl.lay_reader("select phieumuon.masach,nhande,tentacgia,phieumuon.madocgia,phieumuon.soluong from phieumuon,sach,tacgia where phieumuon.masach = sach.masach and sach.matacgia = tacgia.matacgia and phieumuon.thethucmuon like N'%" + "Mượn tại chỗ" + "%' and ngaymuon ='" + DateTime.Now.ToShortDateString() + "'"); i = 0; while (dr.Read()) { listView2.Items.Add(dr[0].ToString()); listView2.Items[i].SubItems.Add(dr[1].ToString()); listView2.Items[i].SubItems.Add(dr[2].ToString()); listView2.Items[i].SubItems.Add(dr[3].ToString()); listView2.Items[i].SubItems.Add(dr[4].ToString()); i++; } L_Ketnoi.HuyKetNoi(); L_Ketnoi.ThietlapketNoi(); dr = dl.lay_reader("select phieumuon.masach,nhande,tentacgia,phieumuon.madocgia,phieumuon.soluong from phieumuon,sach,tacgia where phieumuon.masach = sach.masach and sach.matacgia = tacgia.matacgia and phieumuon.thethucmuon like N'%" + "Mượn giáo trình" + "%' and ngaymuon ='" + DateTime.Now.ToShortDateString() + "'"); i = 0; while (dr.Read()) { listView3.Items.Add(dr[0].ToString()); listView3.Items[i].SubItems.Add(dr[1].ToString()); listView3.Items[i].SubItems.Add(dr[2].ToString()); listView3.Items[i].SubItems.Add(dr[3].ToString()); listView3.Items[i].SubItems.Add(dr[4].ToString()); i++; } L_Ketnoi.HuyKetNoi(); L_Ketnoi.ThietlapketNoi(); dr = dl.lay_reader("select phieumuon.masach,phieumuon.madocgia from phieumuon,sachmuon where phieumuon.maphieumuon = sachmuon.maphieumuon and phieumuon.thethucmuon like N'%" + "Mượn tại chỗ" + "%' and ngaymuon ='" + DateTime.Now.ToShortDateString() + "'"); i = 0; while (dr.Read()) { listView4.Items.Add(dr[0].ToString()); listView4.Items[i].SubItems.Add(dr[1].ToString()); i++; } L_Ketnoi.HuyKetNoi(); }
private void Formhienthi_FormClosing(object sender, FormClosingEventArgs e) { if (ds.GetChanges() != null) { if (MessageBox.Show("Đã có sự thay đổi dữ liệu bạn có muốn lưu lại hay không ?", "Thong bao", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.capnhat(); } } L_Ketnoi.HuyKetNoi(); }
public bool xoabo() { laydulieu ld = new laydulieu(); if (ld.thucthitruyvan(" delete from nhanvien where manhanvien= '" + manhanvien + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { return(false); } }
public bool taomoi() { laydulieu ld = new laydulieu(); if (ld.thucthitruyvan(" insert into nhanvien values ('" + manhanvien + "',N'" + hoten + "',N'" + diachi + "',N'" + tendangnhap + "','" + matkhau + "','" + quyenhan + "')") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { return(false); } }
public bool capnhat() { laydulieu ld = new laydulieu(); if (ld.thucthitruyvan(" update nhanvien set hoten=N'" + hoten + "',diachi=N'" + diachi + "',tendangnhap=N'" + tendangnhap + "',matkhau=N'" + matkhau + "' where manhanvien='" + manhanvien + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { return(false); } }
public bool doimatkhau(string moi) { laydulieu ld = new laydulieu(); matkhau = moi; if (ld.thucthitruyvan(" update nhanvien set matkhau=N'" + moi + "' where manhanvien='" + manhanvien + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { return(false); } }
public bool giahan() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("update phieumuon set ngaymuon='" + ngaymuon + "' where maphieumuon='" + maphieumuon + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool nangquyen(string quyenmoi) { this.quyenhan = quyenmoi; laydulieu ld = new laydulieu(); if (ld.thucthitruyvan(" update nhanvien set quyenhan ='" + quyenmoi + "' where manhanvien = '" + manhanvien + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { return(false); } }
public bool capnhat() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("update phieumuon set madocgia='" + madocgia + "',thethucmuon=N'" + thethucmuon + "',ngaymuon='" + ngaymuon + "',masach='" + masach + "',manhanvien='" + manhanvien + "',soluongmuon='" + soluongmuon + "' where maphieumuon='" + maphieumuon + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool xoabo() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("delete from phieumuon where maphieumuon='" + maphieumuon + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool capnhat() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("update tacgia set tentacgia=N'" + tentacgia + "' where matacgia='" + matacgia + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool taomoi() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("insert into phieumuon values ('" + maphieumuon + "','" + madocgia + "',N'" + thethucmuon + "','" + ngaymuon + "','" + masach + "','" + manhanvien + "','" + soluongmuon + "')") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool xoabo() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("delete from vitriluutru where mavitri='" + mavitri + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool capnhat() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("update vitriluutru set kho='" + kho + "',ke='" + ke + "',ngan='" + ngan + "' where mavitri='" + mavitri + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool taomoi() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("insert into vitriluutru values ('" + mavitri + "','" + kho + "','" + ke + "','" + ngan + "')") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool taomoi() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("insert into phanloai values ('" + maphanloai + "',N'" + loai + "')") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }
public bool capnhat() { laydulieu dl = new laydulieu(); if (dl.thucthitruyvan("update phanloai set loai = N'" + loai + "' where maphanloai='" + maphanloai + "'") == 1) { L_Ketnoi.HuyKetNoi(); return(true); } else { L_Ketnoi.HuyKetNoi(); return(false); } }