private void button2_Click(object sender, EventArgs e) { //Tra sach if (listView1.SelectedItems.Count > 0) { DialogResult dlr = MessageBox.Show("Bạn muốn trả sách này?", "Thông báo", MessageBoxButtons.YesNo); if (dlr == DialogResult.Yes) { if (new Class_CRUDdb().exeData(exeDelStr)) { new Class_CRUDdb().exeData(exeSaveStr); DataTable dt = new Class_CRUDdb().readData("SELECT * FROM Books WHERE MS='" + curentMS + "'"); DataRow dr = dt.Rows[0]; int sachDaMuon = Int32.Parse(dr["DaMuon"].ToString()); sachDaMuon--; String temp2 = "UPDATE Books SET DaMuon=" + sachDaMuon + " WHERE MS = N'" + curentMS + "'"; new Class_CRUDdb().exeData(temp2); MessageBox.Show("Trả sách THÀNH CÔNG!!"); } else { MessageBox.Show("Trả sách THẤT BẠI!!"); } refeshListView(); } } else { MessageBox.Show("Chọn sách muốn trả."); } }
private void Form_editS_Load(object sender, EventArgs e) { DataTable dt = new Class_CRUDdb().readData("SELECT * FROM Books WHERE MS='" + MS + "'"); DataRow dr = dt.Rows[0]; textBox1.Text = dr["MS"].ToString(); textBox2.Text = dr["Ten"].ToString(); textBox3.Text = dr["TacGia"].ToString(); textBox4.Text = dr["NXB"].ToString(); textBox5.Text = dr["TongSach"].ToString(); textBox6.Text = dr["DaMuon"].ToString(); }
private void Form_editSV_Load(object sender, EventArgs e) { DataTable dt = new Class_CRUDdb().readData("SELECT * FROM Student WHERE MSV='" + MSV + "'"); DataRow dr = dt.Rows[0]; textBox1.Text = dr["MSV"].ToString(); textBox2.Text = dr["Ten"].ToString(); comboBox1.Text = dr["Gioitinh"].ToString(); dateTimePicker1.Text = dr["Ngaysinh"].ToString(); textBox3.Text = dr["DiaChi"].ToString(); textBox4.Text = dr["Email"].ToString(); textBox5.Text = dr["Sdt"].ToString(); }
public Boolean Test() { String temp = "SELECT * FROM Staff WHERE MNV = N'" + Form_Login.MNV + "'"; DataTable dt = new Class_CRUDdb().readData(temp); DataRow dr = dt.Rows[0]; if (!textBox1.Text.Equals(dr["Pass"].ToString())) { return(false); } if (!textBox2.Text.Equals(textBox3.Text)) { return(false); } return(true); }
private void button1_Click(object sender, EventArgs e) { String exeString = "SELECT MNV,Pass FROM Staff WHERE MNV=N'" + textBox1.Text + "' AND Pass= N'" + textBox2.Text + "'"; DataTable dt = new Class_CRUDdb().readData(exeString); if (dt != null && dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; MNV = dr["MNV"].ToString(); new Home(this).Show(); this.Hide(); } else { MessageBox.Show("Username hoặc Password Không đúng!"); } }
private void Form_Staffs_Load(object sender, EventArgs e) { refeshListView(); String temp = "SELECT * FROM Staff WHERE MNV= N'" + Form_Login.MNV + "'"; DataTable dt = new Class_CRUDdb().readData(temp); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; label9.Text = dr["MNV"].ToString(); label12.Text = dr["Tennv"].ToString(); label18.Text = dr["Gioitinh"].ToString(); label14.Text = dr["Ngaysinh"].ToString(); label13.Text = dr["Diachi"].ToString(); label16.Text = dr["Gmail"].ToString(); label15.Text = dr["Sdt"].ToString(); } }
public void refeshListView() { listView1.Items.Clear(); DataTable dt = new Class_CRUDdb().readData("SELECT * FROM BorrowReturn"); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { listView1.Items.Add(dr["MSV"].ToString()); listView1.Items[i].SubItems.Add(dr["MS"].ToString()); listView1.Items[i].SubItems.Add(dr["MNV"].ToString()); listView1.Items[i].SubItems.Add(dr["NgayMuon"].ToString()); listView1.Items[i].SubItems.Add(dr["HanTra"].ToString()); i++; } } }
public void refeshListView() { listView1.Items.Clear(); DataTable dt = new Class_CRUDdb().readData("SELECT * FROM Books"); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { listView1.Items.Add(dr["MS"].ToString()); listView1.Items[i].SubItems.Add(dr["Ten"].ToString()); listView1.Items[i].SubItems.Add(dr["TacGia"].ToString()); listView1.Items[i].SubItems.Add(dr["NXB"].ToString()); listView1.Items[i].SubItems.Add(dr["TongSach"].ToString()); listView1.Items[i].SubItems.Add(dr["DaMuon"].ToString()); i++; } } }
static public void refeshLichsuTraSach() { Form_thongke_LichSu.lv.Items.Clear(); DataTable dt = new Class_CRUDdb().readData("SELECT * FROM ReturnedHistory"); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { Form_thongke_LichSu.lv.Items.Add(dr["MSV"].ToString()); Form_thongke_LichSu.lv.Items[i].SubItems.Add(dr["MS"].ToString()); Form_thongke_LichSu.lv.Items[i].SubItems.Add(dr["MNV"].ToString()); Form_thongke_LichSu.lv.Items[i].SubItems.Add(dr["NgayMuon"].ToString()); Form_thongke_LichSu.lv.Items[i].SubItems.Add(dr["HanTra"].ToString()); Form_thongke_LichSu.lv.Items[i].SubItems.Add(dr["NgayTra"].ToString()); i++; } } }
static public void refeshSachDaMuon() { Form_thongke_SachDaMuon.lv.Items.Clear(); DataTable dt = new Class_CRUDdb().readData("SELECT * FROM Books"); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { Form_thongke_SachDaMuon.lv.Items.Add(dr["MS"].ToString()); Form_thongke_SachDaMuon.lv.Items[i].SubItems.Add(dr["Ten"].ToString()); Form_thongke_SachDaMuon.lv.Items[i].SubItems.Add(dr["TacGia"].ToString()); Form_thongke_SachDaMuon.lv.Items[i].SubItems.Add(dr["NXB"].ToString()); int conlai = Int32.Parse(dr["TongSach"].ToString()) - Int32.Parse(dr["DaMuon"].ToString()); Form_thongke_SachDaMuon.lv.Items[i].SubItems.Add(conlai.ToString()); i++; } } }
private void button4_Click(object sender, EventArgs e) { listView1.Items.Clear(); String temp = "SELECT * FROM Books WHERE " + comboBox1.Text + "= N'" + textBox1.Text + "'"; DataTable dt = new Class_CRUDdb().readData(temp); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { listView1.Items.Add(dr["MS"].ToString()); listView1.Items[i].SubItems.Add(dr["Ten"].ToString()); listView1.Items[i].SubItems.Add(dr["TacGia"].ToString()); listView1.Items[i].SubItems.Add(dr["NXB"].ToString()); listView1.Items[i].SubItems.Add(dr["TongSach"].ToString()); listView1.Items[i].SubItems.Add(dr["DaMuon"].ToString()); i++; } } }
public void refeshListView() { listView1.Items.Clear(); DataTable dt = new Class_CRUDdb().readData("SELECT * FROM Staff"); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { listView1.Items.Add(dr["MNV"].ToString()); listView1.Items[i].SubItems.Add(dr["Tennv"].ToString()); listView1.Items[i].SubItems.Add(dr["Gioitinh"].ToString()); listView1.Items[i].SubItems.Add(dr["NgaySinh"].ToString()); listView1.Items[i].SubItems.Add(dr["Diachi"].ToString()); listView1.Items[i].SubItems.Add(dr["Gmail"].ToString()); listView1.Items[i].SubItems.Add(dr["Sdt"].ToString()); i++; } } }
private void sendEmailToolStripMenuItem_Click_1(object sender, EventArgs e) { toMmail = null; DataTable dt = new Class_CRUDdb().readData(exeStr); DataRow dr = dt.Rows[0]; if (dt != null) { toMmail = dr["Email"].ToString();; } fromMail = null; exeStr = "SELECT Gmail FROM Staff WHERE MNV = N'" + Form_Login.MNV + "'"; dt = new Class_CRUDdb().readData(exeStr); dr = dt.Rows[0]; if (dt != null) { fromMail = dr["Gmail"].ToString();; } new Form_sendEmail(toMmail, fromMail).ShowDialog(); }
private void button4_Click_1(object sender, EventArgs e) { listView1.Items.Clear(); String temp = "SELECT * FROM Student WHERE " + comboBox1.Text + "= N'" + textBox1.Text + "'"; DataTable dt = new Class_CRUDdb().readData(temp); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { listView1.Items.Add(dr["MSV"].ToString()); listView1.Items[i].SubItems.Add(dr["Ten"].ToString()); listView1.Items[i].SubItems.Add(dr["Gioitinh"].ToString()); listView1.Items[i].SubItems.Add(dr["NgaySinh"].ToString()); listView1.Items[i].SubItems.Add(dr["DiaChi"].ToString()); listView1.Items[i].SubItems.Add(dr["Email"].ToString()); listView1.Items[i].SubItems.Add(dr["Sdt"].ToString()); i++; } } }
static public void refeshSinhvienQuahan() { Form_thongke_SVQuaHan.lv.Items.Clear(); DataTable dt = new Class_CRUDdb().readData("SELECT * FROM BorrowReturn"); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { int result = DateTime.Compare(DateTime.Parse(dr["HanTra"].ToString()), DateTime.Now); if (result < 0) { Form_thongke_SVQuaHan.lv.Items.Add(dr["MSV"].ToString()); Form_thongke_SVQuaHan.lv.Items[i].SubItems.Add(dr["MS"].ToString()); Form_thongke_SVQuaHan.lv.Items[i].SubItems.Add(dr["MNV"].ToString()); Form_thongke_SVQuaHan.lv.Items[i].SubItems.Add(dr["NgayMuon"].ToString()); Form_thongke_SVQuaHan.lv.Items[i].SubItems.Add(dr["HanTra"].ToString()); i++; } } } }
private void button4_Click(object sender, EventArgs e) { //Search String type; if (radioButton1.Checked) { type = "MSV"; } else if (radioButton2.Checked) { type = "MS"; } else { type = "MNV"; } listView1.Items.Clear(); String temp = "SELECT * FROM BorrowReturn WHERE " + type + "= N'" + textBox1.Text + "'"; DataTable dt = new Class_CRUDdb().readData(temp); int i = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { listView1.Items.Add(dr["MSV"].ToString()); listView1.Items[i].SubItems.Add(dr["MS"].ToString()); listView1.Items[i].SubItems.Add(dr["MNV"].ToString()); listView1.Items[i].SubItems.Add(dr["NgayMuon"].ToString()); listView1.Items[i].SubItems.Add(dr["HanTra"].ToString()); i++; } } }