private void btnSave_Click(object sender, EventArgs e) { if (m_DeliveryNoteDetailData.Rows.Count != 0) { m_DeliveryNoteObject = new CDeliveryNoteDTO("HD00000000", lkCustomerName.EditValue.ToString(), DateTime.ParseExact(labDeliveryDateValue.Text, "dd/MM/yyyy", null), "NV0000001", int.Parse(grdvDeliveryBook.Columns["SoLuong"].SummaryItem.SummaryValue.ToString()), int.Parse(grdvDeliveryBook.Columns["ThanhTien"].SummaryItem.SummaryValue.ToString())); _soHoaDon = m_DeliveryNoteExecute.getDeliveryNoteMaxIdFromDatabase(); if (m_DeliveryNoteExecute.AddDeliveryNoteToDatabase(m_DeliveryNoteObject)) { foreach (DataRow _rowValue in m_DeliveryNoteDetailData.Select()) { m_DeliveryNoteDetailObject = new CDeliveryNoteDetailDTO(); m_DeliveryNoteDetailObject.soHoaDon = _soHoaDon; m_DeliveryNoteDetailObject.maSach = _rowValue["MaSach"].ToString(); m_DeliveryNoteDetailObject.soLuong = int.Parse(_rowValue["SoLuong"].ToString()); m_DeliveryNoteDetailObject.thanhTien = int.Parse(_rowValue["ThanhTien"].ToString()); m_DeliveryNoteDetailObject.giaBan = int.Parse(_rowValue["DonGia"].ToString()); m_DeliveryNoteDetailExecute.AddDeliveryNoteDetailToDatabase(m_DeliveryNoteDetailObject); } } } else { XtraMessageBox.Show("Không có cuốn sách nào được bán!\nXin vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnWrite_Click(object sender, EventArgs e) { try { if (m_DeliveryNoteDetailData.Rows.Count != 0) { m_DeliveryNoteObject = new CDeliveryNoteDTO("HD00000000", lkCustomerName.EditValue.ToString(), DateTime.ParseExact(labDeliveryDateValue.Text, "dd/MM/yyyy", null), ucLogin.m_EmployeeObject.maNhanVien, int.Parse(grdvDeliveryBook.Columns["SoLuong"].SummaryItem.SummaryValue.ToString()), int.Parse(grdvDeliveryBook.Columns["ThanhTien"].SummaryItem.SummaryValue.ToString())); _soHoaDon = m_DeliveryNoteExecute.getDeliveryNoteMaxIdFromDatabase(); if (m_DeliveryNoteExecute.AddDeliveryNoteToDatabase(m_DeliveryNoteObject)) { foreach (DataRow _rowValue in m_DeliveryNoteDetailData.Select()) { m_DeliveryNoteDetailObject = new CDeliveryNoteDetailDTO(); m_DeliveryNoteDetailObject.soHoaDon = _soHoaDon; m_DeliveryNoteDetailObject.maSach = _rowValue["MaSach"].ToString(); m_DeliveryNoteDetailObject.soLuong = int.Parse(_rowValue["SoLuong"].ToString()); m_DeliveryNoteDetailObject.thanhTien = int.Parse(_rowValue["ThanhTien"].ToString()); m_DeliveryNoteDetailObject.giaBan = int.Parse(_rowValue["DonGia"].ToString()); m_DeliveryNoteDetailExecute.AddDeliveryNoteDetailToDatabase(m_DeliveryNoteDetailObject); } } updateEnableButtonAndResetValueOfControl(ref btnWrite); m_enableCashReceiptVoucher = true; XtraCustomMessageBox.Show("Ghi dữ liệu thành công!", "Thông báo", true); } else { XtraCustomMessageBox.Show("Không có cuốn sách nào được bán!\nXin vui lòng kiểm tra lại", "Thông báo", true); } } catch (System.Exception) { XtraCustomMessageBox.Show("Không thể ghi dữ liệu!", "Lỗi", true); } }