public void RemoveFromMergeTable(string MainTableCode) { Data.MergeTable clsMergeTable = new Data.MergeTable(mConnection, mTransaction); mConnection = clsMergeTable.Connection; mTransaction = clsMergeTable.Transaction; clsMergeTable.Delete(MainTableCode); clsMergeTable.CommitAndDispose(); }
private void SelectTable() { // Sep 24, 2011 Lemuel E. Aceron // Added order slip wherein all punch items will not change sales and inventory // a customer named ORDER SLIP should be defined in contacts if (lblCustomer.Text.Trim().ToUpper() == Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && mboIsInTransaction) { MessageBox.Show("Sorry you cannot select ORDER SLIP customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting customer."); DialogResult result; Data.ContactDetails details; bool isMergeTable = false; TableSelectWnd clsTableSelectWnd = new TableSelectWnd(); clsTableSelectWnd.TerminalDetails = mclsTerminalDetails; clsTableSelectWnd.ContactGroupCategory = ContactGroupCategory.TABLES; clsTableSelectWnd.ShowAvailableTableOnly = mboIsInTransaction; clsTableSelectWnd.ShowDialog(this); details = clsTableSelectWnd.Details; result = clsTableSelectWnd.Result; isMergeTable = clsTableSelectWnd.isMergeTable; clsTableSelectWnd.Close(); clsTableSelectWnd.Dispose(); if (result == DialogResult.OK) { if (isMergeTable) { List<Data.ContactDetails> lstDetails; TableMergeWnd clsTableMergeWnd = new TableMergeWnd(); clsTableMergeWnd.TerminalDetails = mclsTerminalDetails; clsTableMergeWnd.ContactGroupCategory = ContactGroupCategory.TABLES; clsTableMergeWnd.ShowAvailableTableOnly = true; // inde pwede imerge and table na may laman na clsTableMergeWnd.MainTableToMerge = details; clsTableMergeWnd.ShowDialog(this); //details = clsTableMergeWnd.Details; result = clsTableMergeWnd.Result; lstDetails = clsTableMergeWnd.MergeTables; clsTableMergeWnd.Close(); clsTableMergeWnd.Dispose(); if (result == DialogResult.OK) { // 22Nov2014 : remove the merge tables when closed or void or create a new list RemoveFromMergeTable(details.ContactCode); if (lstDetails.Count > 0) { Data.MergeTable clsMergeTable = new Data.MergeTable(); Data.MergeTableDetails clsMergeTableDetails; // insert the main table clsMergeTableDetails = new Data.MergeTableDetails() { MainTableCode = details.ContactCode, ChildTableCode = details.ContactCode }; clsMergeTable.Insert(clsMergeTableDetails); // insert the child tables for (int x = 0; x < lstDetails.Count; x++) { clsMergeTableDetails = new Data.MergeTableDetails() { MainTableCode = details.ContactCode, ChildTableCode = lstDetails[x].ContactCode }; clsMergeTable.Insert(clsMergeTableDetails); } clsMergeTable.CommitAndDispose(); } } return; } // Nov 18, 2011 : Lemu - auto suspend if already doing a transaction if (mboIsInTransaction) { if (mclsSalesTransactionDetails.CustomerID == Constants.C_RETAILPLUS_CUSTOMERID && mclsSalesTransactionDetails.CustomerID != details.ContactID) { Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction); mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction; clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate); // Jan 31, 2015 : Lemu // put back to SuspendedOpen so that it won't be open somewhere else Data.SalesTransactions clsSalesTransactions1 = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions1.Connection; mTransaction = clsSalesTransactions1.Transaction; clsEvent.AddEventLn("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true); clsSalesTransactions1.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID); clsContacts.CommitAndDispose(); LoadContact(ContactGroupCategory.CUSTOMER, details); return; } else if (mclsSalesTransactionDetails.CustomerID == details.ContactID) { return; } else if (mclsSalesTransactionDetails.CustomerID != details.ContactID) { if (MessageBox.Show("Would you like to move from table: " + mclsSalesTransactionDetails.CustomerDetails.ContactCode + " to table: " + details.ContactCode + "." + Environment.NewLine + "Please click [Yes] to move, [Cancel] to create new transaction in the selected table.", "RetailPlus", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK) { Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction); mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction; clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate); // Jan 31, 2015 : Lemu // put back to SuspendedOpen so that it won't be open somewhere else Data.SalesTransactions clsSalesTransactions1 = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions1.Connection; mTransaction = clsSalesTransactions1.Transaction; clsEvent.AddEventLn("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true); clsSalesTransactions1.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID); clsContacts.CommitAndDispose(); LoadContact(ContactGroupCategory.CUSTOMER, details); return; } else { this.SuspendTransaction(false); } } } else { Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction); mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction; clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate); clsContacts.CommitAndDispose(); } Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; string stTransactionNo = clsSalesTransactions.getSuspendedTransactionNo(details.ContactID, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID); if (stTransactionNo != string.Empty) { LoadTransaction(stTransactionNo, mclsTerminalDetails.TerminalNo); } else { this.LoadOptions(); LoadContact(ContactGroupCategory.CUSTOMER, details); } clsSalesTransactions.CommitAndDispose(); } else { clsEvent.AddEventLn("Cancelled!"); } } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); } }