private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { String strError = ""; if (cboxSupplier.Text.Equals("")) { strError += "\nSuppiler is null"; } else { bool checkExist = false; foreach (DataRow d in preReceiptNote.loadSupplierDT(true).Rows) { if (cboxSupplier.Text.Equals(d[0].ToString() + " - " + d[1].ToString())) { checkExist = true; break; } } if (!checkExist) { strError += "\nDidn't see any supplier like " + cboxSupplier.Text; } } bool checkItem = true; if (gridItems.DataSource == null || ((DataTable)gridItems.DataSource).Rows.Count == 0) { checkItem = false; } else { foreach (DataRow r in ((DataTable)gridItems.DataSource).Rows) { if (Int32.Parse(r[13].ToString()) == 0) { checkItem = false; } } } if (!checkItem /*lbTotal.Text.Equals("")*/) { strError += "\nSome product hasn't amount, check again"; } else { if (float.Parse(tboxAccounted.Text).CompareTo(float.Parse(lbTotal.Text)) > 0) { strError += "\nAccounted is not rather than total"; } } if (dpickIssued.Value > dpickAccounting.Value) { strError += "\nIssued date is not rather than accounting date"; } if (!strError.Equals("")) { MessageBox.Show(strError); return; } // if (obj != null) { //chua get data obj obj.SUPPLIER_ID = Int32.Parse(cboxSupplier.Text.Substring(cboxSupplier.Text.IndexOf('0'), 5)); obj.ACCOUNTED = Int32.Parse(tboxAccounted.Text); obj.TOTAL = Int32.Parse(lbTotal.Text); obj.ISSUED_DATE = dpickIssued.Value; obj.ACCOUNTING_DATE = dpickAccounting.Value; obj.NOTE = tboxNote.Text; String strEr = preReceiptNote.update(obj, dtItems); if (strEr.Equals("")) { preReceiptNote.loadReceiptNotesDB(); Close(); } else { MessageBox.Show(strEr); } return; } // if (receipt_note == null) { receipt_note = new RECEIPT_NOTE(); } receipt_note.SUPPLIER_ID = Int32.Parse(cboxSupplier.Text.Substring(cboxSupplier.Text.IndexOf('0'), cboxSupplier.Text.IndexOf(' ') - cboxSupplier.Text.IndexOf('0'))); receipt_note.ACCOUNTED = Int32.Parse(tboxAccounted.Text); receipt_note.ISSUED_DATE = DateTime.Parse(dpickIssued.Text); receipt_note.ACCOUNTING_DATE = DateTime.Parse(dpickAccounting.Text); receipt_note.NOTE = tboxNote.Text; receipt_note.PREPARER_ID = 1; receipt_note.RECORD_STATUS = "A"; //receipt_note.RN_CODE = "aaaa"; receipt_note.TOTAL = float.Parse(lbTotal.Text); //receipt_note.RN_ID = 1; preReceiptNote.add(receipt_note, dtItems); preReceiptNote.loadReceiptNotesDB(); Close(); }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { String strError = ""; if (cboxSupplier.Text.Equals("")) { strError += "\nNhà cung cấp trống"; } else { bool checkExist = false; foreach (DataRow d in preReceiptNote.loadSupplierDT(true).Rows) { if (cboxSupplier.Text.Equals(d[0].ToString() + " - " + d[1].ToString())) { checkExist = true; break; } } if (!checkExist) { strError += "\nKhông tìm thấy " + cboxSupplier.Text; } } bool checkItem = true; if (gridItems.DataSource == null || ((DataTable)gridItems.DataSource).Rows.Count == 0) { checkItem = false; } else { foreach (DataRow r in ((DataTable)gridItems.DataSource).Rows) { if (Int32.Parse(r[3].ToString()) == 0) { checkItem = false; } } } if (!checkItem) { strError += "\nHàng hóa phải có số lượng"; } else { if (float.Parse(tboxAccounted.Text).CompareTo(float.Parse(lbTotal.Text)) > 0) { strError += "\nTiền thanh toán không được lớn hơn tổng tiền"; } } if (!strError.Equals("")) { MessageBox.Show(strError); return; } // if (obj != null) { //chua get data obj obj.SUPPLIER_ID = Int32.Parse(cboxSupplier.Text.Substring(cboxSupplier.Text.IndexOf('0'), cboxSupplier.Text.IndexOf(' ') - cboxSupplier.Text.IndexOf('0') + 1)); obj.ACCOUNTED = Int32.Parse(tboxAccounted.Text); obj.TOTAL = Int32.Parse(lbTotal.Text); obj.ISSUED_DATE = dpickIssued.Value; obj.ACCOUNTING_DATE = dpickAccounting.Value; obj.NOTE = tboxNote.Text; obj.STATUS = "Chưa thanh toán"; if (lbTotal.Text.Equals(tboxAccounted.Text)) { obj.STATUS = "Đã thanh toán"; } String strEr = preReceiptNote.update(obj, dtItems); if (strEr.Equals("")) { preReceiptNote.loadReceiptNotesDB(); Close(); beforeForm.WindowState = FormWindowState.Maximized; beforeForm.Activate(); } else { MessageBox.Show(strEr); } return; } // if (receipt_note == null) { receipt_note = new RECEIPT_NOTE(); } receipt_note.SUPPLIER_ID = Int32.Parse(cboxSupplier.Text.Substring(cboxSupplier.Text.IndexOf('0'), cboxSupplier.Text.IndexOf(' ') - cboxSupplier.Text.IndexOf('0'))); receipt_note.ACCOUNTED = Int32.Parse(tboxAccounted.Text); receipt_note.ISSUED_DATE = dpickIssued.Value; receipt_note.ACCOUNTING_DATE = dpickAccounting.Value; receipt_note.NOTE = tboxNote.Text; receipt_note.STATUS = "Chưa thanh toán"; if (lbTotal.Text.Equals(tboxAccounted.Text)) { receipt_note.STATUS = "Đã thanh toán"; } if (AccountPresenter.currentEmployee == null) { receipt_note.PREPARER_ID = 1; } else { receipt_note.PREPARER_ID = AccountPresenter.currentEmployee.EMP_ID; } receipt_note.RECORD_STATUS = "A"; receipt_note.TOTAL = float.Parse(lbTotal.Text); preReceiptNote.add(receipt_note, dtItems); preReceiptNote.loadReceiptNotesDB(); beforeForm.WindowState = FormWindowState.Maximized; beforeForm.Activate(); //Close(); }