private void xoabtn_Click(object sender, EventArgs e) { int dem = 0; int kq = 0; for (int i = Dgv.Rows.Count - 1; i >= 0; i--) { if (Dgv.Rows[i].Cells[0].Value != null) { dem = dem + 1; } } kq = dem; if (kq == 0) { MessageBox.Show("Bạn chưa chọn thông tin để xóa !", "Thông Báo !", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (MessageBox.Show("Bạn có muốn xóa những thông tin đã chọn này ?", "Thông Báo !", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { for (int i = Dgv.Rows.Count - 1; i >= 0; i--) { if (Dgv.Rows[i].Cells[0].Value != null) { con.excute("Delete from thuthu where matt='" + Dgv.Rows[i].Cells[3].Value + "'"); load(); } } MessageBox.Show("Đã xóa thủ thư thành công !", "Thông Báo !", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnadd_Click(object sender, EventArgs e) { String sql = "Insert into thuthu(matt,tentt,ns,qq,choOHT,cmnd,anh,matkhau,tglv,sdt,email,gt) values('" + taoma() + "','" + txtten.Text + "','" + txtns.Text + "','" + txtqq.Text + "','" + txtadr.Text + "','" + txtcmnd.Text + "','" + txtanh.Text + "','" + taoma() + "','0','" + txtsdt.Text + "','" + txtemail.Text + "','" + gioitinh() + "')"; if (con.excute(sql)) { MessageBox.Show("Đã thêm thủ thư thành công !", "Thông Báo !", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Đã thêm thủ thư thất bại !", "Thông Báo !", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Btupdate_Click(object sender, EventArgs e) { string kq = "Update thuthu Set anh ='" + txtanh.Text + "',tentt ='" + txtten.Text + "',gt='" + gioitinh() + "',matkhau ='" + txtmk.Text + "',ns ='" + txtns.Text + "',qq ='" + txtqq.Text + "',choOHT ='" + txtadr.Text + "',cmnd ='" + txtcmnd.Text + "',sdt='" + txtsdt.Text + "',email ='" + txtemail.Text + "' where matt ='" + lbmatt.Text + "'"; //cn.excute(kq); if (cn.excute(kq)) { MessageBox.Show("Đã sua thủ thư thành công !", "Thông Báo !", MessageBoxButtons.OK, MessageBoxIcon.Information);; this.Close(); } else { MessageBox.Show("Đã sua thủ thư that bai !", "Thông Báo !", MessageBoxButtons.OK, MessageBoxIcon.Information);; } }
private void dmkbtn_Click(object sender, EventArgs e) { string qr = "SELECT* FROM NQT WHERE mQT='" + txtmqt.Text + "'and mk = '" + txtmkcu.Text + "'"; string sql = "UPDATE NQT SET mk=N '" + txtmkm.Text + "' WHERE nane=N'" + txtmqt.Text + "'"; DataTable dt = cn.getdata(qr); if (txtmkcu.Text == "" || txtmkm.Text == "" || txtxn.Text == "" || txtmqt.Text == "") { MessageBox.Show("Bạn chưa nhập đầy đủ"); } else if (txtmkm.Text != txtxn.Text) { MessageBox.Show("Mật khẩu của bạn không trùng khớp"); } else if (dt.Rows.Count > 0) { cn.excute(sql); MessageBox.Show("Đổi mật khẩu thành công"); } else { MessageBox.Show("Đổi mật khẩu thất bại"); } }