Пример #1
0
        private void dgBorrowedBooks_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 9 && e.ColumnIndex == 10 && e.RowIndex >= 0)
                {
                    dgBorrowedBooks.ReadOnly = false;
                    DataGridViewCell cell = dgBorrowedBooks.Rows[e.RowIndex].Cells[e.ColumnIndex];
                    dgBorrowedBooks.CurrentCell = cell;
                    dgBorrowedBooks.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true;
                    dgBorrowedBooks.BeginEdit(true);
                    UpdateComputation();
                }



                if (e.ColumnIndex == 11 && e.RowIndex >= 0)
                {
                    DatagridSelectedData(sender, e);

                    iGridControl.BookCommonData         = oMTransaction;
                    iGridControl.BookListData           = oMTransactionList;
                    iGridControl.FindOption             = iControlGrid.iGridControl.FIND_OPTION.INPUT_BOOK_NO;
                    iGridControl.SetDeleteColumnVisible = true;
                    iGridControl.SetFooterVisible       = true;
                    iGridControl.SetHeaderVisible       = true;
                    iGridControl.Visible = true;
                    iGridControl.PopulateRecord();
                }

                if (e.ColumnIndex == 12 && e.RowIndex >= 0)
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_RECORD.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.QUERY;
                    oFrmMsgBox.ShowDialog();

                    if (oFrmMsgBox.sAnswer == "YES")
                    {
                        if (oMTransactionList.Count > 0)
                        {
                            oMTransactionList.RemoveAt(e.RowIndex);
                        }

                        dgBorrowedBooks.Rows.RemoveAt(e.RowIndex);
                        UpdateComputation();
                    }
                }
                ChangeCellGridColor();
            }
            catch (Exception ex)
            { }
        }
Пример #2
0
        private void dgBorrowedBooks_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 9 || e.ColumnIndex == 10 && e.RowIndex >= 0)
                {
                    if (dgBorrowedBooks.Rows[e.RowIndex].Cells[9].Value == null || dgBorrowedBooks.Rows[e.RowIndex].Cells[9].Value.ToString().Trim() == String.Empty || Convert.ToInt32(dgBorrowedBooks.Rows[e.RowIndex].Cells[9].Value) == 0)
                    {
                        oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.THE_DATA_YOU_HAVE_ENTERED_IS_INVALID.ToString().Replace("_", " "));
                        oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                        oFrmMsgBox.ShowDialog();
                        dgBorrowedBooks.Rows[e.RowIndex].Cells[9].Value = 1;
                        UpdateComputation();
                        return;
                    }

                    if (dgBorrowedBooks.Rows[e.RowIndex].Cells[10].Value == null || dgBorrowedBooks.Rows[e.RowIndex].Cells[10].Value.ToString().Trim() == String.Empty || Convert.ToInt32(dgBorrowedBooks.Rows[e.RowIndex].Cells[10].Value) == 0)
                    {
                        oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.THE_DATA_YOU_HAVE_ENTERED_IS_INVALID.ToString().Replace("_", " "));
                        oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                        oFrmMsgBox.ShowDialog();
                        dgBorrowedBooks.Rows[e.RowIndex].Cells[10].Value = 1;
                        UpdateComputation();
                        return;
                    }

                    int iBookCount = 0;
                    foreach (DataGridViewRow row in dgBorrowedBooks.Rows)
                    {
                        iBookCount += Convert.ToInt32(row.Cells[9].Value);
                    }
                    int i = oMTransactionList.Count;
                    while (i > iBookCount)
                    {
                        oMTransactionList.RemoveAt(i - 1);
                        i--;
                    }
                    UpdateComputation();
                }
            }
            catch (Exception ex)
            { }
        }
Пример #3
0
        private void dgDetails_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgDetails.Rows.Count > 0 && e.RowIndex >= 0)
            {
                if (txtBorrowerID.Text == string.Empty)
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.PLEASE_ENTER_MEMBERSHIP_ID_FOR_VERIFICATION.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    txtBorrowerID.Focus();
                    return;
                }


                if (lblMemberStatus.Text == "INVALID" || lblMemberStatus.Text == string.Empty)
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.THE_MEMBERSHIP_STATUS_IS_INVALID.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    txtBorrowerID.Focus();
                    return;
                }

                DatagridSelect(sender, e);

                if (dgBorrowedBooks.Rows.Cast <DataGridViewRow>().Any(r => r.Cells[0].Value.Equals(oMTransaction.BOOK_ID)))
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_IS_ALREADY_EXISTS.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }
                eVariable.DisableGridColumnSort(dgBorrowedBooks);
                dgBorrowedBooks.Rows.Add(oMTransaction.BOOK_ID, oMTransaction.TITLE, oMTransaction.SUBJECT, oMTransaction.CATEGORY, oMTransaction.AUTHOR, oMTransaction.PUBLISH_DATE, oMTransaction.BOOK_PRICE, oMTransaction.RENT_PRICE, oMTransaction.LOCATION, 1, 1);
                UpdateComputation();
                ChangeCellGridColor();
            }
        }
Пример #4
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            int iDaysCount = 0;
            int iBookCount = 0;

            try
            {
                if (dgBorrowedBooks.Rows.Count == 0)
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.PLEASE_SELECT_A_RECORD.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }

                foreach (DataGridViewRow row in dgBorrowedBooks.Rows)
                {
                    iBookCount += Convert.ToInt32(row.Cells[9].Value);
                }

                if (oMTransactionList.Count != iBookCount || oMTransactionList.Count == 0)
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.PLEASE_ENTER_BOOK_NUMBER.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }

                if (iGridControl.Visible == true)
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.PLEASE_CLOSE_THE_ISBN_PANEL.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }

                foreach (var oData in oMTransactionList)
                {
                    iDaysCount = Convert.ToInt32(oData.TOTAL_DAYS);


                    if (iBookCount > Convert.ToInt32(lblMaxBook.Text))
                    {
                        oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.TOTAL_BOOK_COUNT_ALREADY_EXCEED_LIMIT.ToString().Replace("_", " "));
                        oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                        oFrmMsgBox.ShowDialog();
                        return;
                    }
                    if (iDaysCount > Convert.ToInt32(lblMaxDays.Text))
                    {
                        oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.TOTAL_DAY_COUNT_ALREADY_EXCEED_LIMIT.ToString().Replace("_", " "));
                        oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                        oFrmMsgBox.ShowDialog();
                        return;
                    }
                }
                oBorrower = new DataAccess.Borrower();

                if (dgBorrowedBooks.Rows.Count > 0)
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.ARE_YOU_SURE_YOU_WANT_TO_PROCEED_TO_THE_TRANSACTION.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.QUERY;
                    oFrmMsgBox.ShowDialog();

                    if (oFrmMsgBox.sAnswer == "YES")
                    {
                        foreach (Model.Transaction oData in oMTransactionList)
                        {
                            oMTransaction              = new Model.Transaction();
                            oBook                      = new DataAccess.Book();
                            oMTransaction.BOOK_ID      = oData.BOOK_ID;
                            oMTransaction.PERSON_ID    = txtBorrowerID.Text;
                            oMTransaction.BOOK_NO      = oData.BOOK_NO;
                            oMTransaction.TITLE        = oData.TITLE;
                            oMTransaction.SUBJECT      = oData.SUBJECT;
                            oMTransaction.CATEGORY     = oData.CATEGORY;
                            oMTransaction.AUTHOR       = oData.AUTHOR;
                            oMTransaction.PUBLISH_DATE = oData.PUBLISH_DATE;
                            oMTransaction.ISBN_NUMBER  = oData.ISBN_NUMBER;
                            oMTransaction.LOCATION     = oData.LOCATION;
                            oMTransaction.BOOK_PRICE   = oData.BOOK_PRICE;
                            oMTransaction.RENT_PRICE   = oData.RENT_PRICE;
                            oMTransaction.DUE_INTEREST = oData.DUE_INTEREST;
                            oMTransaction.LD_INTEREST  = oData.LD_INTEREST;
                            oMTransaction.TOTAL_QTY    = oData.TOTAL_QTY;
                            oMTransaction.TOTAL_DAYS   = oData.TOTAL_DAYS;
                            oMTransaction.ADDED_DATE   = DateTime.Now.ToString("yyyy-MM-dd");
                            oMTransaction.ADDED_BY     = txtBorrowerID.Text;
                            oMTransaction.STATUS       = "REQUEST";
                            oBook.RequestBook(oMTransaction);
                        }


                        oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.TRANSACTION_HAS_BEEN_SUCESSFULLY_SAVE.ToString().Replace("_", " "));
                        oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.QUERY;
                        oFrmMsgBox.ShowDialog();
                        LoadRecords();
                        clearText();
                    }
                }
            }
            catch (Exception ex)
            { }
        }