コード例 #1
0
ファイル: MainWnd.cs プロジェクト: marioricci/erp-luma
		private bool SelectContact(AceSoft.RetailPlus.Data.ContactGroupCategory enumContactGroupCategory)
		{
            bool boretValue = true;

			// 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 && enumContactGroupCategory == AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER)
			{
				MessageBox.Show("Sorry you cannot select ORDER SLIP customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return false;
			}

			if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto && mboIsInTransaction)
			{
				switch (enumContactGroupCategory)
				{ 
					case AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER:
						MessageBox.Show("Sorry you cannot select a customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
						break;
					case AceSoft.RetailPlus.Data.ContactGroupCategory.AGENT:
						MessageBox.Show("Sorry you cannot select an agent when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
						break;
				}

				return false;
			}

			try
			{
				switch (enumContactGroupCategory)
				{
					case AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER:
						clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting customer.");
						if (mclsTerminalDetails.ShowCustomerSelection == false)
						{
							clsEvent.AddEventLn("Cancelled! ShowCustomerSelection is OFF, reward is ON.");
							txtBarCode.Text = Constants.SWIPE_REWARD_CARD;
							txtBarCode.Focus(); txtBarCode.SelectionStart = txtBarCode.Text.Length + 1;
							return false;
						}
						break;
					case AceSoft.RetailPlus.Data.ContactGroupCategory.AGENT:
						clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting agent.");
						break;
				}

				DialogResult result; Data.ContactDetails details;
				ContactSelectWnd clsContactWnd = new ContactSelectWnd();
                clsContactWnd.EnableContactAddUpdate = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.Contacts) == System.Windows.Forms.DialogResult.OK;
                clsContactWnd.SysConfigDetails = mclsSysConfigDetails;
                clsContactWnd.TerminalDetails = mclsTerminalDetails;
				clsContactWnd.ContactGroupCategory = enumContactGroupCategory;
				clsContactWnd.ShowDialog(this);
				details = clsContactWnd.Details;
				result = clsContactWnd.Result;
				clsContactWnd.Close();
				clsContactWnd.Dispose();

				if (result == DialogResult.OK)
				{

                    if (details.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode && mboIsInTransaction)
                    {
                        MessageBox.Show("Sorry you cannot select OUT OF STOCK customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        clsEvent.AddEventLn("Cancelled OUT OF STOCK customer is selected but items are already purchased."); 
                        return false;
                    }

					LoadContact(enumContactGroupCategory, details);

                    // 13Mar2015 : MPC, override the price using the PriceLevel
                    //             For PriceLevel1...5
                    if (mclsSysConfigDetails.EnablePriceLevel)
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        Int32 iOldRow = dgItems.CurrentRowIndex;
                        Data.SalesTransactionItemDetails Details = new Data.SalesTransactionItemDetails();

                        Data.ProductPackage clsProductPackage = new Data.ProductPackage(mConnection, mTransaction);
                        mConnection = clsProductPackage.Connection; mTransaction = clsProductPackage.Transaction;

                        Data.ProductPackageDetails clsProductPackageDetails = new Data.ProductPackageDetails();

                        System.Data.DataTable dt = (System.Data.DataTable)dgItems.DataSource;
                        for (int x = 0; x < dt.Rows.Count; x++)
                        {
                            dgItems.CurrentRowIndex = x;
                            Details = getCurrentRowItemDetails();

                            dgItems.UnSelect(x);
                            if (Details.TransactionItemStatus == TransactionItemStatus.Valid)
                            {
                                clsProductPackageDetails = clsProductPackage.Details(Details.ProductPackageID);

                                switch (mclsContactDetails.PriceLevel)
                                {
                                    case PriceLevel.SRP: Details.Price = clsProductPackageDetails.Price; break;
                                    case PriceLevel.One: Details.Price = clsProductPackageDetails.Price1 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price1; break;
                                    case PriceLevel.Two: Details.Price = clsProductPackageDetails.Price2 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price2; break;
                                    case PriceLevel.Three: Details.Price = clsProductPackageDetails.Price3 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price3; break;
                                    case PriceLevel.Four: Details.Price = clsProductPackageDetails.Price4 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price4; break;
                                    case PriceLevel.Five: Details.Price = clsProductPackageDetails.Price5 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price5; break;
                                    case PriceLevel.WSPrice: Details.Price = clsProductPackageDetails.WSPrice == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.WSPrice; break;
                                    default: Details.Price = clsProductPackageDetails.Price; break;
                                }
                                Details = ApplyPromo(Details);

                                ApplyChangeQuantityPriceAmountDetails(x, Details, "Change Price: Change Contact");
                            }
                        }

                        clsProductPackage.CommitAndDispose();

                        if (iOldRow >=0 )
                        {
                            dgItems.CurrentRowIndex = iOldRow;
                            dgItems.Select(iOldRow);

                            Details = getCurrentRowItemDetails();
                            DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret);
                            DisplayItemToTurretDel.BeginInvoke(Details.Description, Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null);
                            InsertAuditLog(AccessTypes.ChangePrice, "Change price: change contact : for item " + Details.ProductCode + " to " + Details.Price.ToString("#,##0.#0") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                            mbodgItemRowClick = false;
                        }

                        Cursor.Current = Cursors.Default;
                    }
				}
                else { clsEvent.AddEventLn("Cancelled!"); boretValue = false; }

			}
			catch (Exception ex)
			{ 
                InsertErrorLogToFile(ex, "ERROR!!! Selecting contact.");
                boretValue = false;
            }
            return boretValue;
		}
コード例 #2
0
ファイル: MainWnd.cs プロジェクト: marioricci/erp-luma
		private void ReadBarCode()
		{
			DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.CreateTransaction);

			if (loginresult == DialogResult.OK)
			{
				if (!string.IsNullOrEmpty(txtBarCode.Text.Trim()))
				{
					string stBarcode = txtBarCode.Text.Trim();
					decimal decQuantity = 1;

                    // 21Jul2013 : Check if parking ticket and has already an item.
                    if (mclsTerminalDetails.IsParkingTerminal && ItemDataTable.Rows.Count > 1)
                    {
                        txtBarCode.Text = "";
                        MessageBox.Show("Sorry you can only park 1 vehicle per transaction. ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    // 18Feb2016 : Do not allow consignment if items > 1 and AllowMoreThan1ItemIfConsignment is FALSE
                    if (mclsSalesTransactionDetails.isConsignment && !mclsSysConfigDetails.AllowMoreThan1ItemIfConsignment && ItemDataTable.Rows.Count >= 1)
                    {
                        txtBarCode.Text = "";
                        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 (stBarcode.EndsWith("*"))
					{
						MessageBox.Show("Sorry please scan the item after the quantity before you press the enter key.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
						return;
					}
					if (stBarcode.IndexOf("*") > -1)
					{
						try
						{
							decQuantity = Convert.ToDecimal(stBarcode.Substring(0, stBarcode.IndexOf("*")).Trim());
							stBarcode = stBarcode.Substring(stBarcode.IndexOf("*") + 1, stBarcode.Length - (stBarcode.IndexOf("*") + 1));
						}
						catch
						{
							MessageBox.Show("Sorry the quantity you entered is not valid. Please enter a valid quantity to purchase.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
							return;
						}
					}
                    Data.ProductPackage clsProductPackage = new Data.ProductPackage(mConnection, mTransaction);
                    mConnection = clsProductPackage.Connection; mTransaction = clsProductPackage.Transaction;

                    Data.Products clsProduct = new Data.Products(mConnection, mTransaction);
                    mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction;

                    Data.ProductPackageDetails clsProductPackageDetails = new Data.ProductPackageDetails();
                    Data.ProductDetails clsProductDetails = new Data.ProductDetails();

                    if (ProductModel.PackageID != 0) //PackageID is not zero if selection is used.
                    {
                        clsProductPackageDetails = clsProductPackage.Details(ProductModel.PackageID);
                        clsProductDetails = clsProduct.Details(clsProductPackageDetails.ProductID, clsProductPackageDetails.MatrixID, mclsTerminalDetails.BranchID);
                    }
                    else //PackageID is zero if selection is not used.
                    {
                        // check if the product exist and with quantity
                        clsProductDetails = clsProduct.Details(mclsTerminalDetails.BranchID, stBarcode, mclsTerminalDetails.ShowItemMoreThanZeroQty, decQuantity);

                        // check if the product exist and zero quantity
                        if (clsProductDetails.ProductID == 0) clsProductDetails = clsProduct.Details(stBarcode, mclsTerminalDetails.BranchID);

                        // check if the product is weighted
                        if (clsProductDetails.ProductID == 0)
                        {
                            if (stBarcode.Length == 12) stBarcode = "0" + stBarcode;
                            if (stBarcode.Length > Data.Products.DEFAULT_WEIGHTED_BARCODE_CHARACTER_COUNT + 1)
                            {
                                clsProductDetails = clsProduct.Details(mclsTerminalDetails.BranchID, stBarcode.Remove(Data.Products.DEFAULT_WEIGHTED_BARCODE_CHARACTER_COUNT));

                                if (clsProductDetails.ProductID != 0)
                                {
                                    decQuantity = (decimal.Parse(stBarcode.Remove(stBarcode.Length - 1).Remove(1, Data.Products.DEFAULT_WEIGHTED_BARCODE_CHARACTER_COUNT)) / 100) / clsProductDetails.Price;
                                }
                            }
                        }
                        // 16Apr2015 : Add a new logic for the new weighing machine
                        // if (stBarcode.Length == 11) stBarcode = stBarcode.Remove(stBarcode.Length - 1);

                        // get the package details
                        if (clsProductDetails.ProductID != 0) clsProductPackageDetails = clsProductPackage.Details(clsProductDetails.PackageID);
                    }

					txtBarCode.Text = "";
                    ProductModel.Clear();
					
                    if (clsProductDetails.ProductID != 0)
                    {
                        // 06Mar2015 : Override the price base on the Price Level
                        if (mclsSysConfigDetails.EnablePriceLevel)
                        {
                            switch (mclsContactDetails.PriceLevel)
                            {
                                case PriceLevel.SRP: clsProductDetails.Price = clsProductPackageDetails.Price; break;
                                case PriceLevel.One: clsProductDetails.Price = clsProductPackageDetails.Price1 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price1; break;
                                case PriceLevel.Two: clsProductDetails.Price = clsProductPackageDetails.Price2 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price2; break;
                                case PriceLevel.Three: clsProductDetails.Price = clsProductPackageDetails.Price3 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price3; break;
                                case PriceLevel.Four: clsProductDetails.Price = clsProductPackageDetails.Price4 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price4; break;
                                case PriceLevel.Five: clsProductDetails.Price = clsProductPackageDetails.Price5 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price5; break;
                                case PriceLevel.WSPrice: clsProductDetails.Price = clsProductPackageDetails.WSPrice == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.WSPrice; break;
                                default: clsProductDetails.Price = clsProductPackageDetails.Price; break;
                            }
                        }

                        // 21Jul2013 Include getting of rates for parking
                        if (mclsTerminalDetails.IsParkingTerminal)
                        {
                            Data.ParkingRates clsParkingRate = new Data.ParkingRates(mConnection, mTransaction);
                            mConnection = clsParkingRate.Connection; mTransaction = clsParkingRate.Transaction;

                            Data.ParkingRateDetails clsParkingRateDetails = clsParkingRate.Details(clsProductDetails.ProductID, DateTime.Now.ToString("dddd"));
                            if (clsParkingRateDetails.ParkingRateID != 0)
                            {
                                clsProductDetails.Price = clsParkingRateDetails.MinimumStayPrice;
                            }
                        }

                        if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER &&
                            !mboIsRefund && clsProductDetails.Quantity - clsProductDetails.ReservedQuantity < decQuantity && 
                            mclsTerminalDetails.ShowItemMoreThanZeroQty &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE &&
                            clsProductDetails.BarCode != Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE)
                        {
                            if (clsProductDetails.Quantity >= decQuantity)
                            {
                                clsProductPackage.CommitAndDispose();
                                MessageBox.Show("Sorry the quantity you entered is already reserved. Current Stock: " + clsProductDetails.Quantity.ToString("#,##0.#0") + " Reserved Stock: " + clsProductDetails.ReservedQuantity.ToString("#,##0.#0"), "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                            else
                            {
                                clsProductPackage.CommitAndDispose();
                                MessageBox.Show("Sorry the quantity you entered is greater than the current stock. " + Environment.NewLine + "Current Stock: " + clsProductDetails.Quantity.ToString("#,##0.#0"), "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                        }

                        if (clsProductDetails.IsLock)
                        {
                            clsProductPackage.CommitAndDispose();
                            MessageBox.Show("Sorry this product is currently LOCKED for inventory. Please advise the inventory officer if you really want to sell this product.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }

                        Data.SalesTransactionItemDetails clsItemDetails = new Data.SalesTransactionItemDetails();

                        clsItemDetails.ProductID = clsProductDetails.ProductID;
                        clsItemDetails.ProductCode = clsProductDetails.ProductCode;
                        clsItemDetails.BarCode = clsProductDetails.BarCode;
                        clsItemDetails.Description = clsProductDetails.ProductDesc;
                        clsItemDetails.ProductGroupID = clsProductDetails.ProductGroupID;
                        clsItemDetails.ProductSubGroupID = clsProductDetails.ProductSubGroupID;
                        clsItemDetails.ProductGroup = clsProductDetails.ProductGroupName;
                        clsItemDetails.ProductSubGroup = clsProductDetails.ProductSubGroupName;
                        clsItemDetails.TransactionItemStatus = TransactionItemStatus.Valid;
                        clsItemDetails.ProductUnitID = clsProductDetails.BaseUnitID;
                        clsItemDetails.ProductUnitCode = clsProductDetails.BaseUnitCode;
                        clsItemDetails.Quantity = decQuantity;
                        clsItemDetails.Price = clsProductDetails.Price;
                        clsItemDetails.Discount = 0;
                        clsItemDetails.ItemDiscount = 0;
                        clsItemDetails.ItemDiscountType = DiscountTypes.NotApplicable;
                        clsItemDetails.Amount = (clsItemDetails.Quantity * clsItemDetails.Price) - (clsItemDetails.Quantity * clsItemDetails.Discount);
                        clsItemDetails.VAT = clsProductDetails.VAT;
                        clsItemDetails.EVAT = clsProductDetails.EVAT;
                        clsItemDetails.LocalTax = clsProductDetails.LocalTax;
                        clsItemDetails.TransactionItemStatus = TransactionItemStatus.Valid;
                        clsItemDetails.PurchasePrice = clsProductDetails.PurchasePrice;
                        clsItemDetails.PurchaseAmount = clsItemDetails.Quantity * clsItemDetails.PurchasePrice;
                        clsItemDetails.IncludeInSubtotalDiscount = clsProductDetails.IncludeInSubtotalDiscount;
                        clsItemDetails.IsCreditChargeExcluded = clsProductDetails.IsCreditChargeExcluded;
                        clsItemDetails.OrderSlipPrinter1 = clsProductDetails.OrderSlipPrinter1;
                        clsItemDetails.OrderSlipPrinter2 = clsProductDetails.OrderSlipPrinter2;
                        clsItemDetails.OrderSlipPrinter3 = clsProductDetails.OrderSlipPrinter3;
                        clsItemDetails.OrderSlipPrinter4 = clsProductDetails.OrderSlipPrinter4;
                        clsItemDetails.OrderSlipPrinter5 = clsProductDetails.OrderSlipPrinter5;
                        clsItemDetails.OrderSlipPrinted = false;
                        clsItemDetails.PercentageCommision = clsProductDetails.PercentageCommision;
                        clsItemDetails.Commision = clsItemDetails.Amount * (clsItemDetails.PercentageCommision / 100);
                        clsItemDetails.RewardPoints = clsProductDetails.RewardPoints;
                        clsItemDetails.ItemRemarks = "";
                        clsItemDetails.ReturnTransactionItemsID = 0;
                        clsItemDetails.SupplierID = clsProductDetails.SupplierID;
                        clsItemDetails.SupplierCode = clsProductDetails.SupplierCode;
                        clsItemDetails.SupplierName = clsProductDetails.SupplierName;

                        clsItemDetails.ProductPackageID = clsProductPackageDetails.PackageID;
                        clsItemDetails.ProductUnitID = clsProductPackageDetails.UnitID;
                        clsItemDetails.ProductUnitCode = clsProductPackageDetails.UnitCode;

                        if (!mclsTerminalDetails.IsParkingTerminal)
                        {
                            // 06Mar2015 : Override the price base on the Price Level
                            if (mclsSysConfigDetails.EnablePriceLevel)
                            {
                                switch (mclsContactDetails.PriceLevel)
                                {
                                    case PriceLevel.SRP: clsItemDetails.Price = clsProductPackageDetails.Price; break;
                                    case PriceLevel.One: clsItemDetails.Price = clsProductPackageDetails.Price1 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price1; break;
                                    case PriceLevel.Two: clsItemDetails.Price = clsProductPackageDetails.Price2 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price2; break;
                                    case PriceLevel.Three: clsItemDetails.Price = clsProductPackageDetails.Price3 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price3; break;
                                    case PriceLevel.Four: clsItemDetails.Price = clsProductPackageDetails.Price4 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price4; break;
                                    case PriceLevel.Five: clsItemDetails.Price = clsProductPackageDetails.Price5 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price5; break;
                                    case PriceLevel.WSPrice: clsItemDetails.Price = clsProductPackageDetails.WSPrice == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.WSPrice; break;
                                    default: clsItemDetails.Price = clsProductPackageDetails.Price; break;
                                }
                                if (mclsContactDetails.PriceLevel != PriceLevel.SRP)
                                {
                                    InsertAuditLog(AccessTypes.ChangePrice, "Barcode: " + clsItemDetails.BarCode + " ... Product Code:" + clsItemDetails.ProductCode + " ... Price Level:" + mclsContactDetails.PriceLevel.ToString("G") + "... SRP: " + clsProductPackageDetails.Price.ToString("#,###.#0") + " NewPrice: " + clsItemDetails.Price.ToString("#,###.#0"));
                                }
                            }

                            clsItemDetails.PackageQuantity = clsProductPackageDetails.Quantity;
                            clsItemDetails.Amount = (clsItemDetails.Quantity * clsItemDetails.Price) - (clsItemDetails.Quantity * clsItemDetails.Discount);
                            clsItemDetails.Commision = clsItemDetails.Amount * (clsItemDetails.PercentageCommision / 100);
                        }
                        clsItemDetails.MatrixPackageID = clsProductPackageDetails.MatrixID;
                        clsItemDetails.VariationsMatrixID = clsProductDetails.MatrixID;
                        clsItemDetails.MatrixDescription = clsProductDetails.MatrixDescription;
                        

                        clsItemDetails = ComputeItemTotal(clsItemDetails); // set the grossales, vat, discounts, etc.(Details);

                        if (!mboIsInTransaction)
                        {
                            lblTransDate.Text = DateTime.Now.ToString("MMM. dd, yyyy hh:mm:ss tt");
                            if (!this.CreateTransaction()) { clsProductPackage.CommitAndDispose(); return; }
                        }

                        AddItem(clsItemDetails);
                    }
					else
					{
						MessageBox.Show("Sorry the item is not yet entered in the system. Please select the generic code for this item.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
					}
					clsProductPackage.CommitAndDispose();
				}
			}
		}
コード例 #3
0
ファイル: MainRestoWnd.cs プロジェクト: marioricci/erp-luma
		private void SelectContact(AceSoft.RetailPlus.Data.ContactGroupCategory enumContactGroupCategory)
		{
			// 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 && enumContactGroupCategory == AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER)
			{
				MessageBox.Show("Sorry you cannot select ORDER SLIP customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}

			if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto && mboIsInTransaction)
			{
				switch (enumContactGroupCategory)
				{ 
					case AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER:
						MessageBox.Show("Sorry you cannot select a customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
						break;
					case AceSoft.RetailPlus.Data.ContactGroupCategory.AGENT:
						MessageBox.Show("Sorry you cannot select an agent when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
						break;
				}

				return;
			}

			try
			{
				switch (enumContactGroupCategory)
				{
					case AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER:
						clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting customer.");
						if (mclsTerminalDetails.ShowCustomerSelection == false)
						{
							clsEvent.AddEventLn("Cancelled! ShowCustomerSelection is OFF, reward is ON.");
							txtBarCode.Text = Constants.SWIPE_REWARD_CARD;
							txtBarCode.Focus(); txtBarCode.SelectionStart = txtBarCode.Text.Length + 1;
							return;
						}
						break;
					case AceSoft.RetailPlus.Data.ContactGroupCategory.AGENT:
						clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting agent.");
						break;
				}

				DialogResult result; Data.ContactDetails details;
				TableSelectWnd clsTableSelectWnd = new TableSelectWnd();
				clsTableSelectWnd.TerminalDetails = mclsTerminalDetails;
                clsTableSelectWnd.ContactGroupCategory = enumContactGroupCategory;
				clsTableSelectWnd.ShowAvailableTableOnly = mboIsInTransaction;
				clsTableSelectWnd.ShowDialog(this);
				details = clsTableSelectWnd.Details;
				result = clsTableSelectWnd.Result;
				clsTableSelectWnd.Close();
				clsTableSelectWnd.Dispose();

				if (result == DialogResult.OK)
				{
					// 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);
                            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);
                                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);

                        // 13Mar2015 : MPC, override the price using the PriceLevel
                        //             For PriceLevel1...5
                        if (mclsSysConfigDetails.EnablePriceLevel)
                        {
                            Cursor.Current = Cursors.WaitCursor;

                            Int32 iOldRow = dgItems.CurrentRowIndex;
                            Data.SalesTransactionItemDetails Details = new Data.SalesTransactionItemDetails();

                            Data.ProductPackage clsProductPackage = new Data.ProductPackage(mConnection, mTransaction);
                            mConnection = clsProductPackage.Connection; mTransaction = clsProductPackage.Transaction;

                            Data.ProductPackageDetails clsProductPackageDetails = new Data.ProductPackageDetails();

                            System.Data.DataTable dt = (System.Data.DataTable)dgItems.DataSource;
                            for (int x = 0; x < dt.Rows.Count; x++)
                            {
                                dgItems.CurrentRowIndex = x;
                                Details = getCurrentRowItemDetails();

                                dgItems.UnSelect(x);
                                if (Details.TransactionItemStatus == TransactionItemStatus.Valid)
                                {
                                    clsProductPackageDetails = clsProductPackage.Details(Details.ProductPackageID);

                                    switch (mclsContactDetails.PriceLevel)
                                    {
                                        case PriceLevel.SRP: Details.Price = clsProductPackageDetails.Price; break;
                                        case PriceLevel.One: Details.Price = clsProductPackageDetails.Price1 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price1; break;
                                        case PriceLevel.Two: Details.Price = clsProductPackageDetails.Price2 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price2; break;
                                        case PriceLevel.Three: Details.Price = clsProductPackageDetails.Price3 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price3; break;
                                        case PriceLevel.Four: Details.Price = clsProductPackageDetails.Price4 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price4; break;
                                        case PriceLevel.Five: Details.Price = clsProductPackageDetails.Price5 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price5; break;
                                        case PriceLevel.WSPrice: Details.Price = clsProductPackageDetails.WSPrice == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.WSPrice; break;
                                        default: Details.Price = clsProductPackageDetails.Price; break;
                                    }
                                    Details = ApplyPromo(Details);

                                    ApplyChangeQuantityPriceAmountDetails(x, Details, "Change Price: Change Contact");
                                }
                            }

                            clsProductPackage.CommitAndDispose();

                            if (iOldRow >= 0)
                            {
                                dgItems.CurrentRowIndex = iOldRow;
                                dgItems.Select(iOldRow);

                                Details = getCurrentRowItemDetails();
                                DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret);
                                DisplayItemToTurretDel.BeginInvoke(Details.Description, Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null);
                                InsertAuditLog(AccessTypes.ChangePrice, "Change price: change contact : for item " + Details.ProductCode + " to " + Details.Price.ToString("#,##0.#0") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                                mbodgItemRowClick = false;
                            }
                            
                            Cursor.Current = Cursors.Default;
                        }
                    }
                    clsSalesTransactions.CommitAndDispose();
				}
				else { clsEvent.AddEventLn("Cancelled!"); }
			}
			catch (Exception ex)
			{ clsEvent.AddErrorEventLn(ex); }
		}