private void bt_xoa_Click(object sender, EventArgs e) { string makh = txt_makh.Text; if (makh.Length != 0) { khachhang_DTO kh = new khachhang_DTO(makh, makh, "", makh, makh, makh, makh, makh, makh); DialogResult ok = MessageBox.Show("Bạn có muốn xóa " + makh, "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (ok == DialogResult.Yes) { if (khachhang_BUS.Instance.xoakhachhang(kh)) { MessageBox.Show("Bạn đã xóa thành công phòng ", makh); loadkhachhang(); } else { MessageBox.Show("Rất tiếc, Xóa không thành công"); } } } else { MessageBox.Show("Mời bạn chọn đối tượng muốn xóa", "Thông báo"); } }
//THÊM SỬA XÓA private void bt_them_Click(object sender, EventArgs e) { string querycheck = "SELECT count([ID]) FROM t_khachhang WHERE ([ID] = '" + txt_makh.Text + "') "; if (txt_makh.Text != "" && txt_tenkh.Text != "") { if (khachhang_BUS.Instance.checktrung(querycheck) == false) { khachhang_DTO kh = new khachhang_DTO(txt_makh.Text, txt_tenkh.Text, dt_ngaysinh.Value.ToString("MM/dd/yyyy"), cb_gioitinh.Text, txt_sdt.Text, txt_cmnd.Text, txt_quoctich.Text, txt_email.Text, lb_temp.Text); if (khachhang_BUS.Instance.themkhachhang(kh)) { MessageBox.Show("Bạn đã thêm thành công khách hàng ", txt_makh.Text); loadkhachhang(); } else { MessageBox.Show("Rất tiếc, thêm không thành công"); } } else { MessageBox.Show("Mã phòng bị trùng, vui lòng nhập lại"); } } else { MessageBox.Show("Mời nhập đầy đủ thông tin"); } }
public DataTable timkhachhang(khachhang_DTO kh) { string query = "SELECT * FROM t_khachhang WHERE ID like N'%" + kh.Key + "%' or Ten like N'%" + kh.Key + "%' or Sdt like N'%" + kh.Key + "%' or CMND like N'%" + kh.Key + "%'"; DataTable result = new DataTable(); result = processdata.Instance.ExecuteQuery(query); return(result); }
public bool xoakhachhang(khachhang_DTO kh) { string query = "DELETE FROM t_khachhang WHERE ID ='" + kh.Makh + "'"; if (processdata.Instance.ExecuteNonQuery(query)) { return(true); } else { return(false); } }
public bool suakhachhang(khachhang_DTO kh) { string query = "UPDATE t_khachhang SET ID=N'" + kh.Makh + "',Ten=N'" + kh.Tenkh + "',Ngaysinh=N'" + kh.Ngaysinh + "',Gioitinh=N'" + kh.Gioitinh + "',Sdt=N'" + kh.Sdt + "',Cmnd=N'" + kh.Cmnd + "',Quoctich=N'" + kh.Quoctich + "',Email=N'" + kh.Email + "'where ID='" + kh.Temp + "'"; if (processdata.Instance.ExecuteNonQuery(query)) { return(true); } else { return(false); } }
public bool themkhachhang(khachhang_DTO kh) { string query = "INSERT INTO t_khachhang VALUES(N'" + kh.Makh + "',N'" + kh.Tenkh + "',N'" + kh.Ngaysinh + "',N'" + kh.Gioitinh + "',N'" + kh.Sdt + "',N'" + kh.Cmnd + "',N'" + kh.Quoctich + "',N'" + kh.Email + "')"; if (processdata.Instance.ExecuteNonQuery(query)) { return(true); } else { return(false); } }
private void bt_timphong_Click(object sender, EventArgs e) { string key = txt_tim.Text; if (key.Length != 0) { khachhang_DTO kh = new khachhang_DTO(key); dgv_khachhang.DataSource = khachhang_BUS.Instance.timkhachhang(kh); } else { MessageBox.Show("Mời nhập thông tin muốn tìm kiếm"); } }
private void bt_sua_Click(object sender, EventArgs e) { string temp = lb_temp.Text; if (txt_makh.Text != "" && txt_tenkh.Text != "") { khachhang_DTO kh = new khachhang_DTO(txt_makh.Text, txt_tenkh.Text, dt_ngaysinh.Value.ToString("MM/dd/yyyy"), cb_gioitinh.SelectedItem.ToString(), txt_sdt.Text, txt_cmnd.Text, txt_quoctich.Text, txt_email.Text, lb_temp.Text); if (khachhang_BUS.Instance.suakhachhang(kh)) { MessageBox.Show("Bạn đã sửa thành công phòng : ", txt_makh.Text); loadkhachhang(); } else { MessageBox.Show("Rất tiếc, Sửa không thành công"); } } else { MessageBox.Show("Mời bạn nhập đầy đủ thông tin", "Thông báo"); } }
public DataTable timkhachhang(khachhang_DTO kh) { return(khachhang_DAO.Instance.timkhachhang(kh)); }
public bool suakhachhang(khachhang_DTO kh) { return(khachhang_DAO.Instance.suakhachhang(kh)); }
public bool themkhachhang(khachhang_DTO kh) { return(khachhang_DAO.Instance.themkhachhang(kh)); }