Exemplo n.º 1
0
        private void LoadTransaction(string stTransactionNo, string pstrTerminalNo)
		{
			Cursor.Current = Cursors.WaitCursor;
			try
			{
				clsEvent.AddEvent("Loading transaction : " + stTransactionNo);

				Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

				mclsSalesTransactionDetails = clsSalesTransactions.Details(stTransactionNo, pstrTerminalNo, mclsTerminalDetails.BranchID);

                if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Open ||
                    mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Suspended)
                {
                    // Aug 6, 2011 : Lemu
                    // overwrite to change cashierid and name
                    try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
                    catch { }
                    mclsSalesTransactionDetails.CashierName = lblCashier.Text;

                    // Jan 31, 2015 : Lemu
                    // put to SuspendedOpen so that it won't be open somewhere else
                    if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Suspended)
                    {
                        clsEvent.AddEvent("Putting transaction SuspendedOpen: " + stTransactionNo, true);
                        clsSalesTransactions.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);
                    }
                }

				Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
				Data.ContactDetails clsContactDetails = clsContact.Details(mclsSalesTransactionDetails.CustomerID);
				LoadContact(AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER, clsContactDetails);

				//mclsSalesTransactionDetails.RewardCardNo = clsContactDetails.RewardDetails.RewardCardNo;
				//mclsSalesTransactionDetails.RewardCardExpiry = clsContactDetails.RewardDetails.ExpiryDate;
				//mclsSalesTransactionDetails.RewardPreviousPoints = clsContactDetails.RewardDetails.RewardPoints;

                if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Refund || mclsSalesTransactionDetails.TransactionType == TransactionTypes.POSRefund)
				{
					mboIsRefund = true;
					lblSubtotalName.Text = "SUBTOTAL: REFUND";
					lblOrderType.Visible = false;
				}
				lblTransNo.Text = mclsSalesTransactionDetails.TransactionNo;
				lblTransNo.Tag = mclsSalesTransactionDetails.TransactionID.ToString();
				lblCustomer.Text = mclsSalesTransactionDetails.CustomerName;
				lblCustomer.Tag = mclsSalesTransactionDetails.CustomerID.ToString();
				lblAgent.Text = mclsSalesTransactionDetails.AgentName;
				lblAgent.Tag = mclsSalesTransactionDetails.AgentID.ToString();
				lblAgentPositionDepartment.Text = mclsSalesTransactionDetails.AgentPositionName;
				lblAgentPositionDepartment.Tag = mclsSalesTransactionDetails.AgentDepartmentName;
				grpItems.Text = "Served by: " + mclsSalesTransactionDetails.WaiterName;
				grpItems.Tag = mclsSalesTransactionDetails.WaiterID;

				lblTransDate.Text = mclsSalesTransactionDetails.TransactionDate.ToString("MMM. dd, yyyy hh:mm:ss tt");
                mdteOverRidingPrintDate = mclsSalesTransactionDetails.TransactionDate;

				lblTransDiscount.Tag = mclsSalesTransactionDetails.TransDiscountType.ToString("d");
                lblConsignment.Visible = mclsSalesTransactionDetails.isConsignment;

                //mclsSalesTransactionDetails.ChargeAmount = mclsSalesTransactionDetails.ChargeAmount;
                if (mclsSalesTransactionDetails.ChargeAmount == 0)
                    lblTransCharge.Tag = ChargeTypes.NotApplicable.ToString("d"); //details.TransDiscountType.ToString("d");
                else
                {
                    //lblTransCharge.Tag = ChargeTypes.Percentage.ToString("d"); //details.TransDiscountType.ToString("d");
                    Data.ChargeType clsChargeType = new Data.ChargeType(mConnection, mTransaction);
                    bool bolInPercent = clsChargeType.Details(mclsSalesTransactionDetails.ChargeCode).InPercent;
                    clsChargeType.CommitAndDispose();

                    if (bolInPercent)
                        lblTransCharge.Tag = ChargeTypes.Percentage.ToString("d");
                    else
                        lblTransCharge.Tag = ChargeTypes.FixedValue.ToString("d");
                }

				Data.SalesTransactionItems clsItems = new Data.SalesTransactionItems(mConnection, mTransaction);
                mConnection = clsItems.Connection; mTransaction = clsItems.Transaction;

				Data.SalesTransactionItemDetails[] TransactionItems = clsItems.Details(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TransactionDate);

				clsEvent.AddEventLn("Done loading transaction : " + stTransactionNo, true);

                if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
					LoadResumedItems(TransactionItems, true);
				else
					LoadResumedItems(TransactionItems, false);

				mboIsInTransaction = true;

                clsSalesTransactions.CommitAndDispose();
			}
			catch (Exception ex)
			{
				InsertErrorLogToFile(ex, "ERROR!!! Loading transaction. TRACE: ");
			}
			Cursor.Current = Cursors.Default;
		}
Exemplo n.º 2
0
        private bool CreateTransaction()
        {
            Boolean boRetValue = true;
            try
            {
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                DateTime dteTransactionDate = Convert.ToDateTime(lblTransDate.Text);

                boRetValue = CheckIfOKToSell(false);

                if (!boRetValue) return boRetValue;

                clsEvent.AddEventLn("[" + lblCashier.Text + "] Creating new transaction.", true);

                mclsSalesTransactionDetails = new Data.SalesTransactionDetails();
                mclsSalesTransactionDetails.TransactionItemsList = new System.Collections.Generic.List<Data.SalesTransactionItemDetails>();
                try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
                catch { }

                //mclsSalesTransactionDetails.CustomerID = Convert.ToInt64(lblCustomer.Tag);
                //mclsSalesTransactionDetails.CustomerName = lblCustomer.Text;

                if (mclsContactDetails.ContactID == 0)
                {
                    mclsContactDetails = mclsContactDetailsDEFCustomer;
                }

                if (mboRewardCardSwiped)
                {
                    mclsSalesTransactionDetails.RewardsCustomerID = mclsContactDetails.ContactID;
                    mclsSalesTransactionDetails.RewardsCustomerName = mclsContactDetails.ContactName;
                    mclsSalesTransactionDetails.RewardCardActive = mclsContactDetails.RewardDetails.RewardActive;
                    mclsSalesTransactionDetails.RewardCardNo = mclsContactDetails.RewardDetails.RewardCardNo;
                    mclsSalesTransactionDetails.RewardCardExpiry = mclsContactDetails.RewardDetails.ExpiryDate;
                    mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetails.RewardDetails.RewardPoints;
                }
                else
                {
                    mclsSalesTransactionDetails.RewardsCustomerID = Constants.C_RETAILPLUS_CUSTOMERID;
                    mclsSalesTransactionDetails.RewardsCustomerName = Constants.C_RETAILPLUS_CUSTOMER;
                    mclsSalesTransactionDetails.RewardCardActive = mclsContactDetailsDEFCustomer.RewardDetails.RewardActive;
                    mclsSalesTransactionDetails.RewardCardNo = mclsContactDetailsDEFCustomer.RewardDetails.RewardCardNo;
                    mclsSalesTransactionDetails.RewardCardExpiry = mclsContactDetailsDEFCustomer.RewardDetails.ExpiryDate;
                    mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetailsDEFCustomer.RewardDetails.RewardPoints;
                }
                mclsSalesTransactionDetails.CustomerDetails = mclsContactDetails;
                mclsSalesTransactionDetails.CustomerID = mclsContactDetails.ContactID;
                mclsSalesTransactionDetails.CustomerName = mclsContactDetails.ContactName;
                if (mclsSalesTransactionDetails.CustomerDetails.LastCheckInDate == Constants.C_DATE_MIN_VALUE) mclsSalesTransactionDetails.CustomerDetails.LastCheckInDate = dteTransactionDate;

                mclsSalesTransactionDetails.AgentID = Convert.ToInt64(lblAgent.Tag);
                mclsSalesTransactionDetails.AgentName = lblAgent.Text;
                mclsSalesTransactionDetails.AgentPositionName = lblAgentPositionDepartment.Text;
                mclsSalesTransactionDetails.AgentDepartmentName = lblAgentPositionDepartment.Tag.ToString();
                mclsSalesTransactionDetails.WaiterID = Convert.ToInt64(grpItems.Tag);
                mclsSalesTransactionDetails.WaiterName = grpItems.Text.Remove(0, 11);
                mclsSalesTransactionDetails.CreatedByID = Convert.ToInt64(lblCashier.Tag);
                mclsSalesTransactionDetails.CreatedByName = lblCashier.Text;
                mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag);
                mclsSalesTransactionDetails.CashierName = lblCashier.Text;
                mclsSalesTransactionDetails.TransactionDate = dteTransactionDate;
                mclsSalesTransactionDetails.DateSuspended = DateTime.MinValue;
                mclsSalesTransactionDetails.TerminalNo = mclsTerminalDetails.TerminalNo;
                mclsSalesTransactionDetails.BranchID = mclsTerminalDetails.BranchID;
                mclsSalesTransactionDetails.BranchCode = mclsTerminalDetails.BranchDetails.BranchCode;
                mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.Open;
                mclsSalesTransactionDetails.TransactionType = mboIsRefund ? TransactionTypes.POSRefund : TransactionTypes.POSNormal;

                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                mclsSalesTransactionDetails.TransactionNo = clsSalesTransactions.CreateTransactionNo(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);

                lblTransNo.Text = mclsSalesTransactionDetails.TransactionNo;

                //insert to transaction table 

                mclsSalesTransactionDetails.TransactionID = clsSalesTransactions.Insert(mclsSalesTransactionDetails);

                lblTransNo.Tag = mclsSalesTransactionDetails.TransactionID.ToString();

                // 24Sep2014 : update back the LastCheckInDate to transaction date
                Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
                mConnection = clsContact.Connection; mTransaction = clsContact.Transaction;

                clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, dteTransactionDate);

                // 31Jan2015 : Lemu
                // put back to SuspendedOpen so that it won't be open somewhere else
                clsEvent.AddEventLn("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true);
                clsSalesTransactions.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);

                mboIsInTransaction = true;
                clsTerminalReport.CommitAndDispose();

                InsertAuditLog(AccessTypes.CreateTransaction, "Create transaction #".PadRight(15) + ":" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                clsEvent.AddEventLn("Done! Trans #: " + lblTransNo.Text + " has been created.", true);

            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex);
                boRetValue = false;
            }

            return boRetValue;
        }
Exemplo n.º 3
0
        private bool CreateTransaction()
        {
            Boolean boRetValue = true;
            try
            {
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                DateTime dteTransactionDate = Convert.ToDateTime(lblTransDate.Text);

                boRetValue = CheckIfOKToSell(false);

                if (!boRetValue) return boRetValue;

                // Feb 16, 2015
                if (mclsTerminalDetails.WithRestaurantFeatures)
                {
                    if (mclsContactDetails.ContactID == Constants.ZERO ||
                        mclsContactDetails.ContactID == Constants.C_RETAILPLUS_CUSTOMERID)
                    {
                        MessageBox.Show("Sorry you must select a table / customer to order before punching an item.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                }

                clsEvent.AddEventLn("[" + lblCashier.Text + "] Creating new transaction.", true);

                mclsSalesTransactionDetails = new Data.SalesTransactionDetails();
                mclsSalesTransactionDetails.TransactionItemsList = new System.Collections.Generic.List<Data.SalesTransactionItemDetails>();
                try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
                catch { }

                //mclsSalesTransactionDetails.CustomerID = Convert.ToInt64(lblCustomer.Tag);
                //mclsSalesTransactionDetails.CustomerName = lblCustomer.Text;

                if (mboRewardCardSwiped)
                {
                    mclsSalesTransactionDetails.RewardsCustomerID = mclsContactDetails.ContactID;
                    mclsSalesTransactionDetails.RewardsCustomerName = mclsContactDetails.ContactName;
                    mclsSalesTransactionDetails.RewardCardActive = mclsContactDetails.RewardDetails.RewardActive;
                    mclsSalesTransactionDetails.RewardCardNo = mclsContactDetails.RewardDetails.RewardCardNo;
                    mclsSalesTransactionDetails.RewardCardExpiry = mclsContactDetails.RewardDetails.ExpiryDate;
                    mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetails.RewardDetails.RewardPoints;
                }
                else
                {
                    mclsSalesTransactionDetails.RewardsCustomerID = Constants.C_RETAILPLUS_CUSTOMERID;
                    mclsSalesTransactionDetails.RewardsCustomerName = Constants.C_RETAILPLUS_CUSTOMER;
                    mclsSalesTransactionDetails.RewardCardActive = mclsContactDetailsDEFCustomer.RewardDetails.RewardActive;
                    mclsSalesTransactionDetails.RewardCardNo = mclsContactDetailsDEFCustomer.RewardDetails.RewardCardNo;
                    mclsSalesTransactionDetails.RewardCardExpiry = mclsContactDetailsDEFCustomer.RewardDetails.ExpiryDate;
                    mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetailsDEFCustomer.RewardDetails.RewardPoints;
                }
                mclsSalesTransactionDetails.CustomerDetails = mclsContactDetails;
                mclsSalesTransactionDetails.CustomerID = mclsContactDetails.ContactID;
                mclsSalesTransactionDetails.CustomerName = mclsContactDetails.ContactName;
                if (mclsSalesTransactionDetails.CustomerDetails.LastCheckInDate == Constants.C_DATE_MIN_VALUE) mclsSalesTransactionDetails.CustomerDetails.LastCheckInDate = dteTransactionDate;

                mclsSalesTransactionDetails.AgentID = Convert.ToInt64(lblAgent.Tag);
                mclsSalesTransactionDetails.AgentName = lblAgent.Text;
                mclsSalesTransactionDetails.AgentPositionName = lblAgentPositionDepartment.Text;
                mclsSalesTransactionDetails.AgentDepartmentName = lblAgentPositionDepartment.Tag.ToString();
                mclsSalesTransactionDetails.WaiterID = Convert.ToInt64(lblServedBy.Tag);
                mclsSalesTransactionDetails.WaiterName = lblServedBy.Text.Remove(0, 11);
                mclsSalesTransactionDetails.CreatedByID = Convert.ToInt64(lblCashier.Tag);
                mclsSalesTransactionDetails.CreatedByName = lblCashier.Text;
                mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag);
                mclsSalesTransactionDetails.CashierName = lblCashier.Text;
                mclsSalesTransactionDetails.TransactionDate = dteTransactionDate;
                mclsSalesTransactionDetails.DateSuspended = DateTime.MinValue;
                mclsSalesTransactionDetails.TerminalNo = mclsTerminalDetails.TerminalNo;
                mclsSalesTransactionDetails.BranchID = mclsTerminalDetails.BranchID;
                mclsSalesTransactionDetails.BranchCode = mclsTerminalDetails.BranchDetails.BranchCode;
                mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.Open;
                mclsSalesTransactionDetails.TransactionType = mboIsRefund ? TransactionTypes.POSRefund : TransactionTypes.POSNormal;

                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                mclsSalesTransactionDetails.TransactionNo = clsSalesTransactions.CreateTransactionNo(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                // mclsTransactionStream.Create(mclsSalesTransactionDetails);

                lblTransNo.Text = mclsSalesTransactionDetails.TransactionNo;

                //insert to transaction table 
                mclsSalesTransactionDetails.TransactionID = clsSalesTransactions.Insert(mclsSalesTransactionDetails);

                lblTransNo.Tag = mclsSalesTransactionDetails.TransactionID.ToString();

                // Sep 24, 2014 : update back the LastCheckInDate to transaction date
                Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
                mConnection = clsContact.Connection; mTransaction = clsContact.Transaction;

                clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, dteTransactionDate);

                // Jan 31, 2015 : Lemu
                // put back to SuspendedOpen so that it won't be open somewhere else
                clsEvent.AddEventLn("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true);
                clsSalesTransactions.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);

                mboIsInTransaction = true;
                clsTerminalReport.CommitAndDispose();

                InsertAuditLog(AccessTypes.CreateTransaction, "Create transaction #:" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                clsEvent.AddEventLn("Done! Trans #: " + lblTransNo.Text + " has been created.", true);

                // Added to put the default transaction charge during creation of transaction
                // this is set during the system setup
                ApplyTransDefaultCharge();
            }
            catch (Exception ex)
            { clsEvent.AddErrorEventLn(ex); boRetValue = false; }

            return boRetValue;
        }
Exemplo n.º 4
0
		private void ResumeTransaction()
		{
            if (!SuspendTransactionAndContinue()) return;

            // ShowOneTerminalSuspendedTransactions 
            // Only same cashier in same terminal can be resume.
            // if terminalno and cashier is not the same to not allow   
			if (mclsTerminalDetails.ShowOneTerminalSuspendedTransactions)
			{
                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                int count = clsSalesTransactions.CountSuspended(mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierID, mclsTerminalDetails.BranchID);
                clsSalesTransactions.CommitAndDispose();

				if (count == 0)
				{
					MessageBox.Show("No suspended transaction found for this day.", "RetailPlus", MessageBoxButtons.OK);
					return;
				}
			}

			DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ResumeTransaction);

			if (loginresult == DialogResult.OK)
			{
				try
				{
					ResumeTransactionWnd ResumeWnd = new ResumeTransactionWnd();
                    ResumeWnd.TerminalDetails = mclsTerminalDetails;
					ResumeWnd.CashierID = mclsSalesTransactionDetails.CashierID;
                    ResumeWnd.TransactionStatusToList = AceSoft.RetailPlus.TransactionStatus.Suspended;
					ResumeWnd.ShowDialog(this);
					DialogResult result = ResumeWnd.Result;
					Data.SalesTransactionDetails details = ResumeWnd.Details;
					ResumeWnd.Close();
					ResumeWnd.Dispose();

					if (result == DialogResult.OK)
					{
                        if (details.TransactionStatus == TransactionStatus.SuspendedOpen)
                        {
                            if (MessageBox.Show("This transaction is already open in another terminal. Please suspend in the other terminal first before opening." + Environment.NewLine + "Would you like to force open this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                            {
                                return;
                            }
                            else
                            {
                                DialogResult resResumeSuspendedOpenTransaction = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ResumeSuspendedOpenTransaction);

                                if (resResumeSuspendedOpenTransaction != System.Windows.Forms.DialogResult.OK)
                                {
                                    clsEvent.AddEvent("[" + lblCashier.Text + "] Resuming transaction no. " + details.TransactionNo + " cancelled. SuspendedOpen");
                                    return;
                                }
                            }
                        }

						clsEvent.AddEvent("[" + lblCashier.Text + "] Resuming transaction no. " + details.TransactionNo);

						mclsSalesTransactionDetails = details;

						if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Refund || mclsSalesTransactionDetails.TransactionType == TransactionTypes.POSRefund)
						{
							mboIsRefund = true;
							lblSubtotalName.Text = "SUBTOTAL: REFUND";
							lblOrderType.Visible = false;
						}
						lblOrderType.Text = mclsSalesTransactionDetails.OrderType.ToString("G").ToUpper();
						lblTransNo.Text = mclsSalesTransactionDetails.TransactionNo;
						lblTransNo.Tag = mclsSalesTransactionDetails.TransactionID.ToString();
						lblCustomer.Text = mclsSalesTransactionDetails.CustomerName;
						lblCustomer.Tag = mclsSalesTransactionDetails.CustomerID.ToString();
						lblAgent.Text = mclsSalesTransactionDetails.AgentName;
						lblAgent.Tag = mclsSalesTransactionDetails.AgentID.ToString();
						lblAgentPositionDepartment.Text = mclsSalesTransactionDetails.AgentPositionName;
						lblAgentPositionDepartment.Tag = mclsSalesTransactionDetails.AgentDepartmentName;
						grpItems.Text = "Served by: " + details.WaiterName;
						grpItems.Tag = mclsSalesTransactionDetails.WaiterID.ToString();

						lblTransDate.Text = mclsSalesTransactionDetails.TransactionDate.ToString("MMM. dd, yyyy hh:mm:ss tt");
                        mdteOverRidingPrintDate = mclsSalesTransactionDetails.TransactionDate;

						lblTransDiscount.Tag = mclsSalesTransactionDetails.TransDiscountType.ToString("d");
                        lblConsignment.Visible = mclsSalesTransactionDetails.isConsignment;

                        if (mclsSalesTransactionDetails.ChargeAmount == 0)
                            lblTransCharge.Tag = ChargeTypes.NotApplicable.ToString("d");
                        else
                        {
                            Data.ChargeType clsChargeType = new Data.ChargeType(mConnection, mTransaction);
                            bool bolInPercent = clsChargeType.Details(mclsSalesTransactionDetails.ChargeCode).InPercent;
                            clsChargeType.CommitAndDispose();

                            if (bolInPercent)
                                lblTransCharge.Tag = ChargeTypes.Percentage.ToString("d");
                            else
                                lblTransCharge.Tag = ChargeTypes.FixedValue.ToString("d");
                        }

						// Aug 6, 2011 : Lemu
						// Put here from CloseTransaction
						try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
						catch { }
						mclsSalesTransactionDetails.CashierName = lblCashier.Text;

						LoadResumedItems(details.TransactionItems, false);

                        // Jan 31, 2015 : Lemu
                        // put back to SuspendedOpen so that it won't be open somewhere else
                        if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Suspended)
                        {
                            Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                            mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;
                            clsEvent.AddEvent("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true);
                            clsSalesTransactions.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);
                            clsSalesTransactions.CommitAndDispose();
                        }

                        // 06Mar2015 : reload this, to use for price level
                        Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction);
                        mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction;
                        mclsContactDetails = clsContacts.Details(mclsSalesTransactionDetails.CustomerID);
                        clsContacts.CommitAndDispose();

						mboIsInTransaction = true;

						InsertAuditLog(AccessTypes.ResumeTransaction, "Resume transaction #: " + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
						clsEvent.AddEventLn("[" + lblCashier.Text + "] Resuming transaction no. " + details.TransactionNo + " Done.", true);
					}
					else { clsEvent.AddEventLn("Cancelled!"); }


				}
				catch (Exception ex)
				{ 
                    InsertErrorLogToFile(ex, "ERROR!!! Resuming transaction."); 
                }
			}
		}
Exemplo n.º 5
0
		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); }
		}