private string GetBookNo(List <Model.Transaction> oDataList) { Boolean bFound = false; int iCounter = 0; oBook = new DataAccess.Book(); eVariable.iAutoBookNo = oBook.GetBookNo(); RETURN_HERE: eVariable.iAutoBookNo = eVariable.iAutoBookNo + 1; eVariable.sBookNumber = "BKR-" + (eVariable.iAutoBookNo).ToString("0000#"); if (oBook.IsBookRecordDataExists(ePublicVariable.eVariable.FIND_TYPE.BOOK_NO, eVariable.sBookNumber)) { iCounter++; eVariable.iAutoBookNo = eVariable.iAutoBookNo + 1; goto RETURN_HERE; } if (bFound = oMTransactionList.Any(fw => fw.BOOK_NO == eVariable.sBookNumber)) { goto RETURN_HERE; } return(eVariable.sBookNumber); }
private void btnAdd_Click(object sender, EventArgs e) { Boolean bFound = false; if (!chkAutoNumber.Checked) { if (txtBookNo.Text.Trim() == string.Empty) { oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.PLEASE_ENTER_BOOK_NUMBER.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); return; } } if (txtISBN.Text.Trim() == string.Empty) { oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.PLEASE_ENTER_ISBN_NUMBER.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); return; } oBook = new DataAccess.Book(); eVariable.sISBN_Number = txtISBN.Text; if (oBook.IsBookRecordDataExists(ePublicVariable.eVariable.FIND_TYPE.ISBN_NUMBER, eVariable.sISBN_Number)) { oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.ISBN_NUMBER_ALREADY_EXISTS.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); txtISBN.Focus(); return; } if (!chkAutoNumber.Checked) { eVariable.sBookNumber = txtBookNo.Text; if (oBook.IsBookRecordDataExists(eVariable.FIND_TYPE.BOOK_NO, eVariable.sBookNumber.Trim())) { oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.BOOK_NUMBER_ALREADY_EXISTS.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); txtBookNo.Focus(); return; } } else { eVariable.sBookNumber = GetBookNo(oMTransactionList); } bFound = oMTransactionList.Any(fw => fw.BOOK_NO == eVariable.sBookNumber || fw.ISBN_NUMBER == eVariable.sISBN_Number); if (!bFound) { oMTransactionList.Add(new Model.Transaction { BOOK_ID = eVariable.sBookID, TITLE = txtTitle.Text, SUBJECT = txtSubject.Text, CATEGORY = txtCategory.Text, AUTHOR = txtAuthor.Text, PUBLISH_DATE = dtDatePublish.Value.ToString("yyyy-MM-dd"), LOCATION = txtLocation.Text, BOOK_PRICE = txtBookPrice.Text, RENT_PRICE = txtRentPrice.Text, BOOK_NO = eVariable.sBookNumber, ISBN_NUMBER = eVariable.sISBN_Number, REMARKS = "", STATUS = "ACTIVE" }); iGridControl.FindOption = iControlGrid.iGridControl.FIND_OPTION.ADD_BOOK_NO; iGridControl.BookCommonData = oMTransaction; iGridControl.BookListData = oMTransactionList; iGridControl.SetDeleteColumnVisible = true; iGridControl.SetHeaderVisible = false; iGridControl.PopulateRecord(); iGridControl.Visible = true; txtBookNo.Text = string.Empty; txtISBN.Text = string.Empty; } else { oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_IS_ALREADY_EXISTS.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); } }