public bool DeletePublisherToDatabase(CPublisherDTO _publisherObject) { m_cmd = new SqlCommand(); m_cmd.CommandType = CommandType.StoredProcedure; m_cmd.CommandText = "DeletePublisherDataToDatabase"; m_cmd.Parameters.Add("MaNXB", SqlDbType.NVarChar).Value = _publisherObject.maNhaXuatBan; return(m_publisherExecute.updateData(m_cmd) > 0); }
private void btnUpdate_Click(object sender, EventArgs e) { try { m_PublisherObject = new CPublisherDTO(txtPublisherId.Text, txtPublisherName.Text, txtPublisherAddress.Text); m_PublisherExecute.UpdatePublisherToDatabase(m_PublisherObject); m_PublisherData = m_PublisherExecute.getPublisherDataFromDatabase(); grdListPublisher.DataSource = m_PublisherData; grdvListPublisher.FocusedRowHandle = grdvListPublisher.DataRowCount - 1; } catch (System.Exception ex) { XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } }
private void btnSave_Click(object sender, EventArgs e) { if (!checkData()) { return; } try { if (m_IsAdd) { m_PublisherObject = new CPublisherDTO("NXB000000", txtPublisherName.Text, txtPublisherAddress.Text); if (m_PublisherExecute.AddPublisherToDatabase(m_PublisherObject)) { XtraCustomMessageBox.Show("Thêm dữ liệu thành công !", "Thông báo", true); } else { XtraCustomMessageBox.Show("Thêm dữ liệu thất bại !", "Lỗi", true); } } else { m_PublisherObject = new CPublisherDTO(txtPublisherId.Text, txtPublisherName.Text, txtPublisherAddress.Text); if (m_PublisherExecute.UpdatePublisherToDatabase(m_PublisherObject)) { XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công !", "Thông báo", true); } else { XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại !", "Lỗi", true); } } } catch (System.Exception) { XtraCustomMessageBox.Show("Lưu dữ liệu thất bại!", "Lỗi", true); } finally { updateEnableButtonAndResetValueOfControl(ref btnSave); } }
private void btnDelete_Click(object sender, EventArgs e) { try { foreach (object _rowObjectItem in m_PublisherMulitSelect.Selection) { grdvListPublisher.FocusedRowHandle -= 1; DataRowView _rowObjectDetail = _rowObjectItem as DataRowView; m_PublisherObject = new CPublisherDTO(_rowObjectDetail.Row["MaNXB"].ToString(), _rowObjectDetail.Row["TenNXB"].ToString(), _rowObjectDetail.Row["DiaChi"].ToString()); m_PublisherExecute.DeletePublisherToDatabase(m_PublisherObject); m_PublisherData = new DataTable(); m_PublisherData = m_PublisherExecute.getPublisherDataFromDatabase(); grdListPublisher.DataSource = m_PublisherData; grdvListPublisher.FocusedRowHandle = grdvListPublisher.DataRowCount - 1; } } catch (System.Exception ex) { XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } }
private void btnDelete_Click(object sender, EventArgs e) { try { ArrayList _listPublisherId = new ArrayList(); foreach (object _rowObjectItem in m_PublisherMulitSelect.Selection) { grdvListPublisher.FocusedRowHandle -= 1; DataRowView _rowObjectDetail = _rowObjectItem as DataRowView; m_PublisherObject = new CPublisherDTO(_rowObjectDetail.Row["MaNXB"].ToString(), _rowObjectDetail.Row["TenNXB"].ToString(), _rowObjectDetail.Row["DiaChi"].ToString()); if (!m_PublisherExecute.DeletePublisherToDatabase(m_PublisherObject)) { _listPublisherId.Add(_rowObjectDetail.Row["MaNXB"]); } } if (_listPublisherId.Count != 0) { String _erroContent = "Không thể xóa các nhà xuất bản có mã: \n"; foreach (var item in _listPublisherId) { _erroContent += item.ToString() + "\n"; } XtraCustomMessageBox.Show(_erroContent, "Lỗi", true); } else { XtraCustomMessageBox.Show("Xóa dữ liệu thành công!", "Thông báo", true); } } catch (System.Exception) { XtraCustomMessageBox.Show("Xóa dữ liệu thất bại!", "Lỗi", true); } finally { updateEnableButtonAndResetValueOfControl(ref btnDelete); } }
public CPublisherDAL() { m_publisherObject = null; m_publisherExecute = new CDataExecute(); m_cmd = new SqlCommand(); }
public CPublisherDAL(CPublisherDTO _publisherObject) { m_publisherObject = _publisherObject; m_publisherExecute = new CDataExecute(); m_cmd = new SqlCommand(); }
public bool UpdatePublisherToDatabase(CPublisherDTO _publisherObject) { return(m_PublisherDAL.UpdatePublisherToDatabase(_publisherObject)); }
public bool DeletePublisherToDatabase(CPublisherDTO _publisherObject) { return(m_PublisherDAL.DeletePublisherToDatabase(_publisherObject)); }
public bool AddPublisherToDatabase(CPublisherDTO _publisherObject) { return(m_PublisherDAL.AddPublisherToDatabase(_publisherObject)); }