Example #1
0
        private void UpdateIsConsignment()
        {
            if (!mboIsInTransaction)
            {
                MessageBox.Show("Sorry you cannot consign an empty transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // 18Feb2016 : Do not allow consignment if items > 1 and AllowMoreThan1ItemIfConsignment is FALSE
            if (!mclsSysConfigDetails.AllowMoreThan1ItemIfConsignment && ItemDataTable.Rows.Count > 1)
            {
                MessageBox.Show("Sorry you cannot tag this transaction is CONSIGNMENT. You are only allowed to consign 1 item, per transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (mclsSalesTransactionDetails.AgentID == Constants.C_RETAILPLUS_AGENTID)
            {
                if (MessageBox.Show("Sorry you need to select an agent before you can consign this transaction! Select now?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                { if (!SelectContact(Data.ContactGroupCategory.AGENT)) return; }
                else
                    return;
            }

            if (mclsSalesTransactionDetails.CustomerID == Constants.ZERO || mclsSalesTransactionDetails.CustomerID == Constants.C_RETAILPLUS_CUSTOMERID)
            {
                if (MessageBox.Show("Sorry you need to select a customer before you can consign this transaction! Select now?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                { if (!SelectContact(Data.ContactGroupCategory.CUSTOMER)) return; }
                else
                    return;
            }

            DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.CloseTransaction, "Consign Transaction Access Validation");

            if (loginresult == DialogResult.OK)
            {
                try
                {
                    Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                    mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                    clsSalesTransactions.UpdateisConsignment(mclsSalesTransactionDetails.TransactionID, !mclsSalesTransactionDetails.isConsignment);
                    clsSalesTransactions.CommitAndDispose();

                    mclsSalesTransactionDetails.isConsignment = !mclsSalesTransactionDetails.isConsignment;

                    lblConsignment.Visible = mclsSalesTransactionDetails.isConsignment;

                    InsertAuditLog(AccessTypes.CloseTransaction, "Updating isConsignment: " + mclsSalesTransactionDetails.isConsignment.ToString() + " in the database for transactionno: " + mclsSalesTransactionDetails.TransactionNo + " done.");
                    MessageBox.Show(mclsSalesTransactionDetails.isConsignment ? "This transaction has been saved as consignment." : "This transaction has been saved as NOT consignment", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    InsertErrorLogToFile(ex, "ERROR!!! Updating isConsignment: " + mclsSalesTransactionDetails.isConsignment.ToString() + " in the database for transactionno: " + mclsSalesTransactionDetails.TransactionNo + ". TRACE: ");
                    throw ex;
                }
            }
        }