private void btnSave_Click(object sender, EventArgs e) { if (eVariable.IsFieldEmpty(pnlMain)) { oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.ALL_FIELDS_ARE_REQUIRED.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); return; } if (eVariable.m_ActionType == eVariable.ACTION_TYPE.ADD) { foreach (var oData in oMTransactionList) { oMTransaction = new Model.Transaction(); oBook = new DataAccess.Book(); oMTransaction.BOOK_ID = eVariable.sBookID; oMTransaction.BOOK_NO = oData.BOOK_NO; oMTransaction.TITLE = txtTitle.Text; oMTransaction.SUBJECT = txtSubject.Text; oMTransaction.CATEGORY = txtCategory.Text; oMTransaction.AUTHOR = txtAuthor.Text; oMTransaction.PUBLISH_DATE = dtDatePublish.Value.ToString("yyyy-MM-dd"); oMTransaction.ISBN_NUMBER = oData.ISBN_NUMBER; oMTransaction.LOCATION = txtLocation.Text; oMTransaction.BOOK_PRICE = txtBookPrice.Text; oMTransaction.RENT_PRICE = txtRentPrice.Text; oMTransaction.ADDED_DATE = DateTime.Now.ToString("yyyy-MM-dd"); oMTransaction.ADDED_BY = eVariable.sUsername; oMTransaction.STATUS = "ACTIVE"; oBook.InsertBook(oMTransaction); } } else { oMTransaction = new Model.Transaction(); oBook = new DataAccess.Book(); oMTransaction.BOOK_ID = eVariable.sBookID; oMTransaction.TITLE = txtTitle.Text; oMTransaction.SUBJECT = txtSubject.Text; oMTransaction.CATEGORY = txtCategory.Text; oMTransaction.AUTHOR = txtAuthor.Text; oMTransaction.PUBLISH_DATE = dtDatePublish.Value.ToString("yyyy-MM-dd"); oMTransaction.LOCATION = txtLocation.Text; oMTransaction.BOOK_PRICE = txtBookPrice.Text; oMTransaction.RENT_PRICE = txtRentPrice.Text; oMTransaction.MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd"); oMTransaction.MODIFIED_BY = eVariable.sUsername; oMTransaction.STATUS = "ACTIVE"; oBook.UpdateBookDetails(oMTransaction); } oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_HAS_BEEN_SUCESSFULLY_SAVED.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); oFrmBookList.LoadRecords(); EDControls(true); Close(); ResetFields(); }
private void btnSave_Click(object sender, EventArgs e) { if (oMTransactionList.Count <= 0) { return; } #region ADD if (eVariable.m_ActionType == eVariable.ACTION_TYPE.ADD) { foreach (var oItem in oMTransactionList) { oMTransaction = new Model.Transaction(); oBook = new DataAccess.Book(); oMTransaction.BOOK_ID = oItem.BOOK_ID; oMTransaction.BOOK_NO = oItem.BOOK_NO; oMTransaction.TITLE = oItem.TITLE; oMTransaction.SUBJECT = oItem.SUBJECT; oMTransaction.CATEGORY = oItem.CATEGORY; oMTransaction.AUTHOR = oItem.AUTHOR; oMTransaction.ISBN_NUMBER = oItem.ISBN_NUMBER; oMTransaction.PUBLISH_DATE = oItem.PUBLISH_DATE; oMTransaction.LOCATION = oItem.LOCATION; oMTransaction.BOOK_PRICE = oItem.BOOK_PRICE; oMTransaction.RENT_PRICE = oItem.RENT_PRICE; oMTransaction.REMARKS = txtRemarks.Text; oMTransaction.STATUS = "ACTIVE"; oMTransaction.ADDED_DATE = DateTime.Now.ToString("yyyy-MM-dd"); oMTransaction.ADDED_BY = eVariable.sUsername; oBook.InsertBook(oMTransaction); } } #endregion if (eVariable.m_ActionType == eVariable.ACTION_TYPE.EDIT) { oMTransaction = new Model.Transaction(); oBook = new DataAccess.Book(); oMTransaction.TITLE = txtTitle.Text; oMTransaction.SUBJECT = txtSubject.Text; oMTransaction.CATEGORY = txtCategory.Text; oMTransaction.AUTHOR = txtAuthor.Text; oMTransaction.PUBLISH_DATE = txtDatePublish.Text; oMTransaction.LOCATION = txtLocation.Text; oMTransaction.BOOK_PRICE = txtPrice.Text; oMTransaction.RENT_PRICE = txtLDPrice.Text; oMTransaction.BOOK_ID = oMTransactionRecord.BOOK_ID; oMTransaction.BOOK_NO = oMTransactionRecord.BOOK_NO; oMTransaction.ISBN_NUMBER = oMTransactionRecord.ISBN_NUMBER; oMTransaction.REMARKS = txtRemarks.Text; oMTransaction.STATUS = cboStatus.Text; if (oMTransaction.STATUS == "INACTIVE") { if (oBook.IsBookCheckout(oMTransaction)) { oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.THE_RECORD_YOU_HAVE_SELECTED_HAVE_ACTIVE_TRANSACTION.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); return; } } oMTransaction.ADDED_DATE = DateTime.Now.ToString("yyyy-MM-dd"); oMTransaction.ADDED_BY = eVariable.sUsername; oBook.UpdateBook(oMTransaction); } oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_HAS_BEEN_SUCESSFULLY_SAVED.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); oFrmBookLst.LoadRecords(); LoadRecord(); clearText(); }