Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
185 kB
1
Indexable
Never
using Exact.SystemLayer.TypeExtension;
using Microsoft.VisualBasic;
using System;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using UpgradeHelpers.Gui;
using UpgradeHelpers.Helpers;

namespace Exact.Inventory.ItemBrowser
{
	[Exact.Win.UI.Form.FormLayout(ShowExactMenu=false, ShowActionBar=true, ShowStatusBar=true)]
	internal partial class frmMain
		: Exact.Win.UI.Form.ExactFormBase
	{


		private Exact.SystemLayer.Interfaces.IExactMaintenance m_maint = null; //To start maintenance apps
		private Exact.DataLayer.IEdlRef ref_Renamed = null;
		private clsItem m = null;
		private Exact.SystemLayer.Interfaces.IApplication m_App = null;
		private Exact.SystemLayer.Interfaces.ICompany m_Comp = null;
		private Exact.SystemLayer.Interfaces.ITranslator m_Term = null;
		private Exact.SystemLayer.Interfaces.ISettings m_Set = null;
		private Exact.DataLayer.IEdlConnection m_Conn = null;
		private Exact.SystemLayer.Interfaces.IGateKeeper m_gk = null;
		//BR41.204.403 tans285567 - Precision of prices is not rounded correctly
		private Exact.SystemLayer.Interfaces.ICurrencyCalculator m_CurCalc = null;

		private string gsValutaCode = "";
		private string gsValutaCodeDef = "";
		private string gItemCode = "";
		private string gOriginalItemCode = ""; //FC 16.044.993
		private int hAncient = 0;
		private bool gbBusy = false;
		private bool gbBrowserSelType = false;
		private bool gbBrowserReplSelType = false;

		private GlobalInterfaces.GI_Exact.Inventory.SerialBatch.ISerialBatch gObjSerialBatch = null;
		private bool gbIsHourItem = false;
		//BR:12.368.269 chin31862 15/09/2004
		private bool gbIsExtraItem = false;
		//br25.109.858(simc178002)[31/12/2007] Test case 1-1: Outsourced item browser is launches item maintenance window in standard mode when click on 'Add' icon/ <Copy> button
		private bool gbIsOutsourcedItem = false;
		private int lUserID = 0;
		private GlobalInterfaces.GI_Exact.Inventory.Warehouse.IclsEstkWarehouse mObjWareH = null;
		private GlobalInterfaces.GI_Exact.Inventory.StockQuantities.IclsStockQuantities mObjStkQty = null;
		private bool m_bItemRange = false;
		private bool gbRefreshBrowser = false;
		private GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton gBtnClicked = GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious; //hooho
		private bool gBtnPrevIsNotNull = false; //hooho

		//FC 16.045.238 Item browser navigation
		private clsStack m_oStackItemNav = null;
		private object m_sNavItemBrowserVal = null;
		private string m_sNavItemBrowserCol = "";
		private string m_sNavItemBrowserOrderBy = "";
		private int m_iMaxRows = 0;
		private bool m_bDescOrder = false;

		//BR 16.409.543
		private string m_sPrevOrderBy = "";
		private bool m_bPrevSortOrder = false;
		private bool m_bBrowserRefreshed = false;

		public bool bBusyLoading = false;

		private const int OPT_COMPACT = 200;

		const int BUT_DUMMY = 0;
		const int BUT_SELECT = 1;
		const int BUT_REPLACE = 2;
		const int BUT_ALLITEMS = 3;
		const int BUT_BYSUPPLIER = 4;
		const int BUT_BYWAREHOUSE = 5;
		const int BUT_ITEMPLAN = 6;
		const int BUT_MRP = 7;
		const int BUT_CARD = 8;
		const int BUT_OPEN = 9;
		const int BUT_NEW = 10;
		const int BUT_CLOSE = 11;
		const int BUT_COPY = 12;


		const string BROWSE_MAIN = "M";
		const string BROWSE_REPLACE = "R";

		const int BROWSE_WAREHOUSE = 1;

		//item selection
		const string ALL_ITEMS = "U";
		const string PRODUCT_BY_DEBTOR = "P";

		//08.891.478
		bool bHaveMaintainItem = false;

		private enum QualifyAs
		{
			QA_SUPPLIERCODE = 3,
			QA_DESCRIPTION = 2,
			QA_SEARCHCODE = 1,
			QA_ITEMCODE = 0,
			QA_NOTHING = 9
		}

		private bool bShowReplaceBrowser = false;

		//UPGRADE_NOTE: (2041) The following line was commented. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2041
		//[DllImport("user32.dll", EntryPoint = "SetFocus", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
		//extern public static int Putfocus(int hwnd);

		//[jose276913 14-03-2011 16:10 (GMT +08:00)] 38.542.616
		private GlobalInterfaces.GI_Exact.Cmdm.Tools.IclsGeneral m_oCMDMTools = null;
		private const string gsCMDMTopicItem = "ITEM"; //Constant to hold the topic value
		private bool bUseCentralData = false;
		public frmMain(GlobalProps globalProps)
			: base()
		{
			gProps = globalProps;	// gProps needs to be assigned before calling InitializeComponent()
			//This call is required by the Windows Form Designer.
			isInitializingComponent = true;
			InitializeComponent();
			isInitializingComponent = false;
			ReLoadForm(false);
		}
		private GlobalProps gProps;


		private void actActionBar_ButtonClick(object eventSender, Exact.Win.UI.Controls.Interfaces.ButtonClickEventArgs eventArgs)
		{
			int nID = eventArgs.nID;

			try
			{
				if (gbBusy)
				{
					return;
				}

				switch(nID)
				{
					case BUT_SELECT : 
						if (DoSelect())
						{
							gProps.ModItemBrowser.gbCancel = false;
							//UPGRADE_TODO: (1069) Error handling statement (On Error Resume Next) was converted to a pattern that might have a different behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1069
							try
							{
								ItemFilter.Focus();
								this.Hide();
							}
							catch (Exception catchedException)
							{
								Exact.Exceptions.Globe.BaseGlobeException exc = Exact.Exceptions.Utils.ExceptionBuilder.Build(catchedException);
							}
						} 
						 
						break;
					case BUT_REPLACE : 
						 
						if (!pnlReplaceBrowser.Visible)
						{
							if (!(Browser[1].SelectedRowCount > 1))
							{
								//UPGRADE_WARNING: (1068) Browser()() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
								gOriginalItemCode = Convert.ToString(Browser[1].get_value("items.ItemCode"));
							}
						} 
						 
						pnlReplaceBrowser.Visible = !pnlReplaceBrowser.Visible; 
						bShowReplaceBrowser = pnlReplaceBrowser.Visible; 
						if (pnlReplaceBrowser.Visible)
						{
							ItemFilter.IsExpanded = GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.ExpansionTypes.Collapsed;
						} 
						FormResize(); 
						 
						//13.472.241, if only multiple rows selected just display the repl. browser items if the fellow keep on activate/deactivate the browser. 
						if (!(Browser[1].SelectedRowCount > 1))
						{
							//UPGRADE_WARNING: (1068) Browser()() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							gItemCode = Convert.ToString(Browser[1].get_value("items.ItemCode"));
						} 
						 
						RefreshReplacementBrowser(true); 
						 
						//FC 16.044.993 fill back the original item data 
						if (!pnlReplaceBrowser.Visible)
						{
							gItemCode = gOriginalItemCode;
							FillItemInfo();
						} 
						 
						break;
					case BUT_ALLITEMS : 
						ActionBar.EnableButton(BUT_ALLITEMS, false); 
						ActionBar.EnableButton(BUT_BYSUPPLIER, true); 
						DoRefresh(); 
						 
						break;
					case BUT_BYSUPPLIER : 
						ActionBar.EnableButton(BUT_ALLITEMS, true); 
						ActionBar.EnableButton(BUT_BYSUPPLIER, false); 
						DoRefresh(); 
						 
						break;
					case BUT_BYWAREHOUSE : 
						OpenWarehouse(); 
						 
						break;
					case BUT_ITEMPLAN : 
						//>> Br : 09.795.509 
						OpenItemPlanning(); 
						 
						break;
					case BUT_MRP : 
						//YMM, Br : 09.150.141 
						BrowseMRPItemPlanning(); 
						 
						break;
					case BUT_CARD : 
						SpawnItemCard(); 
						 
						break;
					case BUT_OPEN : 
						OpenMaint(false); 
						 
						break;
					case BUT_NEW : 
						OpenMaint(true); 
						 
						break;
					case BUT_COPY : 
						OpenMaint(true, true); 
						 
						break;
					case BUT_CLOSE : 
						gProps.ModItemBrowser.gbCancel = true; 
						//UPGRADE_TODO: (1069) Error handling statement (On Error Resume Next) was converted to a pattern that might have a different behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1069 
						try
						{
							ItemFilter.Focus();
							this.Hide();
						}
						catch (Exception catchedException)
						{
							Exact.Exceptions.Globe.BaseGlobeException exc2 = Exact.Exceptions.Utils.ExceptionBuilder.Build(catchedException);
						} 
						break;
				}
			}
			finally
			{
				eventArgs.nID = nID;
			}
		}

		private bool DoSelect()
		{
			bool result = false;
			string vID = "";
			if (IsEdlBusy())
			{
				Browser[1].StopBackgroundFetch();
			} //mandatory check on the edl threading

			result = true;

			int i = 0;
			if (!gProps.ModItemBrowser.gbMultiSelect)
			{
				if (pnlReplaceBrowser.Visible && BrowserRepl[1].CurrentRow != 0)
				{
					gProps.FrmConfirm.ShowDialog();
				}
				else
				{
					gProps.ModItemBrowser.giWhichItem = GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SELECT_MAIN_ITEM;
				}
				switch(gProps.ModItemBrowser.giWhichItem)
				{
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SELECT_MAIN_ITEM : 
						//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068 
						gProps.ModItemBrowser.gSelectArtCd = Convert.ToString(Browser[1].get_value("items.ItemCode")); 
						 
						//ngty@ 06.653.193 
						//BR 12.447.878 do not return recipve.version for gappMode = TYPE_PROD_ALL since it not link to recipe table anymore 
						//If gParentApp = INTERNAL_ORDER And (gAppMode = TYPE_PROD_FILLED Or gAppMode = TYPE_PROD_ALL) And Not IsNull(Browser(1).value("recipe.version")) Then 
						//PBI33204 - Kanban order entry in EGN: Param for Kanban order 
						if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_KANBAN) && !Exact.SystemLayer.Common.ConvertHelper.IsNull(Browser[1].get_value("recipe.version")))
						{
							//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to int. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							gProps.ModItemBrowser.glItemVersion = Convert.ToInt32(Browser[1].get_value("recipe.version"));
						} 
						break;
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SELECT_REPLACE_ITEM : 
						//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068 
						gProps.ModItemBrowser.gSelectArtCd = Convert.ToString(BrowserRepl[1].get_value("items.ItemCode")); 
						 
						//ngty@ 06.653.193 
						//BR 12.447.878 do not return recipve.version for gappMode = TYPE_PROD_ALL since it not link to recipe table anymore 
						//If gParentApp = INTERNAL_ORDER And (gAppMode = TYPE_PROD_FILLED Or gAppMode = TYPE_PROD_ALL) And Not IsNull(Browser(1).value("recipe.version")) Then 
						//PBI33204 - Kanban order entry in EGN: Param for Kanban order 
						if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_KANBAN) && !Exact.SystemLayer.Common.ConvertHelper.IsNull(Browser[1].get_value("recipe.version")))
						{
							//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to int. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							gProps.ModItemBrowser.glItemVersion = Convert.ToInt32(BrowserRepl[1].get_value("recipe.version"));
						} 
						break;
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SELECT_CANCEL : 
						result = false; 
						break;
				}
			}
			else
			{
				i = 1;

				//13.857.206 lohp17191 Make sure to Initialize array before we start filling it.
				gProps.ModItemBrowser.gSelectedItemCodes = new System.Collections.Generic.List<string>();

				if (!pnlReplaceBrowser.Visible)
				{
					if (Browser[1].SelectedRowCount == 1)
					{
						//BR 24.410.116 - this should works as well if using cursor to move to the desired item line
						//              - so, when press enter, the dotted line should be selected instead although the highlighted item line is different
						Browser[1].SelectRow(Browser[1].CurrentRow, true);
						//gProps.ModItemBrowser.gSelectedItemCodes = ArraysHelper.RedimPreserve(gProps.ModItemBrowser.gSelectedItemCodes, new int[]{i + 1});
						//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
						//gProps.ModItemBrowser.gSelectedItemCodes[i - 1] = Convert.ToString(Browser[1].get_value("items.ItemCode"));

						gProps.ModItemBrowser.gSelectedItemCodes.Add(Convert.ToString(Browser[1].get_value("items.ItemCode")));

						//The codes below commented by BR 24.410.116, not sure why it was implemented as below as there's no comments stated here
						//                Call Browser(1).SelectRow(Browser(1).SelectedRows(0), True)
						//                ReDim Preserve gSelectedItemCodes(i)
						//
						//                gSelectedItemCodes(i - 1) = Browser(1).Value("items.ItemCode")   'Browser(1).RowValue(Browser(1).SelectedRows(0), "items.ItemCode")
					}
					else
					{
						foreach (string vIDIterator in (System.Collections.IEnumerable) Browser[1].get_SelectedRowValues("items.ItemCode"))
						{
							//vID = vIDIterator;
							//gProps.ModItemBrowser.gSelectedItemCodes = ArraysHelper.RedimPreserve(gProps.ModItemBrowser.gSelectedItemCodes, new int[]{i + 1});
							//gProps.ModItemBrowser.gSelectedItemCodes[i - 1] = vID;
							//i++;
							////vID
							//vID = default(string);
							gProps.ModItemBrowser.gSelectedItemCodes.Add(vIDIterator);
							i++;
						}
					}
				}
				else
				{
					if (BrowserRepl[1].SelectedRowCount > 0)
					{
						foreach (string vIDIterator2 in (System.Collections.IEnumerable) BrowserRepl[1].get_SelectedRowValues("items.ItemCode"))
						{
							//vID = vIDIterator2;
							//gProps.ModItemBrowser.gSelectedItemCodes = ArraysHelper.RedimPreserve(gProps.ModItemBrowser.gSelectedItemCodes, new int[]{i + 1});
							//gProps.ModItemBrowser.gSelectedItemCodes[i - 1] = vID;
							//i++;
							////vID
							//vID = default(string);
							gProps.ModItemBrowser.gSelectedItemCodes.Add(vIDIterator2);
							i++;
						}
					}
					else
					{
						foreach (string vIDIterator3 in (System.Collections.IEnumerable) Browser[1].get_SelectedRowValues("items.ItemCode"))
						{
							//vID = vIDIterator3;
							//gProps.ModItemBrowser.gSelectedItemCodes = ArraysHelper.RedimPreserve(gProps.ModItemBrowser.gSelectedItemCodes, new int[]{i + 1});
							//gProps.ModItemBrowser.gSelectedItemCodes[i - 1] = vID;
							//i++;
							////vID
							//vID = default(string);
							gProps.ModItemBrowser.gSelectedItemCodes.Add(vIDIterator3);
							i++;
						}
					}
				}
			}
			return result;
		}

		//UPGRADE-WARNING: Parameter Params was changed from byref to byval.
		//UPGRADE-WARNING: Parameter sExename was changed from byref to byval.
		public int GetFuncID(string sExename, string Params)
		{

			int result = 0;
			using (Exact.DataLayer.IEdlRef qryref = m_Conn.CreateRef("pwfunc", "exename,param,descr64", "fnc_id", Exact.DataLayer.LockModes.edlReadOnly))
			{
				if (qryref.Find3(sExename, Params, "maintain"))
				{
					result = qryref.get_Long("fnc_id");
				}
			}

			return result;
		}

		//Start maintenance
		private void OpenMaint(bool bNew, bool bCopy = false)
		{
			if (IsEdlBusy())
			{
				Browser[1].StopBackgroundFetch();
			} //mandatory check on the edl threading

			Exact.DataLayer.EdlObject ID = null;
			string sItemCode = "";
			int lLineNum = 0;
			Exact.SystemLayer.Interfaces.IValueSet vs = null;
			bool bRowSelected = false;
			//br25.109.858(simc178002)[31/12/2007]Test 1-4 RTE when add new
			Exact.DataLayer.EdlObject vIsOutsourced = null;

			//Create maint object, if necessary
			if (m_maint is null)
			{
				m_maint = (Exact.SystemLayer.Interfaces.IExactMaintenance) GlobalInterfaces.Factory.CreateInstance<GlobalInterfaces.GI_Exact.Maintenance.Inventory.Items.IItems>();
				m_App.ConnectObject(m_maint, m_Comp, m_Term);
			}


			//Start maintenenance
			if (!bNew && !bCopy)
			{
				if (pnlReplaceBrowser.Visible && BrowserRepl[1].SelectedRowCount > 0)
				{
					//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemCode = Convert.ToString(BrowserRepl[1].get_value("items.itemcode"));
					lLineNum = BrowserRepl[1].CurrentRow;
				}
				else
				{
					//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemCode = Convert.ToString(Browser[1].get_value("items.itemcode"));
					lLineNum = Browser[1].CurrentRow;
					bRowSelected = Browser[1].SelectedRowCount != 0;
				}

				// 15.123.908 lohp17191 only call edit screen when a row has been selected in the browsers
				if (lLineNum > 0 || bRowSelected)
				{
					ID = m_Conn.Query("SELECT ID FROM items WHERE ItemCode = ?", sItemCode, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);
					if (Exact.SystemLayer.Common.ConvertHelper.IsEmpty(ID))
					{
						m_App.Message(this.Handle, m_Term.String(11337, "Not found") + ": " + sItemCode);
					}
					m_maint.Edit(this.Handle, (int) ID, Exact.SystemLayer.Interfaces.MaintenanceFlags.mntModal);
				}
			}
			else
			{
				// 11.894.077 lohp17191 If Copy is true and New flag is true, then the Copy button must've been clicked
				// Start the maintanance item in Add mode, and pass in the ID of the selected item in a valueset
				if (bCopy)
				{
					if (pnlReplaceBrowser.Visible && BrowserRepl[1].SelectedRowCount > 0)
					{
						//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
						sItemCode = Convert.ToString(BrowserRepl[1].get_value("items.itemcode"));
						lLineNum = BrowserRepl[1].CurrentRow;
					}
					else
					{
						//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
						sItemCode = Convert.ToString(Browser[1].get_value("items.itemcode"));
						lLineNum = Browser[1].CurrentRow;
					}
					//br25.109.858(simc178002)[31/12/2007] Test case 1-1: Outsourced item browser is launches item maintenance window in standard mode when click on 'Add' icon/ <Copy> button
					ID = m_Conn.Query("SELECT ID, Type, IsOutsourcedItem FROM items WHERE ItemCode = ?", sItemCode, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);

					if (Exact.SystemLayer.Common.ConvertHelper.IsEmpty(ID))
					{
						m_App.Message(this.Handle, m_Term.String(11337, "Not found") + ": " + sItemCode);
					}
					else
					{
						gbIsHourItem = ((string) ID[1]) == "L" || ((string) ID[1]) == "M";
						gbIsExtraItem = ((string) ID[1]) == "P";
						//br25.109.858(simc178002)[31/12/2007]Test case 1-1: Outsourced item browser is launches item maintenance window in standard mode when click on 'Add' icon/ <Copy> button
						gbIsOutsourcedItem = ((double) ID[2]) == 1;
					}

					// Create valueset and add the ID before passing it to mitems
					vs = new Exact.SystemLayer.Common.ValueSet();
					vs.Add("record", ID[0].Data);

					//BR:12.220.318 Chin31862 06/09/2004
					//For Hour Item Maintenance will display others Screen
					if (gbIsHourItem)
					{
						m_maint.Add(this.Handle, vs, Exact.SystemLayer.Interfaces.MaintenanceFlags.mntModal, "ITEMS -MNTN -BLMH -COPY");
					}
					else
					{
						//BR:12.368.269 chin31862 16/09/2004
						//For Extra Item will display Extra item screen

						//add by chan24680 for br 14.871.690
						//check the item is it a extra charges.
						if (gbIsExtraItem)
						{
							m_maint.Add(this.Handle, vs, Exact.SystemLayer.Interfaces.MaintenanceFlags.mntModal, "ITEMS -MNTN -BLMP -COPY");
						}
						else if (gbIsOutsourcedItem)
						{ 
							//br25.109.858(simc178002)[31/12/2007] Test case 1-1: Outsourced item browser is launches item maintenance window in standard mode when click on 'Add' icon/ <Copy> button
							m_maint.Add(this.Handle, vs, Exact.SystemLayer.Interfaces.MaintenanceFlags.mntModal, "ITEMS -MNTN -BLMS -COPY");
						}
						else
						{
							m_maint.Add(this.Handle, vs, Exact.SystemLayer.Interfaces.MaintenanceFlags.mntModal, "");
						}
					}

				}
				else
				{

					//br25.109.858(simc178002)[31/12/2007] Test case 1-1: Outsourced item browser is launches item maintenance window in standard mode when click on 'Add' icon/ <Copy> button
					//Add new
					//Test 1-4 RTE when add new
					//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemCode = Convert.ToString(Browser[1].get_value("items.itemcode"));

					vIsOutsourced = m_Conn.Query("SELECT IsOutsourcedItem FROM items WHERE ItemCode = ?", sItemCode, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);

					if (((double) vIsOutsourced) == 1)
					{
						m_maint.Add(this.Handle, vs, Exact.SystemLayer.Interfaces.MaintenanceFlags.mntModal, "ITEMS -MNTN -BLMS");
					}
					else
					{
						m_maint.Add(this.Handle, vs, Exact.SystemLayer.Interfaces.MaintenanceFlags.mntModal);
					}
				}
			}

			m_maint = null;
			Browser[1].Refresh();
			//Fc:24.877.475 - load the stock qty into edl browser.
			//refresh stock qty col

			LoadStockQty();

		}

		//UPGRADE-WARNING: Parameter bItem was changed from byref to byval.
		//UPGRADE_NOTE: (7001) The following declaration (OpenHRMPlanning) seems to be dead code More Information: https://www.mobilize.net/vbtonet/ewis/ewi7001
		//private void OpenHRMPlanning(bool bItem)
		//{
			//if (IsEdlBusy())
			//{
				//Browser[1].StopBackgroundFetch();
			//} //mandatory check on the edl threading
			//
			//Exact.SystemLayer.Interfaces.IValueSet vsSpawn = new Exact.SystemLayer.Common.ValueSet();
			//string sItemCode = "";
			//string sShow = "";
			//string sParam = "";
			//
			//if (BrowserRepl[1].Visible && BrowserRepl[1].SelectedRowCount > 0)
			//{
				////UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				//sItemCode = Convert.ToString(BrowserRepl[1].get_Value("items.ItemCode"));
			//}
			//else
			//{
				////UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				//sItemCode = Convert.ToString(Browser[1].get_Value("items.ItemCode"));
			//}
			//
			//if (bItem)
			//{
				//sShow = "I";
				//sParam = "I";
				//
				//vsSpawn.Add("ItemCode", sItemCode);
				//vsSpawn.Add("Warehouse", gProps.ModItemBrowser.gWareHs);
				//vsSpawn.Add("Content", "A");
				//vsSpawn.Add("Options", "X");
			//}
			//else
			//{
				//sShow = "M";
				//sParam = "ME";
				//
				//vsSpawn.Add("fipShow", sShow);
				//vsSpawn.Add("fipActivity", sItemCode);
				//vsSpawn.Add("fipCostcenterFrom", "");
				//vsSpawn.Add("fipCostcenterTo", "");
				//vsSpawn.Add("fipJobGroup", "");
				//vsSpawn.Add("fipProject", "");
				//vsSpawn.Add("fipResource", m_Comp.User.ID);
				//vsSpawn.Add("ComboFip", DateTime.Parse(Exact.SystemLayer.API.vbdate.VBGetSysDate()).Month);
				//vsSpawn.Add("ParentClause", " IS NULL ");
			//}
			//
			//Exact.SystemLayer.Interfaces.ISpawner spnApp = (Exact.SystemLayer.Interfaces.ISpawner) Exact.SystemLayer.API.misc.GetApp();
			//spnApp.SpawnEx(new IntPtr(frmMain.DefInstance.Handle), "ehmroPlanning.exe", Exact.SystemLayer.Interfaces.SpawnFlags.spawnWait, null, sParam, vsSpawn);
			//gProps.ModItemBrowser.ForceToForeGround();
			//
		//}

		//view stock level by warehouse
		private void OpenWarehouse()
		{
			if (IsEdlBusy())
			{
				Browser[1].StopBackgroundFetch();
			} //mandatory check on the edl threading

			string sItemCode = "";
			string sSelectWareHs = "";
			string sSelectWHLoc = "";
			bool bCancel = false;

			//Create warehouse browser object, if necessary
			if (mObjWareH is null)
			{
				mObjWareH = GlobalInterfaces.Factory.CreateInstance<GlobalInterfaces.GI_Exact.Inventory.Warehouse.IclsEstkWarehouse>();
			}

			//First get information
			if (!pnlReplaceBrowser.Visible)
			{
				//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				sItemCode = Convert.ToString(Browser[1].get_value("items.ItemCode"));
			}
			else
			{
				if (BrowserRepl[1].SelectedRowCount > 0)
				{
					//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemCode = Convert.ToString(BrowserRepl[1].get_value("items.ItemCode"));
				}
				else
				{
					//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemCode = Convert.ToString(Browser[1].get_value("items.ItemCode"));
				}
			}

			mObjWareH.WHCodeLoctBrw(gProps.FrmMain.Handle , "O", BROWSE_WAREHOUSE, sItemCode, ref sSelectWareHs, ref sSelectWHLoc, ItemFilter.GetWarehouse(), ref bCancel);

			if (!bCancel)
			{
				ItemFilter.DefaultFilterValue("warehouse", sSelectWareHs);
			}

		}
		public void BrowseMRPItemPlanning()
		{
			object sItemCode = null;
			//doc :02.972.465


			if (IsEdlBusy())
			{
				Browser[1].StopBackgroundFetch();
			} //mandatory check on the edl threading

			if (!pnlReplaceBrowser.Visible)
			{
				sItemCode = (gProps.ModItemBrowser.gbMultiSelect) ? Browser[1].get_SelectedRowValues("items.ItemCode") : Browser[1].get_value("items.ItemCode");
			}
			else
			{
				if (BrowserRepl[1].SelectedRowCount > 0)
				{
					sItemCode = (gProps.ModItemBrowser.gbMultiSelect) ? BrowserRepl[1].get_SelectedRowValues("items.ItemCode") : BrowserRepl[1].get_value("items.ItemCode");
				}
				else
				{
					sItemCode = (gProps.ModItemBrowser.gbMultiSelect) ? Browser[1].get_SelectedRowValues("items.ItemCode") : Browser[1].get_value("items.ItemCode");
				}
			}

			string sWarehr = ItemFilter.GetWarehouse();

			this.Cursor = Cursors.WaitCursor;

			Exact.SystemLayer.Interfaces.IValueSet vs = new Exact.SystemLayer.Common.ValueSet();
			if (~((System.String.IsNullOrWhiteSpace(sWarehr)) ? -1 : 0) != 0)
			{
				vs.Add("Warehouse", sWarehr);
			}
			//FC 17.845.818
			//Call vs.Add("ItemCode", sItemCode)
			vs.Add("ItemLists", sItemCode);
			//UPGRADE_WARNING: (2081) Array has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2081
			vs.Add("Date", new object[]{gProps.ModItemBrowser.gdDate, gProps.ModItemBrowser.gdDate.AddDays(14)});
			vs.Add("Content", "A");
			vs.Add("Options", "X");
			vs.Add("Scale", "D");
			vs.Add("Show", "ALL");
			//Call vs.Add("GroupBy", "O")
			//YMM, 09.150.141, document id  : 02.972.465
			vs.Add("GroupBy", "I");

            Exact.SystemLayer.Interfaces.ISpawner MySpawner = (Exact.SystemLayer.Interfaces.ISpawner) m_App;
            MySpawner.SpawnEx(this.Handle, "eStkoPlanning", Exact.SystemLayer.Interfaces.SpawnFlags.spawnWait | Exact.SystemLayer.Interfaces.SpawnFlags.spawnNewProcess, null, "I", vs);
            MySpawner = null;
            vs = null;
			this.Cursor = Cursors.Default;

            //Chan31941, 20040706 (BR 11.475.425): Display previous active screen once this screen is closed.
            gProps.ModItemBrowser.ForceToForeGround(this);

        }

		private void OpenItemPlanning()
		{
			if (IsEdlBusy())
			{
				Browser[1].StopBackgroundFetch();
			} //mandatory check on the edl threading

			GlobalInterfaces.GI_Exact.Inventory.ItemPlan.IclsItem oB = GlobalInterfaces.Factory.CreateInstance<GlobalInterfaces.GI_Exact.Inventory.ItemPlan.IclsItem>();
			string sItemCode = "";
			string sItemUnits = "";

			if (!pnlReplaceBrowser.Visible)
			{
				//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				sItemCode = Convert.ToString(Browser[1].get_value("items.ItemCode"));
				//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				sItemUnits = Convert.ToString(Browser[1].get_value("Items.PackageDescription"));
			}
			else
			{
				if (BrowserRepl[1].SelectedRowCount > 0)
				{
					//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemCode = Convert.ToString(BrowserRepl[1].get_value("items.ItemCode"));
					//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemUnits = Convert.ToString(BrowserRepl[1].get_value("Items.PackageDescription"));
				}
				else
				{
					//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemCode = Convert.ToString(Browser[1].get_value("items.ItemCode"));
					//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemUnits = Convert.ToString(Browser[1].get_value("Items.PackageDescription"));
				}
			}

			oB.BrowseExpectedPlanningPerDay(gProps.ModItemBrowser.gParentApp, gProps.ModItemBrowser.gAppMode, sItemCode, sItemUnits, ItemFilter.GetWarehouse(), "", DateTime.Parse(Exact.SystemLayer.API.vbdate.VBGetSysDate()));

		}

		//FC 16.045.238 Item browser navigation
		//UPGRADE-WARNING: Parameter Index was changed from byref to byval.
		private void Browser_ColumnsChanged(Object eventSender, EventArgs eventArgs)
		{

			Exact.DataLayer.IEdlSql oSql = null;
			string sOrderKey = "";
			string sDefOrderKey = "";
			int lRec = 0;
			if (!(Browser[1].SQLObject is null))
			{
				oSql = (Exact.DataLayer.IEdlSql) Browser[1].SQLObject;
				m_sNavItemBrowserOrderBy = oSql.get_Clause(Exact.DataLayer.EdlSqlClauses.edlSqlOrderBy);

				//BR 16.409.543 enable next btn if numrows>0 disable prev btn whenever columns changed
				ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);
				if (Browser[1].NumRows > 0)
				{ //solve for when change on column sorting, if numrow = 0, don't enable the next btn

					if (Browser[1].NumRows < ItemFilter.MaxRows)
					{
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, false);
					}
					else
					{
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, true);
					}
				}

				//BR 16.263.480 workaround to solve for the restore default function

				sDefOrderKey = "items.Description_" + m_Comp.MultiLang.DefaultIndex.ToString();

				//everytime refreshbrowser() called, set the registry
				if (gProps.ModItemBrowser.gbRefreshBrowserCall)
				{
					lRec = modRegistry.UpdateRegistry(m_App, "[" + Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "]-" + gProps.ModItemBrowser.gParentApp + "-" + gProps.ModItemBrowser.gAppMode, m_sNavItemBrowserOrderBy);
				}

				if (m_sNavItemBrowserOrderBy != sDefOrderKey)
				{
					sOrderKey = modRegistry.QueryRegistry(m_App, "[" + Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "]-" + gProps.ModItemBrowser.gParentApp + "-" + gProps.ModItemBrowser.gAppMode);
					//if sOrderKey is empty meant it has been restored default, refresh the browser to default state
					if (System.String.IsNullOrWhiteSpace(sOrderKey))
					{
						lRec = modRegistry.UpdateRegistry(m_App, "[" + Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "]-" + gProps.ModItemBrowser.gParentApp + "-" + gProps.ModItemBrowser.gAppMode, m_sNavItemBrowserOrderBy);
						m_sNavItemBrowserOrderBy = "";
						oSql.set_Clause(Exact.DataLayer.EdlSqlClauses.edlSqlOrderBy, sDefOrderKey);
						Browser[1].SQL = oSql.Sql;
						Browser[1].Refresh();
					}
				}
				else
				{
					lRec = modRegistry.UpdateRegistry(m_App, "[" + Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "]-" + gProps.ModItemBrowser.gParentApp + "-" + gProps.ModItemBrowser.gAppMode, sDefOrderKey);
				}
				// end BR 16.263.480

				//FC 16.045.238 Check if order by desc, need to eliminate the DESC from the column name
				if (m_sNavItemBrowserOrderBy.IndexOf("DESC") >= 0)
				{
					m_sNavItemBrowserCol = StringsHelper.Replace(m_sNavItemBrowserOrderBy, " DESC", "", 1, -1, CompareMethod.Binary);
					m_bDescOrder = true;
				}
				else
				{
					m_sNavItemBrowserCol = m_sNavItemBrowserOrderBy;
					m_bDescOrder = false;
				}

				m_sNavItemBrowserVal = "";

				//FC 16.045.238 if sorting change on the same column, if the current browser record = 0, the browser is won't show any record after change sorting
				//force refresh browser with m_sNavItemBrowserCol= ""
				if (m_bPrevSortOrder != m_bDescOrder && (m_sPrevOrderBy == m_sNavItemBrowserCol))
				{
					m_oStackItemNav.Clear(); //BR 16.409.543 always clear the stack when changing of column sorting
					m_bPrevSortOrder = m_bDescOrder; //set previous order by = current order by

					//BR 16.409.543 only for numrows = 0
					if (Browser[1].NumRows == 0)
					{
						gProps.ModItemBrowser.bGlobalTrigger = true; //need to include this to include the search criteria when refreshing
						DoRefresh();
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);
					}
				}

				//BR 16.409.543 if current browser return 0 record and different column is selected for sorting , it wont show any record,
				//therefore need to force refresh again to show the data
				if (m_sPrevOrderBy != m_sNavItemBrowserCol)
				{
					m_oStackItemNav.Clear(); //always clear the stack when changing of column sorting

					//the m_bBrowserRefreshed is to prevent infinite looping when numrows is always 0 even after different column sorting has fired
					//If Browser(1).NumRows = 0 And Not m_bBrowserRefreshed Then 'br30.041.183 chon32144 sorting for price no record show in next page
					m_sPrevOrderBy = m_sNavItemBrowserCol; //br30.041.183 chon32144 sorting for price no record show in next page
					m_bBrowserRefreshed = true;
					gProps.ModItemBrowser.bGlobalTrigger = true; //need to include this to include the search criteria when refreshing
					DoRefresh();
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);
					//Else
					//    m_bBrowserRefreshed = False
					//End If
				}

				m_sPrevOrderBy = m_sNavItemBrowserCol;

				//Fc:24.877.475 - load the stock qty into edl browser.
				//refresh stock qty col
				LoadStockQty();

				oSql = null;
				//end of BR 16.409.543

			}
		}

		//Change event for multiselect and single select browser
		//UPGRADE-WARNING: Parameter Index was changed from byref to byval.
		private void Browser_SelectionChanged(Object eventSender, EventArgs eventArgs)
		{
			int i = 0;
			int SelectedRow = 0;

			if (gProps.ModItemBrowser.gbMultiSelect)
			{
				SelectedRow = Browser[1].get_SelectedRows(0);
			}
			else
			{
				SelectedRow = Browser[1].CurrentRow;
			}

			//FC 17.845.818
			if (SelectedRow < 1)
			{
				ActionBar.EnableButton(BUT_MRP, false);
				ActionBar.EnableButton(BUT_SELECT, false);
				ActionBar.EnableButton(BUT_CARD, false);
				ActionBar.EnableButton(BUT_COPY, false);
				fbCommand[1].Enabled = false;
			}
			else
			{
				//angs BR 20.756.775 Hide <add>, <Edit> and copy buttons with E-Branche
				if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_POS_BRANCHE_OFFICE)))
				{
					fbCommand[1].Enabled = SelectedRow > 0 && Browser[1].NumRows > 0; //BR 22.530.908 Felix (29187): If no row selected or browser is empty, disabled to edit icon.
				}
			}

			gbBusy = true;

			if (this.Visible)
			{
				ActionBar.get_Button(BUT_DUMMY).Focus = true;
			}

			//Browser[1].Enabled = false;
			//ItemFilter.Enabled = false;

			//BR 22.319.808 Felix (29187): Do not obtain item code/currency if selected row is 0
			if (SelectedRow > 0)
			{
				//UPGRADE_WARNING: (1068) Browser().RowValue() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				gItemCode = Convert.ToString(Browser[1].get_RowValue(SelectedRow, "items.ItemCode"));

				if (!Exact.SystemLayer.Common.ConvertHelper.IsNull(Browser[1].get_RowValue(SelectedRow, "ItemAccounts.PurchaseCurrency")))
				{
					//UPGRADE_WARNING: (1068) Browser().RowValue() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					gsValutaCode = Convert.ToString(Browser[1].get_RowValue(SelectedRow, "ItemAccounts.PurchaseCurrency"));
				}
				else
				{
					gsValutaCode = gsValutaCodeDef;
				}

				//UPGRADE_WARNING: (1068) Browser().RowValue() of type Variant is being forced to double. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				if (Convert.ToDouble(Browser[1].get_RowValue(SelectedRow, "items.IsStockItem")) != 0)
				{
					gbIsHourItem = false;
				}
			}
			else
			{
				gItemCode = "";
				gsValutaCode = gsValutaCodeDef;
				gbIsHourItem = false;
			}

			if (((gProps.ModItemBrowser.gbMultiSelect && Browser[1].SelectedRowCount != 1) || (!gProps.ModItemBrowser.gbMultiSelect && Browser[1].CurrentRow == 0)) || (Browser[1].NumRows < 1))
			{

				DoButtons(false);
				ClearAllValues();
				RefreshReplacementBrowser(false);
			}
			else
			{
				DoButtons(true);
				if (pnlReplaceBrowser.Visible)
				{
					RefreshReplacementBrowser(true);
				}
				FillItemInfo(); //ngty@ put this here because i dont want it to fire when another item is selected
			}

			//Browser[1].Enabled = true;
			//ItemFilter.Enabled = true;
			if (this.Visible)
			{
				Browser[1].Focus();
			}

			gbBusy = false;
		}

		//UPGRADE-WARNING: Parameter Index was changed from byref to byval.
		private void Browser_RowsetFetched(Object eventSender, EventArgs eventArgs)
		{
			if (Browser[1].NumRows == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.MAX_REC)
			{
				ItemFilter.WarningMessage(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.MessageType.REC_EXCEEDED);
			}
			else if (Browser[1].NumRows > 0 && Browser[1].NumRows < GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.MAX_REC)
			{ 
				ItemFilter.WarningMessage(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.MessageType.REC_NORMAL);
			}
			else if (Browser[1].NumRows == 0)
			{ 
				ItemFilter.WarningMessage(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.MessageType.REC_NONE);
			}
		}

		//UPGRADE-WARNING: Parameter Index was changed from byref to byval.
		private void Browser_Selected(Object eventSender, EventArgs eventArgs)
		{

			if (!gProps.ModItemBrowser.gbCancel)
			{
				return;
			}
			if (Browser[1].SelectedRowCount == 0)
			{
				//ngty@ 04.940.811 make sure at least one row is selected
				Browser[1].SelectRow(Browser[1].CurrentRow, true);
			}

			ActionBar.ClickButton(BUT_SELECT);

		}

		private void RefreshReplacementBrowser(bool bSelected)
		{
			if (IsEdlBusy())
			{
				return;
			} //mandatory check on the edl threading

			string sRecipeVersion = "";
			string sRecipeJoin = "";
			string sAssortmentJoin = "";
			string[] sWareHsRights = new string[]{"", ""};
			string sIsAssembled = "";

			if (!bSelected && BrowserRepl[1].NumRows == 0)
			{
				return;
			}

			SetupBrowsers(BROWSE_REPLACE);

			//use proper language description
			string sOms30 = "items.Description_" + m_Comp.MultiLang.DefaultIndex.ToString();

			//check if serial batch is in the license
			string sSerialBatch = (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_SERIEBATCH))) ? "Items.IsSerialNumberItem, " : "";

			//ngty@ 07.285.877
			if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_STUKLIJSTEN)) || m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_PAS_RECEPTUUR)))
			{
				//ngty@ 08.787.338
				//sIsAssembled = "(CASE WHEN recipe.ID IS NULL THEN 0 ELSE 1 END) AS [Items.IsAssembled], "
				sIsAssembled = "Items.IsAssembled AS [Items.IsAssembled], ";
			}

			//check for prod order
			//ngty@ 08.789.273
			//BR 12.447.878 gappMode = TYPE_PROD_ALL not link to recipe table anymore
			//If gParentApp = INTERNAL_ORDER And (gAppMode = TYPE_PROD_FILLED Or gAppMode = TYPE_PROD_ALL) Then
			//PBI33204 - Kanban order entry in EGN: Param for Kanban order
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_KANBAN))
			{
				sRecipeVersion = " recipe.version,recipe.MainVersion, ";
				sRecipeJoin = "   LEFT OUTER JOIN recipe ON Items.ItemCode = recipe.itemprod AND recipe.sequenceno = 0 AND recipe.version > 0 ";
			}
			else
			{
				sRecipeVersion = "";
				sRecipeJoin = "";
			}

			//ngty@ 08.789.273
			if (ItemFilter.bUseItemassortment)
			{
				sAssortmentJoin = "   LEFT JOIN ItemAssortment ON Items.Assortment = ItemAssortment.Assortment";
			}
			else
			{
				sAssortmentJoin = "";
			}

			//BR 18.128.324 Add user number 9 -13
			string sUserDefined = "items.UserNumber_01, items.UserNumber_02, items.UserNumber_03, items.UserNumber_04, items.UserNumber_05, items.UserNumber_06, items.UserNumber_07, items.UserNumber_08, items.UserNumber_09, items.UserNumber_10, items.UserNumber_11, items.UserNumber_12, items.UserNumber_13,  " + 
								  "items.UserField_01, items.UserField_02, items.UserField_03, items.UserField_04, items.UserField_05, items.UserField_06, items.UserField_07, items.UserField_08, items.UserField_09,items.UserField_10, " + 
								  "items.UserDate_01, items.UserDate_02, items.UserDate_03, items.UserDate_04,items.UserDate_05,  " + 
								  "items.UserYesNo_01, items.UserYesNo_02, items.UserYesNo_03, items.UserYesNo_04, items.UserYesNo_05";


			//ngty@ 08.709.652,
			//08.965.346, take out the 'cicmpy.cmp_name AS MainSupplier' if ItemFilter.bShowData is false.
			string sSQL = "SELECT artver.priority, Items.ID, Items.ItemCode," + sRecipeVersion + sOms30 + " AS [Items.Description], Items.PackageDescription, Items.Condition, Items.SearchCode, Items.IsSalesItem, Items.IsPurchaseItem, " + sIsAssembled + "Items.IsExplode, Items.IsStockItem, " + sSerialBatch + "(CASE WHEN Items.Picture IS NULL THEN 0 ELSE 1 END) AS HasPicture, Items.SalesPackagePrice AS SalesPrice," + 
						  ((gProps.ModItemBrowser.gbShowPurchaseInfo) ? "   (ItemAccounts.PurchasePrice / (CASE WHEN SlsPkgsPerPurPkg = 0 THEN 1 ELSE SlsPkgsPerPurPkg END)) AS PurchasePrice," : "") + 
						  " ItemAccounts.PurchaseCurrency AS Currency, Items.Warehouse, " + 
						  ((ItemFilter.bShowdata) ? " cicmpy.cmp_name AS MainSupplier, " : "") + sUserDefined + 
						  " FROM Items" + 
						  " INNER JOIN artver ON items.ItemCode = artver.subart";

			//modified by Chan for br 08.205.082
			if (gItemCode.TrimNullAndSpaces() != "")
			{
				sSQL = sSQL + " AND artver.artcode = " + m_Conn.LitString(gItemCode);
			}

			//ngty@ 08.789.273
			sSQL = sSQL + 
				   "   LEFT OUTER JOIN ItemAccounts ON ItemAccounts.ItemCode = Items.ItemCode AND ItemAccounts.crdnr = Items.lev_crdnr AND ItemAccounts.crdnr IS NOT NULL AND Items.lev_crdnr IS NOT NULL" + 
				   ((ItemFilter.bShowdata) ? "   LEFT OUTER JOIN cicmpy ON cicmpy.cmp_wwn = ItemAccounts.AccountCode" : "") + 
				   sRecipeJoin + 
				   sAssortmentJoin;

			//13.472.241, add in this dummy to avoid any codes below cause SQL syntax error. the 'AND'
			sSQL = sSQL + " WHERE (1=1) ";

			if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_MAGAZIJNEN)))
			{
				if (ItemFilter.IsWarehouseAll)
				{
					// 12.517.720 lohp17191 Remove Subquery on Voorrd when user is administrator or has all rights to warehouse so that ALL items are shown,
					// or else just display the items of which the user has rights on the warehouse
					if (!gProps.ModItemBrowser.gbUserHasAllWrhHseRights)
					{
						sSQL = sSQL + " AND items.ItemCode IN (SELECT artcode FROM voorrd WHERE magcode IN " + gProps.ModItemBrowser.gWareHs + ") ";
					}
				}
				else
				{

					sSQL = sSQL + " AND items.ItemCode IN (SELECT artcode FROM voorrd WHERE magcode = " + m_Conn.LitString(gProps.ModItemBrowser.gWareHs) + ") ";
				}

			}

			// lohp17191 12.147.931 Replacement item browser should also show only items with recipe defined
			//is an assembled unit. for internal use & production order only
			if (ItemFilter.GetFilterValue(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_MAKEITEMS))
			{
				sSQL = sSQL + " AND recipe.id IS NOT NULL";

				//ngty@ 06.653.193
				sSQL = sSQL + " AND (recipe.eff_date <= " + m_Conn.LitDate(DateTime.Parse(Exact.SystemLayer.API.vbdate.VBGetSysDate())) + ")";
				sSQL = sSQL + " AND (recipe.exp_date IS NULL OR recipe.exp_date > " + m_Conn.LitDate(DateTime.Parse(Exact.SystemLayer.API.vbdate.VBGetSysDate())) + ") ";
			}

			if (bSelected)
			{
				sSQL = sSQL + " AND artver.artcode = " + m_Conn.LitString(gItemCode);
			}
			else
			{
				sSQL = sSQL + " AND artver.artcode = ''";
			}

			sSQL = sSQL + " ORDER BY artver.priority, Items.Description";

			BrowserRepl[1].StorageKey = "Exact Globe 2000\\[" + Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "]-Replacement-" + gProps.ModItemBrowser.gParentApp + "-" + gProps.ModItemBrowser.gAppMode;
			BrowserRepl[1].SQL = sSQL;
			BrowserRepl[1].Refresh();
		}

		private void GetCicmpyGuid(ref string sDebtorGuid, ref bool bPriceAgreementExist, bool bOrderDebtorOnly = false)
		{
			string sSQL = "";

			bPriceAgreementExist = false;
			Exact.DataLayer.IEdlConnection oCheck = (Exact.DataLayer.IEdlConnection) m_Comp.EDLConnection;

			//11.091.282 lohp17191 added support to look for guid from orderdebtor variable
			Exact.DataLayer.EdlObject vInfo = oCheck.Query("SELECT TOP 1 cmp_wwn FROM cicmpy WHERE debnr = ? ", (bOrderDebtorOnly) ? gProps.ModItemBrowser.gOrderDebtor : gProps.ModItemBrowser.gDebtorOrCreditor, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);
			if (!Exact.SystemLayer.Common.ConvertHelper.IsEmpty(vInfo))
			{
				sDebtorGuid = (string) vInfo;
				sSQL = "SELECT TOP 1 1 FROM Staffl WHERE Staffl.AccountID = ? ";
				//FC 20.841.087 Price lists/agreements per item group
				if (!gProps.ModItemBrowser.gbPricelistPerItemGroup)
				{
					sSQL = sSQL + " AND staffl.LineType = '1' ";
				}
				vInfo = oCheck.Query(sSQL, sDebtorGuid, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);
				if (!Exact.SystemLayer.Common.ConvertHelper.IsEmpty(vInfo))
				{
					bPriceAgreementExist = true;
				}
			}

		}

		//BR 23.650.118 - the codes below moved from RefreshBrowser, for single sorting column usage
		private string GetSingleSortFilterSQL()
		{
			string sFilterWhere = "";

			//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			m_sNavItemBrowserVal = StringsHelper.Replace(Convert.ToString(m_sNavItemBrowserVal), "#¿", "", 1, -1, CompareMethod.Binary); //br30.041.183 chon32144 sorting for price no record show in next page

			if (m_sNavItemBrowserVal == null)
			{
				sFilterWhere = sFilterWhere + " AND (NOT " + m_sNavItemBrowserCol + " IS NULL) ";
			}
			else
			{
				//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				if (m_sNavItemBrowserVal.GetType() == typeof(bool))
				{
					//BR 16.409.543
					if (m_sNavItemBrowserOrderBy.IndexOf("DESC") >= 0)
					{
						//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to bool. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
						sFilterWhere = sFilterWhere + " AND " + m_sNavItemBrowserCol + " < " + ((Convert.ToBoolean(m_sNavItemBrowserVal)) ? 1 : 0).ToString();
					}
					else
					{
						//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to bool. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
						sFilterWhere = sFilterWhere + " AND " + m_sNavItemBrowserCol + " > " + ((Convert.ToBoolean(m_sNavItemBrowserVal)) ? 1 : 0).ToString();
					}

				}
				else if (m_sNavItemBrowserVal.GetType() == typeof(decimal) || m_sNavItemBrowserVal.GetType() == typeof(double) || m_sNavItemBrowserVal.GetType() == typeof(short) || m_sNavItemBrowserVal.GetType() == typeof(int) || m_sNavItemBrowserVal.GetType() == typeof(float) || (IsDouble(ref m_sNavItemBrowserVal) && m_sNavItemBrowserCol == "Items.SalesPackagePrice"))
				{  //BR30.394.504 chon32144 to prevent itemcode treat as integer, added And m_sNavItemBrowserCol = "Items.SalesPackagePrice"

					//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sFilterWhere = sFilterWhere + " AND " + m_sNavItemBrowserCol + ((m_bDescOrder) ? " < " : " > ") + Convert.ToString(m_sNavItemBrowserVal);

				}
				else if (!System.String.IsNullOrWhiteSpace(Convert.ToString(m_sNavItemBrowserVal)))
				{ 
					//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sFilterWhere = sFilterWhere + " AND " + m_sNavItemBrowserCol + ((m_bDescOrder) ? " < " : " > ") + m_Conn.LitString(Convert.ToString(m_sNavItemBrowserVal));
				}
				else if (System.String.IsNullOrWhiteSpace(Convert.ToString(m_sNavItemBrowserVal)) && gBtnClicked == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext)
				{ 
					sFilterWhere = sFilterWhere + " AND " + m_sNavItemBrowserCol + " IS NOT NULL "; //br30.041.183 chon32144
				}
				else if (System.String.IsNullOrWhiteSpace(Convert.ToString(m_sNavItemBrowserVal)) && gBtnClicked == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious && m_oStackItemNav.Size != 0)
				{ 
					sFilterWhere = sFilterWhere + " AND " + m_sNavItemBrowserCol + " IS NOT NULL "; //br30.041.183 chon32144
				}
			}
			//UPGRADE_WARNING: (6021) Casting 'int' to Enum may cause different behaviour. More Information: https://www.mobilize.net/vbtonet/ewis/ewi6021
			gBtnClicked = (GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton) 99; //reset
			return sFilterWhere;
		}
		//br30.041.183 chon32144 sorting for price no record show in next page
		private bool IsDouble(ref object d)
		{
			bool result = false;
			//If d is a number
			if (Information.IsNumeric(d))
			{
				//Convert the number to a double and check if the original and the converted
				//numbers match - if they do then original is a double
				//UPGRADE_WARNING: (1068) d of type Variant is being forced to double. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				if (Conversion.Str(d).Trim() == Conversion.Str(Convert.ToDouble(d)).Trim())
				{
					//UPGRADE_WARNING: (1068) d of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					d = StringsHelper.Replace(Convert.ToString(d), ",", ".", 1, -1, CompareMethod.Binary);
					result = true;
				}
			}
			return result;
		}

		//BR 23.650.118 - in case there's multiple sorting columns, make sure that the filteration constructed correctly
		//              - this browser need to cater manually for condition "Add to sorting order", make sure it behaves the same as system layer logic
		//                   e.g. AND (( colA=x AND colB=y and colC>z ) OR (colA=x AND col>y) OR (colA > x))
		private string GetMultipleSortFilterSQL(string[] arrCol, string[] arrVal, int iEnd)
		{
			string sNavBrowserVal = "";
			string sNavBrowserCol = "";
			bool bLastCol = false;
			bool bFirstCol = false;
			StringBuilder sFilterWhere = new StringBuilder();

			int tempForEndVar = iEnd;
			for (int i = arrCol.GetLowerBound(0); i <= tempForEndVar; i++)
			{
				sNavBrowserVal = arrVal[i];
				sNavBrowserCol = arrCol[i];
				bLastCol = (i == iEnd);
				bFirstCol = (i == arrCol.GetLowerBound(0));

				if (!bFirstCol)
				{
					sFilterWhere.Append(" AND ");
				}
				if (Exact.SystemLayer.Common.ConvertHelper.IsNull(sNavBrowserVal))
				{
					sFilterWhere.Append("  (NOT " + sNavBrowserCol + " IS NULL) ");
				}
				else
				{
					if (sNavBrowserVal.GetType() == typeof(bool))
					{
						//BR 16.409.543
						if (bLastCol)
						{
							if (m_sNavItemBrowserOrderBy.IndexOf("DESC") >= 0)
							{
								bool tempBool = false;
								sFilterWhere.Append(sNavBrowserCol + " < " + ((((Boolean.TryParse(sNavBrowserVal, out tempBool)) ? tempBool : Convert.ToBoolean(Double.Parse(sNavBrowserVal)))) ? 1 : 0).ToString());
							}
							else
							{
								bool tempBool2 = false;
								sFilterWhere.Append(sNavBrowserCol + " > " + ((((Boolean.TryParse(sNavBrowserVal, out tempBool2)) ? tempBool2 : Convert.ToBoolean(Double.Parse(sNavBrowserVal)))) ? 1 : 0).ToString());
							}
						}
						else
						{
							bool tempBool3 = false;
							sFilterWhere.Append(sNavBrowserCol + " = " + ((((Boolean.TryParse(sNavBrowserVal, out tempBool3)) ? tempBool3 : Convert.ToBoolean(Double.Parse(sNavBrowserVal)))) ? 1 : 0).ToString());
						}
					}
					else if (sNavBrowserVal.GetType() == typeof(decimal) || sNavBrowserVal.GetType() == typeof(double) || sNavBrowserVal.GetType() == typeof(short) || sNavBrowserVal.GetType() == typeof(int) || sNavBrowserVal.GetType() == typeof(float))
					{ 
						if (bLastCol)
						{
							sFilterWhere.Append(sNavBrowserCol + ((m_bDescOrder) ? " < " : " > ") + sNavBrowserVal);
						}
						else
						{
							sFilterWhere.Append(sNavBrowserCol + " = " + sNavBrowserVal);
						}
					}
					else if (!System.String.IsNullOrWhiteSpace(sNavBrowserVal))
					{ 
						if (bLastCol)
						{
							sFilterWhere.Append(sNavBrowserCol + ((m_bDescOrder) ? " < " : " > ") + m_Conn.LitString(sNavBrowserVal));
						}
						else
						{
							sFilterWhere.Append(sNavBrowserCol + "=" + m_Conn.LitString(sNavBrowserVal));
						}
					}
				}
			}

			return sFilterWhere.ToString();
		}

		//BR 23.650.118 - to construct where clause for sorting order filteration, cater for single/multiple sorting columns
		private string GetWhereSortSQL()
		{
			StringBuilder sFilterWhere = new StringBuilder();
			int iCount = 0;
			bool bLastCol = false;

			//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			string[] arrVal = (string[]) Convert.ToString(m_sNavItemBrowserVal).Split(new string[]{"#¿¢"}, StringSplitOptions.None); //BR 25.668.309 - When Sorting column containing "," in the data, then will cause RTE, thus change to use "#¿¢" in stead of ","
			string[] arrCol = (string[]) m_sNavItemBrowserCol.Split(',');

			bool bMultipleSort = (arrVal.GetUpperBound(0) > arrVal.GetLowerBound(0));
			if (bMultipleSort)
			{
				sFilterWhere = new StringBuilder(" AND (");
				int tempForEndVar = arrVal.GetUpperBound(0);
				for (int i = arrVal.GetLowerBound(0); i <= tempForEndVar; i++)
				{
					bLastCol = (i == arrVal.GetUpperBound(0));
					sFilterWhere.Append("(" + GetMultipleSortFilterSQL(arrCol, arrVal, arrVal.GetUpperBound(0) - iCount) + ")");

					if (!bLastCol)
					{
						sFilterWhere.Append(" OR ");
					}
					iCount++;
				}
				sFilterWhere.Append(")");
			}
			else
			{
				sFilterWhere = new StringBuilder(GetSingleSortFilterSQL());
			}

			return sFilterWhere.ToString();
		}

		//Browser refreshing
		private void RefreshBrowser()
		{
			string sRecipeVersion = "";
			string sRecipeJoin = "";
			string sAssortmentJoin = "";
			string sByWarehouse = "";
			string sGroupOrder = "";
			string sJoinRule = "";
			string[] sWareHsRights = new string[]{"", ""};
			string sProductRange = "";
			string sOrderSuppl = "";
			string sEancode = "";
			string sIsAssembled = "";
			string sItemRestriction = "";
			string sItemRangeDebtorJoin = ""; // 11.091.282 lohp17191
			string sItemGLJoin = ""; //FC26.191.598 yoon109184 Recurring Sales Order
			string sItemCodeDebtor = ""; // 11.091.282 lohp17191
			string sStockPosition = "";
			//@LowJay br 18.163.941 + 18.775.722 : Barcodes for POS and items are duplicate at Item browser: caused by multiple barcodes
			string sColInfo = "";
			string sColStkInfo = "";
			string sDetItemCode = "";
			string sDetEancode = "";
			string sCompare = "%";

			if (gbRefreshBrowser) return;	// prevent recursive calls
			gbRefreshBrowser = true;

			SetupBrowsers(BROWSE_MAIN);

			// 08.152.157 lohp17191
			if (gProps.ModItemBrowser.gAppMode != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
			{
				gProps.ModItemBrowser.gWareHs = ItemFilter.GetWarehouse(true);
			}

			string sBySupplier = "";

			//FC 16.045.238  Item browser navigation, get maxrows with ties
			//sSQL = "SELECT TOP " & ItemFilter.MaxRows & vbCrLf
			string sSQL = "SELECT TOP " + ItemFilter.MaxRows.ToString() + " WITH TIES " + Environment.NewLine;

			//use proper language description
			string sOms30 = "items.Description_" + m_Comp.MultiLang.DefaultIndex.ToString();

			//BR 15.924.502 add isbatchitem
			//check if serial batch is in the license
			string sSerialBatch = (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_SERIEBATCH))) ? "Items.IsSerialNumberItem,Items.IsBatchItem, " : "";

			//ngty@ 07.285.877
			if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_STUKLIJSTEN)) || m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_PAS_RECEPTUUR)))
			{
				sIsAssembled = "Items.IsAssembled AS [Items.IsAssembled], ";
			}

			// lohp17191 13.588.212
			// If the Search-CustomerItemCode is enabled, then a JOIN should be made to ItemAccounts, and the CustomerItemCode field
			// should be displayed on the browser
			if (ItemFilter.GetFilterValueGlobalSearch(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_CUSTITEMCODE))
			{
				// lohp17191 11.091.282
				//FC26.191.598 yoon109184 Recurring Sales Order
				if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER)
				{
					sItemCodeDebtor = " IADebtor.ItemCodeAccount, ";
					sItemRangeDebtorJoin = " LEFT OUTER JOIN ItemAccounts IADebtor ON Items.Itemcode = IADebtor.Itemcode AND IADebtor.Accountcode = " + m_Conn.LitString((gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.MODE_SALESORDER) ? gProps.ModItemBrowser.gOrderDebtorGuid : gProps.ModItemBrowser.gDebtorOrCreditorGuid);
				}
			}

			//FC26.191.598 yoon109184 Recurring Sales Order
			//LEFT JOIN grtbk ON Items.GLAccountDistribution = grtbk.reknr
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER)
			{
				sItemGLJoin = " LEFT JOIN grtbk ON Items.GLAccountDistribution = grtbk.reknr ";
			}

			//@LowJay br 18.163.941 + 18.775.722 : Barcodes for POS and items are duplicate at Item browser: caused by multiple barcodes
			//                                     for now display only the one with default barcode
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE)
			{
				if (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
				{
					if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_BARCODE)))
					{
						//angs BR 20.413.990 item code with same barcode but with different supplier item code is displayed in item browser.
						//- (Added: SELECT Account field)
						//- (Added: GROUP BY Account field)
						//- (Added: JOIN BY Account "AND b.Account = ItemAccounts.AccountCode")
						//angs BR 18.940.323 barcode only display for item even barcode exist for more than one items.
						//sItemRangeDebtorJoin = sItemRangeDebtorJoin & " LEFT OUTER JOIN (SELECT TOP 1 Itemcode,Barcode FROM Barcodes WHERE Barcodes.IsDefault = 1 "
						sItemRangeDebtorJoin = sItemRangeDebtorJoin + " LEFT OUTER JOIN (SELECT Itemcode, MAX(Barcode) AS Barcode, Account FROM Barcodes WHERE Barcodes.IsDefault = 1 ";
						if (ItemFilter.GetFilterItemsForBarcode(ref sDetItemCode, ref sDetEancode))
						{
							if (sDetItemCode.TrimNullAndSpaces() != "")
							{
								sItemRangeDebtorJoin = sItemRangeDebtorJoin + " AND Barcodes.Itemcode LIKE " + m_Conn.LitString(sCompare + sDetItemCode.Trim() + sCompare);
							}
							if (sDetEancode.TrimNullAndSpaces() != "")
							{
								sItemRangeDebtorJoin = sItemRangeDebtorJoin + " AND Barcodes.Barcode LIKE " + m_Conn.LitString(sCompare + sDetEancode.Trim() + sCompare);
							}
						}
						//angs BR 18.940.323 (GROUP BY) barcode only display for item even barcode exist for more than one items.
						sItemRangeDebtorJoin = sItemRangeDebtorJoin + " GROUP BY Itemcode, Account) AS b ON  b.Itemcode = Items.Itemcode ";
						sItemRangeDebtorJoin = sItemRangeDebtorJoin + " AND b.Account = ItemAccounts.AccountCode";
					}
				}
			}

			//check for prod order
			//ngty@ 08.789.273
			//BR 12.447.878 gappMode = TYPE_PROD_ALL not link to recipe table anymore, therefore do not show recipe version and mainversion
			//If gParentApp = INTERNAL_ORDER And (gAppMode = TYPE_PROD_FILLED Or gAppMode = TYPE_PROD_ALL) Then
			//PBI33204 - Kanban order entry in EGN: Param for Kanban order
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_KANBAN))
			{
				sRecipeVersion = " recipe.version, recipe.MainVersion,";
				sRecipeJoin = " LEFT OUTER JOIN recipe ON Items.ItemCode = recipe.itemprod AND recipe.sequenceno = 0 AND recipe.version > 0 ";
			}
			else if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_SALES_ALL)
			{ 
				sRecipeVersion = "";
				//BR 16.563.821 for internal use, show only the main version
				//sRecipeJoin = " LEFT OUTER JOIN recipe ON Items.ItemCode = recipe.itemprod AND recipe.sequenceno = 0 AND recipe.version > 0 "
				sRecipeJoin = " LEFT OUTER JOIN recipe ON Items.ItemCode = recipe.itemprod AND recipe.sequenceno = 0 AND MainVersion = 1 ";
			}
			else
			{
				sRecipeVersion = "";
				sRecipeJoin = "";
			}

			//ngty@ 08.789.273
			if (ItemFilter.bUseItemassortment)
			{
				sAssortmentJoin = "   LEFT JOIN ItemAssortment ON Items.Assortment = ItemAssortment.Assortment";
			}
			else
			{
				sAssortmentJoin = "";
			}

			// lohp17191 13.588.212
			// If the Search-SupplierItemCode is enabled,the SupplierItemCode field should be displayed on the browser
			if (ItemFilter.GetFilterValueGlobalSearch(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_SUPPLIERITEMCODE))
			{
				//ngty@ 08.485.615
				//BR 19.133.839
				//FC26.191.598 yoon109184 Recurring Sales Order
				if ((gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER) || (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_SALES_ALL || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_SALES_RMA || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_DIRECT_INVOICE)) || (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE) || (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER))
				{
					sOrderSuppl = " ItemAccounts.ItemCodeAccount, ";
				}
				else
				{
					sOrderSuppl = "";
				}
			}
			else
			{
				//BR 16.409.543 if itemcodeaccount is the first sorting column, when the supplier code is uncheck, change the description field as the first column
				if (m_sNavItemBrowserOrderBy == "ItemAccounts.ItemCodeAccount")
				{
					m_sNavItemBrowserOrderBy = sOms30;
				}
			}

			if ((gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE) && gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
			{
				//@LowJay br 18.163.941 + 18.775.722 : Barcodes for POS and items are duplicate at Item browser: caused by multiple barcodes
				//sEancode = " ItemAccounts.EANCode, "
				if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE)
				{
					if (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
					{
						if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_BARCODE)))
						{
							sEancode = "(CASE WHEN ItemAccounts.EANCode IS NULL THEN b.Barcode ELSE ItemAccounts.EANCode END) AS BarCode, ";
							sColInfo = "BarCode,13036,Bar code;";
						}
					}
				}
				else
				{
					sEancode = " ItemAccounts.EANCode, ";
				}
			}
			else
			{
				sEancode = "";
			}

			//BR 18.128.324 Add user number 9 -13
			//setup the user defined fields
			string sUserDefined = "items.UserNumber_01, items.UserNumber_02, items.UserNumber_03, items.UserNumber_04, items.UserNumber_05, items.UserNumber_06, items.UserNumber_07, items.UserNumber_08, items.UserNumber_09, items.UserNumber_10, items.UserNumber_11, items.UserNumber_12, items.UserNumber_13, " + 
								  "items.UserField_01, items.UserField_02, items.UserField_03, items.UserField_04, items.UserField_05, items.UserField_06, items.UserField_07, items.UserField_08, items.UserField_09,items.UserField_10, " + 
								  "items.UserDate_01, items.UserDate_02, items.UserDate_03, items.UserDate_04,items.UserDate_05,  " + 
								  "items.UserYesNo_01, items.UserYesNo_02, items.UserYesNo_03, items.UserYesNo_04, items.UserYesNo_05";

			//Fc: 24.877.475 stock position columns
			if (ItemFilter.bShowStockPos)
			{ //CBR79.675.937 - stock position solution to used *1 as Key Tag
				sStockPosition = ", CONVERT(float, 0*1) AS PhysicalStock, CONVERT(float, 0) AS FreeStock";
				//Column name,Header TermID,Header,Width,Scale,Options,Invisible,Checkmark,Order By,Term ID column;
				sColStkInfo = "PhysicalStock,8859,Stock,12,3,2;FreeStock,1041,Free Stock,12,3,2;";
			}


			//ngty@ 08.135.267: Get the whereclause first
			//sWareHsRights(0) = " items.ItemCode IN (SELECT artcode FROM voorrd WHERE magcode IN " & m_Conn.LitString(gWareHs) & ") "
			if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_MAGAZIJNEN)))
			{
				if (ItemFilter.IsWarehouseAll)
				{
					// 12.517.720 lohp17191 Remove Subquery on Voorrd when user is administrator or has all rights to warehouse so that ALL items are shown,
					// or else just display the items of which the user has rights on the warehouse
					if (!gProps.ModItemBrowser.gbUserHasAllWrhHseRights)
					{
						sByWarehouse = " items.ItemCode IN (SELECT artcode FROM voorrd WHERE magcode IN " + gProps.ModItemBrowser.gWareHs + ") ";
					}
				}
				else
				{
					sByWarehouse = " items.ItemCode IN (SELECT artcode FROM voorrd WHERE magcode = " + m_Conn.LitString(gProps.ModItemBrowser.gWareHs) + ") ";
				}
			}

			string sFilterWhere = ItemFilter.GetWhere((((sByWarehouse) is null) ? 0 : sByWarehouse.Length) != 0);

			//ngty@ 07.634.446 - added checking for TYPE_POS_INVOICE to join on main supplier
			switch(gProps.ModItemBrowser.gParentApp)
			{
				//FC26.191.598 yoon109184 Recurring Sales Order
				case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER : 
					// lohp17191 13.588.212 Only when Search-SupplierItemCode is enabled, then apply the following clauses for ItemAccounts 
					if (ItemFilter.GetFilterValueGlobalSearch(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_SUPPLIERITEMCODE))
					{
						//ngty@ 08.135.267
						if (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
						{
							sItemRestriction = (gProps.ModItemBrowser.gbBrowseMultiEAN) ? "" : " AND ItemAccounts.crdnr = Items.lev_crdnr";
						}
						else
						{
							sItemRestriction = " AND ItemAccounts.crdnr = Items.lev_crdnr";
						}
						//angs BR 20.413.990 Item Browser lists more than once for some items - Added: (gAppMode = TYPE_POS_INVOICE)
					}
					else
					{
						if (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
						{
							sItemRestriction = " AND ItemAccounts.crdnr = Items.lev_crdnr";
						}
					} 
					 
					//ngty@ 08.789.273 
					//BR 16.947.557 remove stock columns in compact 
					sSQL = sSQL + 
						   " Items.ID, " + sOms30 + " AS [Items.Description], Items.ItemCode," + 
						   sItemCodeDebtor + 
						   sRecipeVersion + 
						   " Items.SearchCode, Items.PackageDescription," + 
						   sOrderSuppl + 
						   sEancode + 
						   " Items.Condition, Items.IsSalesItem, Items.IsPurchaseItem, " + 
						   sIsAssembled + 
						   " Items.IsExplode, " + 
						   ((!m_Comp.GetOpt(OPT_COMPACT)) ? "Items.IsStockItem, " : "") + 
						   sSerialBatch + 
						   " (CASE WHEN Items.Picture IS NULL THEN 0 ELSE 1 END) AS HasPicture, Items.SalesPackagePrice AS SalesPrice,"; 
					 
					// lohp17191 13.588.212 When either ViewCostPurch rights exists, and Search-SupplierItemCode is enabled, show the purchase price 
					// information from ItemAccounts 
					if (gProps.ModItemBrowser.gbShowPurchaseInfo && ItemFilter.GetFilterValueGlobalSearch(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_SUPPLIERITEMCODE))
					{
						sSQL = sSQL + 
							   " (ItemAccounts.PurchasePrice / (CASE WHEN ItemAccounts.SlsPkgsPerPurPkg = 0 THEN 1 ELSE ItemAccounts.SlsPkgsPerPurPkg END)) AS PurchasePrice,ItemAccounts.PurchaseCurrency AS Currency, ";
					} 
					 
					//BR 16.947.508 remove user defined columns in compact 
					//            sSQL = sSQL & _
					//'                " Items.Warehouse, " & _
					//'                IIf(ItemFilter.bShowdata, " ,cicmpy.cmp_name AS MainSupplier, ", "") & sUserDefined & _
					//'                " FROM Items" 
					sSQL = sSQL + 
						   " Items.Warehouse " + 
						   ((ItemFilter.bShowdata) ? " ,cicmpy.cmp_name AS MainSupplier " : "") + ((!m_Comp.GetOpt(OPT_COMPACT)) ? "," + sUserDefined : "") + 
						   sStockPosition + 
						   " FROM Items"; 
					 
					// lohp17191 13.588.212 When Search-SupplierItemcode is enabled, or we are in POS_INVOICE mode(mandatory JOIN to retrieve the barcode), 
					// make a JOIN to the ItemAccounts table, and cicmpy if necessary 
					//BR 16.300.334 Felix: production browse: = gParentApp = INTERNAL_ORDER And (gAppMode = TYPE_PROD_FILLED Or gAppMode = TYPE_PROD_ALL) 
					// don't link to ItemAccounts table if supplier's item code checked box not check, else will create multiple item code 
					//PBI33204 - Kanban order entry in EGN: Param for Kanban order 
					if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_ALL || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_KANBAN))
					{
						if (ItemFilter.GetFilterValueGlobalSearch(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_SUPPLIERITEMCODE))
						{
							sSQL = sSQL + 
								   "   LEFT OUTER JOIN ItemAccounts ON ItemAccounts.ItemCode = Items.ItemCode" + sItemRestriction + 
								   ((ItemFilter.bShowdata) ? "   LEFT OUTER JOIN cicmpy ON cicmpy.cmp_wwn = ItemAccounts.AccountCode" : "");
						}
					}
					else if (ItemFilter.GetFilterValueGlobalSearch(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_SUPPLIERITEMCODE) || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_ALL || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_KANBAN))
					{ 
						sSQL = sSQL + 
							   "   LEFT OUTER JOIN ItemAccounts ON ItemAccounts.ItemCode = Items.ItemCode" + sItemRestriction + 
							   ((ItemFilter.bShowdata) ? "   LEFT OUTER JOIN cicmpy ON cicmpy.cmp_wwn = ItemAccounts.AccountCode" : "");
					} 
					 
					//FC26.191.598 yoon109184 recurring sales order 
					sSQL = sSQL + 
						   sRecipeJoin + 
						   sAssortmentJoin + 
						   sItemRangeDebtorJoin + 
						   sItemGLJoin; 
					 
					//BR 13.581.868 
				//	if (Exact.SystemLayer.API.misc.VBGetOpt(OPT_COMPACT))
						if (m_Comp.GetOpt(OPT_COMPACT))
					{
						if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE)
						{
							sFilterWhere = sFilterWhere + " AND items.type NOT IN ('L') ";
						}
					} 
					 
					//FC 16.045.238 Item browser navigation 
					if (!System.String.IsNullOrWhiteSpace(m_sNavItemBrowserOrderBy))
					{
						//CBR79.675.937 - stock position
						switch(m_sNavItemBrowserOrderBy)
						{
							case "CONVERT(float, 0*1)" : 
								sGroupOrder = " ORDER BY PhysicalStock"; 
								break;
							case "CONVERT(float, 0)" : 
								sGroupOrder = " ORDER BY FreeStock"; 
								break;
							default:
								m_sNavItemBrowserOrderBy = StringsHelper.Replace(m_sNavItemBrowserOrderBy, "CONVERT(float, 0*1)", "PhysicalStock", 1, -1, CompareMethod.Binary); 
								m_sNavItemBrowserOrderBy = StringsHelper.Replace(m_sNavItemBrowserOrderBy, "CONVERT(float, 0)", "FreeStock", 1, -1, CompareMethod.Binary); 
								 
								sGroupOrder = " ORDER BY " + m_sNavItemBrowserOrderBy; 
								break;
						}

					}
					else
					{
						sGroupOrder = " ORDER BY Items.ItemCode";// + sOms30; // Performance fix: Do not order by description (it can be empty or duplicated)
					} 
					 
					//ngty@ 08.197.791 all this hassle!! 
					//FC26.191.598 yoon109184 Recurring Sales Order 
					if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER)
					{
						if (m_bItemRange && gProps.ModItemBrowser.gPriceAgreementExists && ActionBar.get_Button(BUT_ALLITEMS).Enabled)
						{
							//FC 20.841.087 Price lists/agreement per group
							sProductRange = " AND items.ItemCode IN (SELECT Staffl.artcode FROM Staffl WHERE Staffl.AccountID = " + m_Conn.LitString(gProps.ModItemBrowser.gDebtorOrCreditorGuid) + " AND staffl.LineType ='1')";
						}

						if (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_SALES_CONTRACTS)
						{
							//See document 04.993.209
							//sFilterWhere = sFilterWhere & " AND (Items.Type = 'S' AND Items.IsSalesItem = 1 AND Items.IsSerialNumberItem = 1 AND Items.IsStockItem = 0 AND Items.PackageDescription IN (SELECT Unit FROM ItemUnits WHERE UnitType = 'T'))"
							//tanc30792 [BR 11.419.568] [2004 Jul 1]
							//Removed Items.IsStockItem = 0, add Items.GLAccountDistribution = P&L Account
							sFilterWhere = sFilterWhere + " AND (Items.Type = 'S' AND Items.IsSalesItem = 1 AND Items.IsSerialNumberItem = 1";
							sFilterWhere = sFilterWhere + " AND Items.PackageDescription IN (SELECT Unit FROM ItemUnits WHERE UnitType = 'T')";
							sFilterWhere = sFilterWhere + " AND Items.GLAccountDistribution IN (SELECT reknr FROM grtbk WHERE bal_vw = 'W'))";
						}
					} 
					 
					//FC 16.045.238 Item browser navigation 
					// 1 - if item is null, use NULL clause 
					// 2 - if item is bool, convert to integer 
					// 3 - if item is string, just concatenate 
					//BR 23.650.118 - commented below codes which is cater for single sorting criteria only 
					//              - moved the codes below to GetSingleSortFilterSQL() 
					//              - call GetWhereSortSQL() instead 
					sFilterWhere = sFilterWhere + GetWhereSortSQL(); 
					//            If IsNull(m_sNavItemBrowserVal) Then 
					//                sFilterWhere = sFilterWhere & " AND (NOT " & m_sNavItemBrowserCol & " IS NULL) " 
					//            Else 
					//                If VarType(m_sNavItemBrowserVal) = vbBoolean Then 
					// 
					//                    'BR 16.409.543 
					//                    If InStr(m_sNavItemBrowserOrderBy, "DESC") Then 
					//                        sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & " < " & IIf(m_sNavItemBrowserVal, 1, 0) 
					//                    Else 
					//                        sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & " > " & IIf(m_sNavItemBrowserVal, 1, 0) 
					//                    End If 
					// 
					//                ElseIf VarType(m_sNavItemBrowserVal) = vbDecimal Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbDouble Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbInteger Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbLong Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbSingle Then 
					//                    sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & IIf(m_bDescOrder, " < ", " > ") & m_sNavItemBrowserVal 
					//                ElseIf m_sNavItemBrowserVal <> "" Then 
					//                    sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & IIf(m_bDescOrder, " < ", " > ") & m_Conn.LitString(m_sNavItemBrowserVal) 
					//                End If 
					//            End If 
					break;
				case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER : 
					if (ActionBar.get_Button(BUT_ALLITEMS).Enabled)
					{
						sBySupplier = "ItemAccounts.crdnr = " + m_Conn.LitString(gProps.ModItemBrowser.gDebtorOrCreditor) + " AND ";
						sJoinRule = "";
						//>>FC : 11.034.764 -PO ENTRY: Approved suppliers.
						//If an item requires approved supplier, then the supplier must also be the approved supplier.
						//else show all items that have links to supplier.
						if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER)
						{
							if ((((sFilterWhere) is null) ? 0 : sFilterWhere.Length) > 0)
							{
								sFilterWhere = sFilterWhere + Environment.NewLine + " AND ";
							}
							sFilterWhere = sFilterWhere + " (items.RequiresApprovedSupplier = 0 OR items.RequiresApprovedSupplier IS NULL " + Environment.NewLine;
							sFilterWhere = sFilterWhere + " OR (items.RequiresApprovedSupplier = 1 AND ItemAccounts.SupplierPreference = 1)) ";
						}
					}
					else
					{
						sBySupplier = "";
						sJoinRule = " AND ItemAccounts.crdnr = Items.lev_crdnr";
					} 
					 
					//BR 16.947.508 remove user defined columns in compact 
					//BR 16.947.557 remove stock columns in compact 
					//            sSQL = sSQL & _
					//'                   "   Items.ID, " & sOms30 & " AS [Items.Description], Items.ItemCode, Items.SearchCode, ItemAccounts.PurchasePackage, ItemAccounts.ItemCodeAccount, Items.Condition, Items.IsSalesItem, Items.IsPurchaseItem, " & sIsAssembled & "Items.IsStockItem, " & sSerialBatch & "(CASE WHEN Items.Picture IS NULL THEN 0 ELSE 1 END) AS HasPicture, Items.SalesPackagePrice AS SalesPrice, ItemAccounts.PurchasePrice AS PurchasePrice, ItemAccounts.PurchaseCurrency AS Currency, Items.Warehouse, " & _
					//'                   IIf(ItemFilter.bShowdata, " cicmpy.cmp_name AS MainSupplier, ", "") & sUserDefined & _
					//'                   " FROM Items" & _
					//'                   " LEFT OUTER JOIN ItemAccounts ON ItemAccounts.ItemCode = Items.ItemCode" & sJoinRule & _
					//'                   IIf(ItemFilter.bShowdata, " LEFT OUTER JOIN cicmpy ON cicmpy.cmp_wwn = ItemAccounts.AccountCode", "") & _
					//'                   sAssortmentJoin 
					sSQL = sSQL + 
						   "   Items.ID, " + sOms30 + " AS [Items.Description], Items.ItemCode, Items.SearchCode, ItemAccounts.PurchasePackage, ItemAccounts.ItemCodeAccount, Items.Condition, Items.IsSalesItem, Items.IsPurchaseItem, " + sIsAssembled + ((!m_Comp.GetOpt(OPT_COMPACT)) ? "Items.IsStockItem, " : "") + sSerialBatch + "(CASE WHEN Items.Picture IS NULL THEN 0 ELSE 1 END) AS HasPicture, Items.SalesPackagePrice AS SalesPrice, ItemAccounts.PurchasePrice AS PurchasePrice, ItemAccounts.PurchaseCurrency AS Currency, Items.Warehouse " + 
						   ((ItemFilter.bShowdata) ? " ,cicmpy.cmp_name AS MainSupplier " : "") + ((!m_Comp.GetOpt(OPT_COMPACT)) ? "," + sUserDefined : "") + 
						   " FROM Items" + 
						   " LEFT OUTER JOIN ItemAccounts ON ItemAccounts.ItemCode = Items.ItemCode" + sJoinRule + 
						   ((ItemFilter.bShowdata) ? " LEFT OUTER JOIN cicmpy ON cicmpy.cmp_wwn = ItemAccounts.AccountCode" : "") + 
						   sAssortmentJoin; 
					 
					//FC 16.045.238 Item browser navigation 
					if (!System.String.IsNullOrWhiteSpace(m_sNavItemBrowserOrderBy))
					{
						sGroupOrder = " ORDER BY " + m_sNavItemBrowserOrderBy;
					}
					else
					{
						sGroupOrder = " ORDER BY " + sOms30; //" ORDER BY Items.Description"
					} 
					 
					//FC 16.045.238 Item browser navigation 
					// 1 - if item is null, use NULL clause 
					// 2 - if item is bool, convert to integer 
					// 3 - if item is string, just concatenate 
					 
					//BR 23.650.118 - commented below codes which is cater for single sorting criteria only 
					//              - moved the codes below to GetSingleSortFilterSQL() 
					//              - call GetWhereSortSQL() instead 
					sFilterWhere = sFilterWhere + GetWhereSortSQL(); 
					//            If IsNull(m_sNavItemBrowserVal) Then 
					//                sFilterWhere = sFilterWhere & " AND (NOT " & m_sNavItemBrowserCol & " IS NULL) " 
					//            Else 
					//                If VarType(m_sNavItemBrowserVal) = vbBoolean Then 
					// 
					//                    'BR 16.409.543 
					//                    If InStr(m_sNavItemBrowserOrderBy, "DESC") Then 
					//                        sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & " < " & IIf(m_sNavItemBrowserVal, 1, 0) 
					//                    Else 
					//                        sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & " > " & IIf(m_sNavItemBrowserVal, 1, 0) 
					//                    End If 
					// 
					//                ElseIf VarType(m_sNavItemBrowserVal) = vbDecimal Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbDouble Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbInteger Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbLong Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbSingle Then 
					//                    sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & IIf(m_bDescOrder, " < ", " > ") & m_sNavItemBrowserVal 
					//                ElseIf m_sNavItemBrowserVal <> "" Then 
					//                    sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & IIf(m_bDescOrder, " < ", " > ") & m_Conn.LitString(m_sNavItemBrowserVal) 
					//                End If 
					//            End If 

					 
					break;
				case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.RECEIPT : 
					sSQL = sSQL + 
						   "   Items.ID, " + sOms30 + " AS [Items.Description], Items.ItemCode, Items.PackageDescription, Items.Condition, Items.IsSalesItem, Items.IsPurchaseItem, " + sIsAssembled + "Items.IsStockItem, " + sSerialBatch + "(CASE WHEN Items.Picture IS NULL THEN 0 ELSE 1 END) AS HasPicture, " + sUserDefined + 
						   "   FROM Items"; 

					 
					//FC 16.045.238 Item browser navigation 
					if (!System.String.IsNullOrWhiteSpace(m_sNavItemBrowserOrderBy))
					{
						sGroupOrder = " ORDER BY " + m_sNavItemBrowserOrderBy;
					}
					else
					{
						sGroupOrder = " ORDER BY " + sOms30; //" ORDER BY Items.Description"
					} 
					 
					//FC 16.045.238 Item browser navigation 
					// 1 - if item is null, use NULL clause 
					// 2 - if item is bool, convert to integer 
					// 3 - if item is string, just concatenate 
					 
					//BR 23.650.118 - commented below codes which is cater for single sorting criteria only 
					//              - moved the codes below to GetSingleSortFilterSQL() 
					//              - call GetWhereSortSQL() instead 
					sFilterWhere = sFilterWhere + GetWhereSortSQL(); 
					//            If IsNull(m_sNavItemBrowserVal) Then 
					//                sFilterWhere = sFilterWhere & " AND (NOT " & m_sNavItemBrowserCol & " IS NULL) " 
					//            Else 
					//                If VarType(m_sNavItemBrowserVal) = vbBoolean Then 
					// 
					//                    'BR 16.409.543 
					//                    If InStr(m_sNavItemBrowserOrderBy, "DESC") Then 
					//                        sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & " < " & IIf(m_sNavItemBrowserVal, 1, 0) 
					//                    Else 
					//                        sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & " > " & IIf(m_sNavItemBrowserVal, 1, 0) 
					//                    End If 
					// 
					//                ElseIf VarType(m_sNavItemBrowserVal) = vbDecimal Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbDouble Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbInteger Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbLong Or _
					//'                        VarType(m_sNavItemBrowserVal) = vbSingle Then 
					//                    sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & IIf(m_bDescOrder, " < ", " > ") & m_sNavItemBrowserVal 
					//                ElseIf m_sNavItemBrowserVal <> "" Then 
					//                    sFilterWhere = sFilterWhere & " AND " & m_sNavItemBrowserCol & IIf(m_bDescOrder, " < ", " > ") & m_Conn.LitString(m_sNavItemBrowserVal) 
					//                End If 
					//            End If 
					break;
			}

			//'Putting it all together
			sSQL = sSQL + " WHERE " + sBySupplier + sByWarehouse + sFilterWhere + sProductRange + sGroupOrder;

			Browser[1].StorageKey = "Exact Globe 2003\\[" + Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "]-" + gProps.ModItemBrowser.gParentApp + "-" + gProps.ModItemBrowser.gAppMode;
			Browser[1].ColInfo = Browser[1].ColInfo + sColStkInfo;
			//@LowJay br 18.163.941 : Barcodes created by SE4030 not recognized in E-Pos
			if (~((System.String.IsNullOrWhiteSpace(sColInfo)) ? -1 : 0) != 0)
			{
				//angs BR 22.023.714 incomplete change for BR 18.163.941: If e-barcode used, column width is too large can happened
				//-- existing code : .ColInfo = sColInfo
				//-- New code: .ColInfo = .ColInfo & sColInfo [added: sColInfo]
				Browser[1].ColInfo = Browser[1].ColInfo + sColInfo;
			}
			//.SelectColumnsMode = 0
			Browser[1].SQL = sSQL;
			gProps.ModItemBrowser.gbRefreshBrowserCall = true; //BR 16.263.480 to determine whether column_change fired from RefreshBrowser()
			Browser[1].Refresh();
			gProps.ModItemBrowser.gbRefreshBrowserCall = false; //BR 16.263.480

			//Fc:24.877.475 - load stock qty
			LoadStockQty();


			gbRefreshBrowser = false;
		}

		//Fc:24.877.475 - load the stock qty into edl browser.
		//max 50 item per query trip
		private void LoadStockQty()
		{
			if (gProps.ModItemBrowser.gbRefreshBrowserCall)
			{
				return;
			}
			if (Browser[1].NumRows == 0)
			{
				return;
			}
			if (!ItemFilter.bShowStockPos)
			{
				return;
			}

			//logic:
			//retrieve stock pos for 50 item in a batch
			int iCount = 0;
			string sItemCode = "";
			Exact.DataLayer.EdlObject vPhysicalQty = null, vFreeQty = null;
			double dPhysicalQty = 0, dFreeQty = 0;
			string sQtyItem = "";


			OrderedDictionary dicPhysicalQty = new OrderedDictionary(System.StringComparer.CurrentCultureIgnoreCase);
			OrderedDictionary dicFreeStock = new OrderedDictionary(System.StringComparer.CurrentCultureIgnoreCase);

			//init the stock query dll
			InitStockObj();

			iCount = 0;
			int tempForEndVar = Browser[1].NumRows;
			for (int iReadRow = 1; iReadRow <= tempForEndVar; iReadRow++)
			{
				iCount++; //to counter the 50 item
				if (iCount <= 50)
				{
					//UPGRADE_WARNING: (1068) Browser().RowValue() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					sItemCode = sItemCode + "," + m_Conn.LitString(Convert.ToString(Browser[1].get_RowValue(iReadRow, "Items.ItemCode")));
				}

				if (iCount == 50 || iReadRow == Browser[1].NumRows)
				{
					//calculate the qty
					sItemCode = sItemCode.Substring(1);
					//UPGRADE_WARNING: (1068) GetPhysicalStock() of type Variant is being forced to Scalar. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					vPhysicalQty = new Exact.DataLayer.EdlObject (GetPhysicalStock(sItemCode, gProps.ModItemBrowser.gsWarehouse, true)); //get stock qty
					//UPGRADE_WARNING: (1068) GetFreeStock() of type Variant is being forced to Scalar. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					vFreeQty = new Exact.DataLayer.EdlObject (GetFreeStock(sItemCode, gProps.ModItemBrowser.gsWarehouse, true)); //get free stock

					//add to dic
					if (!Exact.SystemLayer.Common.ConvertHelper.IsEmpty(vPhysicalQty))
					{
						int tempForEndVar2 = vPhysicalQty.GetUpperBound(0);
						for (int iNum = vPhysicalQty.GetLowerBound(0); iNum <= tempForEndVar2; iNum++)
						{
							//UPGRADE_WARNING: (1068) vPhysicalQty() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							sQtyItem = Convert.ToString(vPhysicalQty[iNum, 0].Data);
							//UPGRADE_WARNING: (1068) vPhysicalQty() of type Variant is being forced to double. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							dPhysicalQty = Convert.ToDouble(vPhysicalQty[iNum, 2].Data);
							if (dicPhysicalQty.Contains(sQtyItem))
							{
								//UPGRADE_WARNING: (1068) dicPhysicalQty.Item() of type Variant is being forced to double. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
								dPhysicalQty += Convert.ToDouble(dicPhysicalQty[sQtyItem]);
								dicPhysicalQty.Remove(sQtyItem);
							}

							dicPhysicalQty.Add(sQtyItem, dPhysicalQty);
						}
					}

					//add free qty into dic
					if (!Exact.SystemLayer.Common.ConvertHelper.IsEmpty(vFreeQty))
					{
						int tempForEndVar3 = vFreeQty.GetUpperBound(0);
						for (int iNum = vFreeQty.GetLowerBound(0); iNum <= tempForEndVar3; iNum++)
						{
							//UPGRADE_WARNING: (1068) vFreeQty() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							sQtyItem = Convert.ToString(vFreeQty[iNum, 0].Data);
							//UPGRADE_WARNING: (1068) vFreeQty() of type Variant is being forced to double. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							dFreeQty = Convert.ToDouble(vFreeQty[iNum, 1].Data);
							if (dicFreeStock.Contains(sQtyItem))
							{
								//UPGRADE_WARNING: (1068) dicFreeStock.Item() of type Variant is being forced to double. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
								dFreeQty += Convert.ToDouble(dicFreeStock[sQtyItem]);
								dicFreeStock.Remove(sQtyItem);
							}
							dicFreeStock.Add(sQtyItem, dFreeQty);
						}
					}

					sItemCode = "";
					iCount = 0;
				}
			}
			
			Exact.DataLayer.IEdlQuery qu = (Exact.DataLayer.IEdlQuery) Browser[1].QueryObject;
			Exact.DataLayer.IEdlColumn colPhysicalStock = (Exact.DataLayer.IEdlColumn) qu.Column("PhysicalStock");
			Exact.DataLayer.IEdlColumn colFreeStock = (Exact.DataLayer.IEdlColumn) qu.Column("FreeStock");

			//load qty to grid
			int tempForEndVar4 = Browser[1].NumRows;
			for (int iReadRow = 1; iReadRow <= tempForEndVar4; iReadRow++)
			{
				//UPGRADE_WARNING: (1068) Browser().RowValue() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				sItemCode = Convert.ToString(Browser[1].get_RowValue(iReadRow, "Items.ItemCode"));
				if (dicPhysicalQty.Contains(sItemCode))
				{
					//UPGRADE_WARNING: (1068) dicPhysicalQty.Item() of type Variant is being forced to double. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					colPhysicalStock.Dbl = Convert.ToDouble(dicPhysicalQty[sItemCode]);
				}
				if (dicFreeStock.Contains(sItemCode))
				{
					//UPGRADE_WARNING: (1068) dicFreeStock.Item() of type Variant is being forced to double. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					colFreeStock.Dbl = Convert.ToDouble(dicFreeStock[sItemCode]);
				}
				Browser[1].RefreshRow(iReadRow);
			}

		}
		//Fc:24.877.475 - load the stock qty into edl browser.
		private object GetPhysicalStock(string sItemCode, string sWhr, bool bInputItemInList)
		{

			string sItemTo = "";
			object vQty = null;
			if (!bInputItemInList)
			{
				sItemTo = sItemCode;
			} // not query item qty in list, so, set the sItemTo = sItemCode

			mObjStkQty.ReturnResultsAsArray = true;
			mObjStkQty.ReturnWarehouse = (true).ToString();
			mObjStkQty.InputItemInList = bInputItemInList.ToString();
			vQty = mObjStkQty.StockQtyPerReferenceDate(sItemCode, sItemTo, sWhr, sWhr, m_Comp.ProcessDate);
			return vQty;
		}
		//Fc:24.877.475 - load the stock qty into edl browser.
		private object GetFreeStock(string sItemCode, string sWhr, bool bInputItemInList)
		{

			string sItemTo = "";
			object vQty = null;
			if (!bInputItemInList)
			{
				sItemTo = sItemCode;
			} // not query item qty in list, so, set the sItemTo = sItemCode

			mObjStkQty.ReturnResultsAsArray = true;
			mObjStkQty.ReturnWarehouse = (true).ToString();
			mObjStkQty.InputItemInList = bInputItemInList.ToString();
			vQty = mObjStkQty.FreeStockTotalQty(sItemCode, sItemTo, sWhr, sWhr);
			return vQty;
		}
		//Fc:24.877.475 - load the stock qty into edl browser.
		private void InitStockObj()
		{
			if (mObjStkQty is null)
			{
				mObjStkQty = GlobalInterfaces.Factory.CreateInstance<GlobalInterfaces.GI_Exact.Inventory.StockQuantities.IclsStockQuantities>();
				m_App.ConnectObject(mObjStkQty, m_Comp, m_Term);
			}
		}

		//Refresh form, based on current selection criteria
		private void DoRefresh()
		{
			Cursor iMousePtr = this.Cursor;
			this.Cursor = Cursors.WaitCursor;
			try
			{
				if (ItemFilter.MaxRows == 0 || ItemFilter.MaxRows > 500)
				{
					return;
				}

				gItemCode = "";

				RefreshBrowser();

				//BR 16.297.817 set tab index for browser(1) = browser(0) here else everytime when refreshbrowser, the tabindex will be changed
				Browser[1].TabIndex = 3;
				BrowserRepl[1].TabIndex = 4;
			}
			catch (Exception catchedException)
			{
				Exact.Exceptions.Globe.BaseGlobeException exc = Exact.Exceptions.Utils.ExceptionBuilder.Build(catchedException);
				m_App.Message(this.Handle, "Error " + ": " + exc.Message);
			}

			this.Cursor = iMousePtr;

		}

		//UPGRADE-WARNING: Parameter Index was changed from byref to byval.
		private void BrowserRepl_SelectionChanged(Object eventSender, EventArgs eventArgs)
		{
			int SelectedRow = 0;

			if (gProps.ModItemBrowser.gbMultiSelect)
			{
				SelectedRow = BrowserRepl[1].get_SelectedRows(0);
			}
			else
			{
				SelectedRow = BrowserRepl[1].CurrentRow;
			}
			//FC 17.845.818
			if (SelectedRow < 1)
			{
				ActionBar.EnableButton(BUT_MRP, false);
				ActionBar.EnableButton(BUT_SELECT, false);
				ActionBar.EnableButton(BUT_CARD, false);
				ActionBar.EnableButton(BUT_COPY, false);
				fbCommand[1].Enabled = false;
			}
			else
			{
				//angs BR 20.756.775 Hide <add>, <Edit> and copy buttons with E-Branche
				if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_POS_BRANCHE_OFFICE)))
				{
					fbCommand[1].Enabled = true;
				}
			}

			if (gbBrowserReplSelType)
			{ //ngty@ 05.451.186
				gbBrowserReplSelType = false;
				return;
			}

			gbBusy = true;

			if (this.Visible)
			{
				ActionBar.get_Button(BUT_DUMMY).Focus = true;
			}

			BrowserRepl[1].Enabled = false;

			//UPGRADE_WARNING: (1068) BrowserRepl().RowValue() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			gItemCode = Convert.ToString(BrowserRepl[1].get_RowValue(SelectedRow, "items.ItemCode"));

			if ((BrowserRepl[1].MultiSelect && BrowserRepl[1].SelectedRowCount != 1) || (!BrowserRepl[1].MultiSelect && BrowserRepl[1].CurrentRow == 0))
			{
				DoButtons(false);
				ClearAllValues();
			}
			else
			{
				DoButtons(true);
				FillItemInfo();
			}

			BrowserRepl[1].Enabled = true;
			if (this.Visible && BrowserRepl[1].Visible)
			{
				BrowserRepl[1].Focus();
			}

			gbBusy = false;
		}

		//UPGRADE-WARNING: Parameter Index was changed from byref to byval.
		private void BrowserRepl_RowChanged(Object eventSender, EventArgs eventArgs)
		{

			gbBusy = true;

			if (this.Visible)
			{
				ActionBar.get_Button(BUT_DUMMY).Focus = true;
			}

			BrowserRepl[1].Enabled = false;

			int SelectedRow = BrowserRepl[1].CurrentRow;
			//UPGRADE_WARNING: (1068) BrowserRepl().RowValue() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			gItemCode = Convert.ToString(BrowserRepl[1].get_RowValue(SelectedRow, "items.ItemCode"));

			FillItemInfo();

			if ((BrowserRepl[1].MultiSelect && BrowserRepl[1].SelectedRowCount != 1) || (!BrowserRepl[1].MultiSelect && BrowserRepl[1].CurrentRow == 0))
			{
				DoButtons(false);
				ClearAllValues();
			}
			else
			{
				DoButtons(true);
			}

			BrowserRepl[1].Enabled = true;
			if (this.Visible && BrowserRepl[1].Visible)
			{
				BrowserRepl[1].Focus();
			}

			gbBusy = false;
			gbBrowserReplSelType = true; //ngty@ 05.451.186
		}

		//UPGRADE-WARNING: Parameter Index was changed from byref to byval.
		private void BrowserRepl_Selected(Object eventSender, EventArgs eventArgs)
		{

			if (!gProps.ModItemBrowser.gbCancel)
			{
				return;
			}
			if (BrowserRepl[1].SelectedRowCount == 0)
			{
				//ngty@ 04.940.811 make sure at least one row is selected
				BrowserRepl[1].SelectRow(BrowserRepl[1].CurrentRow, true);
			}

			ActionBar.ClickButton(BUT_SELECT);
		}

		private void cmdSerialBatch_Click(Object eventSender, EventArgs eventArgs)
		{
			using (ClsSerialBatch dlgSB = new ClsSerialBatch(gProps))
			{
				//UPGRADE_TODO: (1069) Error handling statement (On Error Resume Next) was converted to a pattern that might have a different behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1069
				try
				{
					if (!pnlReplaceBrowser.Visible)
					{
						//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
						dlgSB.sItemCode = Convert.ToString(Browser[1].get_value("Items.Itemcode"));
						//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
						dlgSB.sItemdesc = Convert.ToString(Browser[1].get_value("Items.Description"));
					}
					else
					{
						if (gProps.FrmMain.BrowserRepl[1].SelectedRowCount > 0)
						{
							//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							dlgSB.sItemCode = Convert.ToString(BrowserRepl[1].get_value("Items.Itemcode"));
							//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							dlgSB.sItemdesc = Convert.ToString(BrowserRepl[1].get_value("Items.Description"));
						}
						else
						{
							//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							dlgSB.sItemCode = Convert.ToString(Browser[1].get_value("Items.Itemcode"));
							//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
							dlgSB.sItemdesc = Convert.ToString(Browser[1].get_value("Items.Description"));
						}
					}

					if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_SERIEBATCH)))
					{
						//if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_SERIEBATCH)))
						//{ // br 03.293.920
						if (gObjSerialBatch == null)
						{
							gObjSerialBatch = new Exact.Inventory.SerialBatch.SerialBatch();
							m_App.ConnectObject(gObjSerialBatch, m_Comp, m_Term);

						}
						gObjSerialBatch.sWarehouse = gProps.ModItemBrowser.gWareHs;
					}
					m_App.ConnectObject(dlgSB, m_Comp, m_Term);
					dlgSB.Show(Handle );
				}
				catch (Exception catchedException)
				{
					Exact.Exceptions.Globe.BaseGlobeException exc = Exact.Exceptions.Utils.ExceptionBuilder.Build(catchedException);
				}
			}    
		}


		//UPGRADE-WARNING: Parameter Index was changed from byref to byval.
		private void fbCommand_Click(Object eventSender, EventArgs eventArgs)
		{
			int Index = Array.IndexOf(this.fbCommand, eventSender);
			switch(Index)
			{
				case 0 : 
					OpenMaint(true); 
					break;
				case 1 : 
					OpenMaint(false); 
					break;
			}
			DoButtons(true);
		}

		private void Form_Paint(Object eventSender, EventArgs eventArgs)
		{
			//br: 21.126.896
			//        If Len(Trim(gSelectArtCd)) = 0 Then
			//            On Error Resume Next
			//            ItemFilter.SetFocus
			//        End If
			//BR 23.389.323 Focus issue
			if (Browser[1].NumRows > 0 && !System.String.IsNullOrWhiteSpace(gProps.ModItemBrowser.gSelectArtCd))
			{
				Browser[1].Focus();
			}
			else
			{
				ItemFilter.Focus();
			}
		}

		private void LoadBrowser()
		{

			//ControlArrayHelper.LoadControl(this, "Browser", 1); //first time load of browser
			
			//Browser[0].Visible = false;
			Array.Resize(ref Browser, Browser.Length + 1);
			Browser[1] = Browser[0];// new Exact.Win.UI.DataLayerGrid.Browser();
			Browser[1].SkipAutoRefresh = true;
			//this.pnlMainBrowser.Controls.Add(Browser[1]);
			//	ControlArrayHelper.LoadControl(this, "BrowserRepl", 1);
			Array.Resize(ref BrowserRepl, BrowserRepl.Length + 1);
			BrowserRepl[1] = BrowserRepl[0];// new Exact.Win.UI.DataLayerGrid.Browser();
			BrowserRepl[1].SkipAutoRefresh = true;
			//this.pnlReplaceBrowser.Controls.Add(BrowserRepl[1]);
			//BrowserRepl[0].Visible = false;
			//BrowserRepl[1].Visible = true;

		}

		private void FillDefaulFilterValues(bool bFirstLoad)
		{
			if (bFirstLoad)
			{
				ItemFilter.NoRefresh = true;

				// lohp17191 12.924.874 When there's only 1 warehouse in use, consider hiding the warehouse fip
				if (((gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE) && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_NORMAL_INVOICE || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)) || gProps.ModItemBrowser.giWarehouseCount == 1)
				{ //ngty@ 04.402.673 removed condition for TYPE_POS_INVOICE
					ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_WAREHOUSE);
				}

				switch(gProps.ModItemBrowser.gParentApp)
				{
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER : 
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_MAKEITEMS); 
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_ITEMEANCODE); 
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_CUSTOMER_ITEMCODE); 
						// lohp17191 13.588.212 Hide this checkbox 
						ItemFilter.HideGlobalSearchFilter(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_CUSTITEMCODE); 
						 
						//BR 16.947.508 hide user defined checkbox if compact 
						if (m_Comp.GetOpt(OPT_COMPACT))
						{
							ItemFilter.HideGlobalSearchFilter(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_USERDEFINED);
						} 
						 
						break;
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER : 
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_ITEMEANCODE); 
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_CUSTOMER_ITEMCODE); 
						// lohp17191 13.588.212 Hide this checkbox 
						ItemFilter.HideGlobalSearchFilter(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_CUSTITEMCODE); 

						 
						break;
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER :  //FC26.191.598 yoon109184 Recurring Sales Order 
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_MAKEITEMS); 
						if (gProps.ModItemBrowser.gAppMode != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
						{
							ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_ITEMEANCODE);
						} 
						 
						//BR 16.947.508 hide user defined checkbox if compact 
						if (m_Comp.GetOpt(OPT_COMPACT))
						{
							ItemFilter.HideGlobalSearchFilter(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_USERDEFINED);
							//chan221476 (19-11-2007) [BR24.827.860] - To Hide Customer Item code and Supplier Item Code in Direct Invoice for Exact Compact
							ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_CUSTOMER_ITEMCODE);
							ItemFilter.HideGlobalSearchFilter(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_CUSTITEMCODE);
							ItemFilter.HideGlobalSearchFilter(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_SUPPLIERITEMCODE);
						} 
						 
						break;
					default:
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SUPPLIER_ITEMCODE); 
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_MAKEITEMS); 
						ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_ITEMEANCODE); 
						// lohp17191 13.588.212 Hide this checkbox 
						ItemFilter.HideGlobalSearchFilter(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_SEARCH_SUPPLIERITEMCODE); 
						break;
				}

				//ngty@ 06.932.743
				if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_MAGAZIJNEN)))
				{
					ItemFilter.HideControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_WAREHOUSE);
				}

				//BR 21.098.375
				//Set default state to collapsed mode for Advanced
				//.IsExpanded = Collapsed

				//if this is the first time loading, then fill the default search
				ItemFilter.DefaultFilterValue("defsearch", gProps.ModItemBrowser.gSelectArtCd);


				//BR19.990.412:6/Sep/2006:chan193060 - First time loading, fip(warehouse) is enabled
				//BR19.990.412:DefaultFilterValue will set default value to gWareHs. But due to BR12.403.333 set fip to disable.
				//BR19.990.412:Inside DefaultFilterValue will not set fip value the 2nd time when form loaded.
				//BR19.990.412:Ensure fip(warehouse) default value is set. Defaultfilterstate of warehouse set to enabled.
				ItemFilter.DefaultFilterState("warehouse", true);

				ItemFilter.DefaultFilterValue("warehouse", gProps.ModItemBrowser.gWareHs);

				//BR 12.403.333 if warehouse is selected, then do not allow user to change warehouse, and it only for production order header entries
				//PBI33204 - Kanban order entry in EGN: Param for Kanban order
				if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_KANBAN) && !ItemFilter.IsWarehouseAll)
				{
					ItemFilter.EnabledControl(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.FIP_WAREHOUSE, false);
				}


			}

			ItemFilter.NoRefresh = true;

			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER)
			{ //FC26.191.598 yoon109184 Recurring Sales Order
				//PBI33204 - Kanban order entry in EGN: Param for Kanban order
				if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_KANBAN))
				{
					ItemFilter.DefaultFilterValue("artcodlev", (true).ToString());
					ItemFilter.DefaultFilterState("artcodlev", false);
				}
				else
				{
					//2006-08-10;chin111989;BR 19.829.016 Enable the Show make item first
					ItemFilter.DefaultFilterState("artcodlev");
					ItemFilter.DefaultFilterValue("artcodlev", (false).ToString());
				}
			}
			else if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER)
			{ 
				ItemFilter.DefaultFilterValue("buy", (true).ToString());
			}

			ItemFilter.fipFilterContain.Value = ItemFilter.Save2Registry(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.RegAction.Read, "FilterStartContain");
			ItemFilter.NoRefresh = false;

		}

		private void Initializeflags()
		{
			gbBusy = false;
			gItemCode = "";
			pnlReplaceBrowser.Visible = false;
		}

		//UPGRADE-WARNING: Parameter UnloadMode was changed from byref to byval.
		private void Form_FormClosing(Object eventSender, FormClosingEventArgs eventArgs)
		{
			int Cancel = (eventArgs.Cancel) ? 1 : 0;
			CloseReason UnloadMode = eventArgs.CloseReason;
			try
			{

                //UPGRADE_WARNING: (2065) QueryUnloadConstants property QueryUnloadConstants.vbFormControlMenu has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2065
                // checked with VB6 behavior,
                // only allow closing via Component disposing
                if (!_disposing && UnloadMode == CloseReason.UserClosing)
                {
                    Cancel = -1;
                    gProps.ModItemBrowser.gbCancel = true;
                    //UPGRADE_TODO: (1069) Error handling statement (On Error Resume Next) was converted to a pattern that might have a different behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1069
                    try
                    {
                        ItemFilter.Focus();
                        this.Hide();
                    }
                    catch (Exception catchedException)
                    {
                        Exact.Exceptions.Globe.BaseGlobeException exc = Exact.Exceptions.Utils.ExceptionBuilder.Build(catchedException);
                    }
                }
            }
			finally
			{
				eventArgs.Cancel = Cancel != 0;
			}
		}

		private bool isInitializingComponent;
		private void Form_Resize(Object eventSender, EventArgs eventArgs)
		{
			if (isInitializingComponent)
			{
				return;
			}
			FormResize();
		}

		//UPGRADE-WARNING: Parameter Cancel was changed from byref to byval.
		private void Form_Closed(Object eventSender, EventArgs eventArgs)
		{
			m_App = null;
			m_Conn = null;
			m_Comp = null;
			m_Term = null;
			m_Set = null;
			m_gk = null;
			m_oStackItemNav = null;
			//ngty@ who added this in? not being used?
			//Set vStk = Nothing
			gObjSerialBatch = null;
			mObjWareH = null;
			mObjStkQty = null;

			//BR41.204.403 tans285567 - Precision of prices is not rounded correctly
			m_CurCalc = null;

			if (hAncient != 0)
			{
				Exact.SystemLayer.API.Vsb.ReleaseOldApiCompatibility(hAncient);
				hAncient = 0;
			}
		}

		private void GetSettings()
		{
			Exact.DataLayer.EdlObject vRes = null;
			Exact.SystemLayer.Interfaces.ISettings iset = (Exact.SystemLayer.Interfaces.ISettings) m_Comp;

			//UPGRADE_WARNING: (1068) iset() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			gsValutaCodeDef = Convert.ToString(iset["eaccount\\default_valutacode,c"]);
			//UPGRADE_WARNING: (1068) iset() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			gProps.ModItemBrowser.gsMagazCodeDef = Convert.ToString(iset["ontvangst\\magcode,c"]);
			//UPGRADE_WARNING: (1068) iset.Setting() of type Variant is being forced to bool. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			gProps.ModItemBrowser.gbPricelistPerItemGroup = Convert.ToBoolean(iset.Setting("orders\\PriceListPerItemGroup,b", 0));

			// 12.517.720 lohp17191 Make a one time check to see if this user has all warehouse rights or happens to be admin
			if (m_Comp.User.Administrator)
			{
				gProps.ModItemBrowser.gbUserHasAllWrhHseRights = true;
			}
			else
			{
				// This query checks to see if there are any warehouses(except TRAN) that the user does not have any rights on. If we can't find any,
				// that means this user does have rights to all the warehouses that were created.
				vRes = m_Conn.Query("SELECT COUNT(*) FROM magaz LEFT JOIN pwmagaz ON magaz.magcode = pwmagaz.magcode AND pwmagaz.res_id=? WHERE magaz.magcode <> 'TRAN' AND pwmagaz.res_id IS NULL", m_Comp.User.ID, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);
				if (((double) vRes) == 0)
				{
					gProps.ModItemBrowser.gbUserHasAllWrhHseRights = true;
				}
			}

			gProps.ModItemBrowser.giWarehouseCount = (int) m_Conn.Query("SELECT COUNT(*) FROM magaz WHERE magaz.magcode <> 'TRAN'", null, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);

			//2008-01-09;chin111989;BR25.320.397 Operation setting
			//UPGRADE_WARNING: (1068) iset.Setting() of type Variant is being forced to bool. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			gProps.ModItemBrowser.gbUseRouting = Convert.ToBoolean(iset.Setting("manufacturing\\routing_operation,b", false));

		}

		private void SetFormCaptions()
		{

			//PBI 116391 - Set application title
			//VBAppSetTitle Me, m_Term.String(9889, "Items")

			sepReplace.Caption = m_Term.String(9380, "Replacement items");
			fbCommand[0].Caption = m_Term.String(1355, "New");
			fbCommand[1].Caption = m_Term.String(25319, "Edit");
			ToolTipMain.SetToolTip(cmdSerialBatch, m_Term.String(7917, "Serial/batch data"));

			//10.930.697, button BUT_SUPPLIER should terms with TERMS06679 (by supplier) in sales order.
			//FC26.191.598 yoon109184 Recurring Sales Order
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER || gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER)
			{
				ActionBar[BUT_BYSUPPLIER].SetCaptionTermID(26963, "By customer", false);
			}

		}

		private void SetFormControlColors()
		{
			Exact.SystemLayer.Interfaces.IGraphics iGrx = new Exact.SystemLayer.Graphics();
			Image icon = null;

			gProps.ModItemBrowser.SetToParentIcon(this);

			Exact.SystemLayer.Interfaces.ExactColor tempRefParam = Exact.SystemLayer.Interfaces.ExactColor.ecolBackground;
			Color lBackGround = iGrx.Color[tempRefParam];
			Exact.SystemLayer.Interfaces.ExactColor tempRefParam2 = Exact.SystemLayer.Interfaces.ExactColor.ecolActiveBackground;
			Color lActiveBackGround = iGrx.Color[tempRefParam2];

			try
			{

				Control ctrl = null;

				Exact.Win.UI.UniLabel.LabelW ctrlTyped = null;
				//UPGRADE_WARNING: (2065) Form property frmMain.Controls has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2065
				foreach (Control ctrlIterator in ContainerHelper.Controls(this))
				{
					ctrl = ctrlIterator;
					if ((ctrl is Exact.Win.UI.Fip) || (ctrl is Exact.Win.UI.UniCommandButton.CommandButtonW) || (ctrl is Exact.Win.UI.Panel.Panel))
					{
						ctrl.BackColor = lActiveBackGround;
					}
					if (ctrl is Exact.Win.UI.UniLabel.LabelW)
					{
						ctrlTyped = (Exact.Win.UI.UniLabel.LabelW) ctrl;
						ctrlTyped.BackColor = lActiveBackGround;
					}
					//ctrl
					ctrl = default(Control);
				}

				this.BackColor = lBackGround;

				icon = iGrx.Bitmap[GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.e4reslibIDs.IDB_SERIALBATCHDATA, (int) Exact.SystemLayer.Interfaces.IconSizes.eiconSmall];

				cmdSerialBatch.MaskColor = Color.Fuchsia;
				cmdSerialBatch.UseMaskColor = true;
				cmdSerialBatch.Picture = icon;
			}
			catch
			{
				//UPGRADE_TODO: (1065) Error handling statement (Resume Next) could not be converted. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1065
			}

		}

		private void SetFonts()
		{
			Exact.SystemLayer.Interfaces.IGraphics iGrx = new Exact.SystemLayer.Graphics();
			Control ctrl = null;

			Exact.Win.UI.UniLabel.LabelW ctrlTyped = null;
			//UPGRADE_WARNING: (2065) Form property frmMain.Controls has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2065
			foreach (Control ctrlIterator in ContainerHelper.Controls(this))
			{
				ctrl = ctrlIterator;
				if (ctrl is Exact.Win.UI.UniLabel.LabelW)
				{
					ctrlTyped = (Exact.Win.UI.UniLabel.LabelW) ctrl;
					if (!ctrlTyped.Name.StartsWith("lblQty") && !ctrlTyped.Name.StartsWith("fipInfo"))
					{
						try
						{
							ctrlTyped.Font = iGrx.Font[Exact.SystemLayer.Interfaces.ExactFont.efontDefaultButton];
						}
						catch
						{
						}
					}
				}
				ctrl = default(Control);
			}
		}

		//UPGRADE-WARNING: Parameter bExpanded was changed from byref to byval.
		private void ItemFilter_Expand(Object Sender, ItemFilter.ExpandEventArgs e)
		{
			GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.ExpansionTypes bExpanded = e.bExpanded;
			if (pnlReplaceBrowser.Visible)
			{
				pnlReplaceBrowser.Visible = bExpanded == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.ExpansionTypes.Collapsed;
			}
			Form_Resize(this, new EventArgs());
		}

		private void ItemFilter_ExpandProperty(Object Sender, EventArgs e)
		{
			Form_Resize(this, new EventArgs());
		}

		//11.644.319 lohp17191 Forces focus to either the lines or the search textbox without forcing a refresh on the browser
		private void ItemFilter_ForceFocus(Object Sender, EventArgs e)
		{
			//UPGRADE_TODO: (1069) Error handling statement (On Error Resume Next) was converted to a pattern that might have a different behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1069
			try
			{
				if (Browser[1].NumRows == 1)
				{
					Browser[1].SelectRow(1, true);
					Browser[1].CurrentRow = 1;
					ActionBar.SetFocusOnButton(BUT_SELECT);
				}
				else if (Browser[1].NumRows > 1)
				{ 
					Browser[1].SelectRow(1, true);
					Browser[1].CurrentRow = 1;
					Browser_SelectionChanged(Browser[1], new EventArgs());
				}
				else if (Browser[1].NumRows == 0)
				{ 
					if (this.Visible)
					{
						ItemFilter.Focus();
					}
				}

				Form_Resize(this, new EventArgs());
			}
			catch (Exception catchedException)
			{
				Exact.Exceptions.Globe.BaseGlobeException exc = Exact.Exceptions.Utils.ExceptionBuilder.Build(catchedException);
			}

		}

		private void ItemFilter_ForceRefresh(Object Sender, ItemFilter.ForceRefreshEventArgs e)
		{
			bool bClear = e.bClear;
			if (bClear)
			{
				FillDefaulFilterValues(false);
			}

			DoRefresh();

			if (Browser[1].NumRows == 1)
			{
				//11.644.319 lohp17191 Should also select the first row before setting focus on button. Without doing this,
				// the button will still be disabled, and no focus can be set on it.
				Browser[1].SelectRow(1, true);
				Browser[1].CurrentRow = 1;
				//angs BR 20.756.775 Hide <add>, <Edit> and copy buttons with E-Branche
				if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_POS_BRANCHE_OFFICE)))
				{
					fbCommand[1].Enabled = true;
				}
				ActionBar.SetFocusOnButton(BUT_SELECT);

				//BR 16.409.543 if 1 < maxrow, disable navigation btn
				if (Browser[1].NumRows < ItemFilter.MaxRows)
				{
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, false);
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);
				}
				else
				{
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, true);
				}

			}
			else if (Browser[1].NumRows > 1)
			{ 
				Browser[1].SelectRow(1, true);
				Browser[1].CurrentRow = 1;
				//angs BR 20.756.775 Hide <add>, <Edit> and copy buttons with E-Branche
				if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_POS_BRANCHE_OFFICE)))
				{
					fbCommand[1].Enabled = true;
				}
				//Browser_SelectionChanged(Browser[1], new EventArgs());

				//BR 16.297.817
				DetermineNavBtnState(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SEARCH_REFRESH);

			}
			else if (Browser[1].NumRows == 0)
			{ 
				if (this.Visible)
				{
					//FC 16.045.238 if no row returns disable pre&next btn
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, false);
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);

					fbCommand[1].Enabled = false;
					//UPGRADE_TODO: (1069) Error handling statement (On Error Resume Next) was converted to a pattern that might have a different behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1069
					try
					{
						ItemFilter.Focus();
					}
					catch (Exception catchedException)
					{
						Exact.Exceptions.Globe.BaseGlobeException exc = Exact.Exceptions.Utils.ExceptionBuilder.Build(catchedException);
					}
				}
			}
		}

		//BR 16.297.817
		//UPGRADE-WARNING: Parameter sType was changed from byref to byval.
		private void DetermineNavBtnState(string sType)
		{

			if (sType == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SEARCH_REFRESH)
			{
				if (EdlBusyCheck())
				{
					//FC 16.045.238 if row returns < than max row defined, disable pre&next btn
					if (Browser[1].NumRows < ItemFilter.MaxRows)
					{
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, false);
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);
					}
					else
					{
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, true);
					}
				}
				else
				{
					//if false meant edl still busy
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, true);
				}
			}
			else
			{

				//when next is press, the previous button always enable
				ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, true);

				//next navigation
				if (EdlBusyCheck())
				{
					// if the browser is empty or browser rows returned < maxrow, disable the Next button
					if (Browser[1].NumRows == 0 || Browser[1].NumRows < ItemFilter.MaxRows)
					{
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, false);
					}
				}
				else
				{
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, true);
				}

			}

		}

		bool bBusy_FormResize = false;
		private void FormResize()
		{

			if (bBusy_FormResize)
			{
				return;
			}

			bBusy_FormResize = true;

			int InsideWidth = 0;
			int H = 0, w = 0;

			//FC 16.044.993 show item picture
			//ngty@ 08.789.273
			pnlItemInfo.Visible = ItemFilter.bShowdata || ItemFilter.bShowItemData;

			int AvailableTop = 0;
			int AvailableHeight = 0;
			if (WindowState != FormWindowState.Minimized)
			{
				w = this.ContentPanel.Width * 15;
				H = (this.ClientRectangle.Height - this.OffsetClientHeight) * 15 - ActionBar.Height * 15 - 350;
				if (H < 9000)
				{
					H = 9000;
				}
				if (w < 12000)
				{
					w = 12000;
				}

				InsideWidth = w - 300;
				
				ItemFilter.Top = 5;
				ItemFilter.Left = 5;
				ItemFilter.Width = InsideWidth / 15;

				// Determine fixed height for browser1 panel

				//BR 16.263.480 'don't add 30, else will cause RTE when screen resolution is > 1280*768
				AvailableTop = ItemFilter.Top * 15 + ItemFilter.Height * 15; // + 30
				AvailableHeight = pnlMain.Height * 15 - AvailableTop - 180;

				// Substract item info
				if (pnlItemInfo.Visible)
				{
					AvailableHeight -= pnlItemInfo.Height * 15;
				}

				// Check replacement browser visibillity
				if (bShowReplaceBrowser)
				{
					// Both visible
					H = Convert.ToInt32((AvailableHeight + 450) / 2d);
					pnlMainBrowser.SetBounds(5, AvailableTop / 15, InsideWidth / 15, H / 15);
					pnlReplaceBrowser.SetBounds(5, pnlMainBrowser.Top + pnlMainBrowser.Height, InsideWidth / 15, (AvailableHeight - H) / 15);
				}
				else
				{
					// Only main browser
					pnlMainBrowser.SetBounds(5, (AvailableTop / 15) + 5, InsideWidth / 15, AvailableHeight / 15);
				}

				// Move item info panel
				pnlItemInfo.SetBounds(8, ((AvailableTop + AvailableHeight) / 15) + 5, InsideWidth / 15, 0, BoundsSpecified.X | BoundsSpecified.Y | BoundsSpecified.Width);

				// Main browser panel size
				H = pnlMainBrowser.Height * 15 - 180;
				fbCommand[0].Top = 43;
				fbCommand[1].Top = fbCommand[0].Top + fbCommand[0].Height + 4;
				fbCommand[0].Left = 10;
				fbCommand[1].Left = 10;
				Browser[1].SetBounds(fbCommand[0].Width + 15, 3, pnlMainBrowser.Width - 40, (H / 15) + 8);

				// Replace item panel size
				if (bShowReplaceBrowser)
				{
					sepReplace.SetBounds(6, 6, pnlReplaceBrowser.Width - 12, 0, BoundsSpecified.X | BoundsSpecified.Y | BoundsSpecified.Width);
					BrowserRepl[1].SetBounds(fbCommand[0].Width + 15, sepReplace.Top + sepReplace.Height, pnlReplaceBrowser.Width - 40, pnlReplaceBrowser.Height - sepReplace.Top - sepReplace.Height - 6);
				}

				switch(gProps.ModItemBrowser.gParentApp)
				{
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE : 
						//hide stock quantity panels 
						 
						break;
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.RECEIPT : 
						//always show item info 
						pnlItemInfo.Top = pnlMainBrowser.Top + pnlMainBrowser.Height; 
						break;
				}
			}

			bBusy_FormResize = false;
		}

		private void SetInitialSize()
		{
			if (this.ContentPanel.Width * 15 < 12000 || this.Height * 15 < 8999)
			{
				this.ContentPanel.Width = 833;
				this.Height = 600;
			}

		}

		private void FillCaptions()
		{
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER)
			{
				lblWInfoHeader[0].Caption = m_Term.String(4850, "Purchase price");
			}

			//FC 16.044.993
			//lblWInfoHeader(1).Caption = m_Term.String(3299, "Item delivery time")
			lblWInfoHeader[1].Caption = m_Term.String(1836, "Time of delivery");
			lblWInfoHeader[2].Caption = m_Term.String(5858, "Extra item description");
			lblWInfoHeader[3].Caption = m_Term.String(1401, "Main supplier");
			lblWInfoHeader[4].Caption = m_Term.String(167, "Available batches");

		}

		private void SetItemInfoVisibility()
		{

			if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_VOORRAAD)) || !m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_MRP)))
			{ //license Stock & Purchase Control
				ActionBar[BUT_MRP].Visible = false;
				//BR 10.822.491 Hide Item Planning button if it is Compact without license for Stock & Purchase Control
				// 13.926.437 Hide button completely for all Compact mode (used to check on Stock&Purchase module as well)
				if (m_Comp.GetOpt(OPT_COMPACT))
				{
					ActionBar[BUT_ITEMPLAN].Visible = false;
				}
			}

			//FC26.191.598 yoon109184 Recurring Sales Order
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER)
			{
				ActionBar[BUT_MRP].Visible = false;
			}

			switch(gProps.ModItemBrowser.gParentApp)
			{
				case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER : 
					fipInfo[3].Visible = true; 
					lblWInfoHeader[3].Visible = true; 
					 
					break;
				case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PRODUCTION_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER :  //FC26.191.598 yoon109184 Recurring Sales Order 
					 
					//FC 16.044.993 hide sales order price and rearrange position 
					lblWInfoHeader[0].Visible = false; 
					fipInfo[0].Visible = false; 
					lblWInfoHeader[2].Top = lblWInfoHeader[3].Top; 
					fipInfo[2].Top = fipInfo[3].Top; 
					lblWInfoHeader[3].Top = lblWInfoHeader[0].Top; 
					fipInfo[3].Top = fipInfo[0].Top; 
					 
					break;
				case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.RECEIPT : 
					cmdSerialBatch.Visible = false; 
					fipInfo[2].Visible = false; 
					lblWInfoHeader[2].Visible = false; 
					 
					break;
			}

		}

		private void SetButtonVisibility()
		{
			//ngty@ 05.105.403 make sure this is set to cater for font sizes
			//UPGRADE_ISSUE: (2064) slui.ActionBar method actActionBar.Align was not upgraded. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2064
			//// ActionBar.setAlign(DockStyle.Top);
			//UPGRADE_ISSUE: (2064) slui.ActionBar method actActionBar.Align was not upgraded. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2064
			//// ActionBar.setAlign(DockStyle.Bottom);

			//temp hide this
			ActionBar[BUT_NEW].Visible = false;
			ActionBar[BUT_OPEN].Visible = false;
			ActionBar[BUT_COPY].Visible = false;

			//Check rights
			//BR 17.950.204
			if (!m_gk.Access(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PWFUNC_ITEMCARDS))
			{
				ActionBar.get_Button(BUT_CARD).Visible = false;
			}

			//ngty@ 08.709.652
			//lohp17191 12.054.336 Use View Cost/Purchase Price rights instead
			if (m_gk.Access(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.VIEWCPPRICERIGHTS))
			{
				gProps.ModItemBrowser.gbShowPurchaseInfo = true;
			}

			//ngty@ 09.012.744
			bHaveMaintainItem = m_gk.Access(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PWFUNC_MAINTAIN_ITEMS);

			//angs BR 20.756.775 Hide <add>, <Edit> and copy buttons with E-Branche
			if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_POS_BRANCHE_OFFICE)))
			{
				fbCommand[0].Visible = bHaveMaintainItem;
				fbCommand[1].Visible = bHaveMaintainItem;
				ActionBar[BUT_COPY].Visible = bHaveMaintainItem; // 11.894.077 lohp17191
			}
			else
			{
				fbCommand[0].Enabled = false;
				fbCommand[1].Enabled = false;
			}

			//[jose276913 14-03-2011 16:10 (GMT +08:00)] 38.542.616
			if (bUseCentralData)
			{
				fbCommand[0].Visible = false;
				ActionBar[BUT_COPY].Visible = false;
			}

			if (!m_gk.Access(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PWFUNC_MRP))
			{
				ActionBar.get_Button(BUT_MRP).Visible = false;
			}

			//EG2003 Standard Edition Options
			if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_STANDARD_EDITION)))
			{
				ActionBar.get_Button(BUT_REPLACE).Visible = false; //ngty@ 07.342.911
				ActionBar.get_Button(BUT_ITEMPLAN).Visible = true; //>> Br : 09.795.509
				ActionBar.get_Button(BUT_MRP).Visible = false; //ngty@ 07.995.502
			}
			else
			{
				//>>Br: 10.026.364
				ActionBar.get_Button(BUT_ITEMPLAN).Visible = !m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_MRP)); //>> Br : 09.795.509
			}


			//hide the serial batch info button & label
			if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_SERIEBATCH)))
			{
				lblWInfoHeader[4].Visible = false;
				cmdSerialBatch.Visible = false;
			}

			if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_MAGAZIJNEN)) || m_Comp.GetOpt(OPT_COMPACT))
			{
				ActionBar.get_Button(BUT_BYWAREHOUSE).Visible = false;
			}

			//replacement item browser is only applicable for sales order and sales invoice
			//FC26.191.598 yoon109184 Recurring Sales Order
			if (m_Comp.GetOpt(OPT_COMPACT) || (gProps.ModItemBrowser.gParentApp != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER && gProps.ModItemBrowser.gParentApp != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER && gProps.ModItemBrowser.gParentApp != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE && gProps.ModItemBrowser.gParentApp != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER))
			{
				ActionBar.get_Button(BUT_REPLACE).Visible = false;
			}

			//no item planning in compact
			if (m_Comp.GetOpt(OPT_COMPACT))
			{
				ActionBar.get_Button(BUT_MRP).Visible = false;
			}

			m_bItemRange = false; //ngty@ set this to false first

			//all items is only applicable for purchase order
			if (gProps.ModItemBrowser.gParentApp != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER)
			{
				//FC26.191.598 yoon109184 Recurring Sales Order
				if (gProps.ModItemBrowser.gParentApp != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER && gProps.ModItemBrowser.gParentApp != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER)
				{
					// lohp17191 11.091.282
					if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE)
					{
						GetCicmpyGuid(ref gProps.ModItemBrowser.gDebtorOrCreditorGuid, ref gProps.ModItemBrowser.gPriceAgreementExists);
					}

					ActionBar.get_Button(BUT_ALLITEMS).Visible = false;
					ActionBar.get_Button(BUT_BYSUPPLIER).Visible = false;
				}
				else
				{
					//ngty@ 08.197.791 all this hassle!!
					GetCicmpyGuid(ref gProps.ModItemBrowser.gDebtorOrCreditorGuid, ref gProps.ModItemBrowser.gPriceAgreementExists);
					//lohp17191 11.091.282 retrieve guid for order debtor if we're in order mode
					if (gProps.ModItemBrowser.gOrderDebtor == gProps.ModItemBrowser.gDebtorOrCreditor)
					{
						gProps.ModItemBrowser.gOrderDebtorGuid = gProps.ModItemBrowser.gDebtorOrCreditorGuid;
						gProps.ModItemBrowser.gOrderDebtorPriceAgreement = gProps.ModItemBrowser.gPriceAgreementExists;
					}
					else
					{
						GetCicmpyGuid(ref gProps.ModItemBrowser.gOrderDebtorGuid, ref gProps.ModItemBrowser.gOrderDebtorPriceAgreement, true);
					}
					//UPGRADE_WARNING: (1068) m_Set.Setting() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_PRIJSAFSPRAAK)) && gProps.ModItemBrowser.gPriceAgreementExists && Convert.ToString(m_Set.Setting("orders\\assortiment_inorder,c", "U")) == "P")
					{
						m_bItemRange = true;
						//BR 21.353.825
						ActionBar.EnableButton(BUT_BYSUPPLIER, !ActionBar.get_Button(BUT_ALLITEMS).Enabled);
					}
					else
					{
						ActionBar.get_Button(BUT_ALLITEMS).Visible = false;
						ActionBar.get_Button(BUT_BYSUPPLIER).Visible = false;
						m_bItemRange = false;
					}
				}
			}
			else
			{
				//BR 21.353.825
				ActionBar.EnableButton(BUT_BYSUPPLIER, !ActionBar.get_Button(BUT_ALLITEMS).Enabled);
				ActionBar.get_Button(BUT_MRP).Visible = false;
			}

			//BR 03.203.111
			//POS invoice doesn't need the 'SELECT' button for item browser type 1 (stock-positions)
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER && gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
			{
				ActionBar.get_Button(BUT_SELECT).Visible = false;
			}

			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE && gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_POS_INVOICE)
			{
				ActionBar.get_Button(BUT_BYWAREHOUSE).Visible = false;
			}

			//dummy button to set focus to when the browser is disabled during the calculations of stock positions
			ActionBar.get_Button(BUT_DUMMY).Visible = false;

			//angs BR 20.756.775 Hide <add>, <Edit> and copy buttons with E-Branche
			if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_POS_BRANCHE_OFFICE)))
			{
				fbCommand[0].BitmapID = GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.e4reslibIDs.IDB_ADDROW;
				fbCommand[1].BitmapID = GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.e4reslibIDs.IDB_EDITROW;
			}
			ActionBar[BUT_CLOSE].Visible = true;

		}

		private void SetupBrowsers(string sType)
		{
			string sHideExplode = "";
			string InvisibleCols = "";
			string ExtraColInfo = "";
			string OtherColInfo = "";
			//Dim TermString    As String

			string sTables = "";

			//BR41.204.403 tans285567 - Precision of prices is not rounded correctly
			int pricePrecision = 0;

			try
			{

				switch(gProps.ModItemBrowser.gParentApp)
				{
					//FC26.191.598 yoon109184 Recurring Sales Order
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_INVOICE : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER : case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SALES_RECURRING_ORDER : 
						sTables = "items,ItemAccounts,recipe,itemassortment"; 
						break;
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER : 
						sTables = "items,ItemAccounts,recipe,artlev"; 
						break;
					case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.RECEIPT : 
						sTables = "items,ItemAccounts,recipe"; 
						break;
				}

				//'BR 18.128.324 Add user number 9 -13
				InvisibleCols = "items.ID, " + 
								"items.UserNumber_01, items.UserNumber_02, items.UserNumber_03, items.UserNumber_04, items.UserNumber_05, items.UserNumber_06, items.UserNumber_07, items.UserNumber_08, items.UserNumber_09, items.UserNumber_10, items.UserNumber_11, items.UserNumber_12, items.UserNumber_13,  " + 
								"items.UserField_01, items.UserField_02, items.UserField_03, items.UserField_04, items.UserField_05, items.UserField_06, items.UserField_07, items.UserField_08, items.UserField_09,items.UserField_10, " + 
								"items.UserDate_01, items.UserDate_02, items.UserDate_03, items.UserDate_04,items.UserDate_05,  " + 
								"items.UserYesNo_01, items.UserYesNo_02, items.UserYesNo_03, items.UserYesNo_04, items.UserYesNo_05";

				//ngty@ Make the option available but not visible when showing all items in prod ord
				//BR 12.447.878 gappMode = TYPE_PROD_ALL not link to recipe table anymore, not show recepe version and mainvesion
				//    If gParentApp = INTERNAL_ORDER And gAppMode = TYPE_PROD_ALL Then
				//        InvisibleCols = InvisibleCols & ",recipe.version,recipe.MainVersion"
				//    End If

				if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_STANDARD_EDITION)))
				{
					sHideExplode = "1";
				}
				else
				{
					sHideExplode = "";
				}

				//BR41.204.403 tans285567 - Precision of prices is not rounded correctly
				pricePrecision = m_CurCalc.CurrencyPricePrecision();

				//tanc30792 [BR 09.700.237] [2004 May 31] - Change "Supplier's code"  to "Supplier's item code"
				//BR41.204.403 tans285567 - Precision of prices is not rounded correctly
				//Change the Sales Price and Purchase Price precision from 2 to pricePrecision.
				OtherColInfo = "Items.Itemcode, 1102, ItlblWInfoHeaderem code,14;" + 
							   "ItemAccounts.ItemCodeAccount, 5501, Supplier's item code,14;" + 
							   "IADebtor.ItemCodeAccount, 24621,Customer item code,14;" + 
							   "[Items.Description], 4243, Description,30;" + 
							   "ItemAccounts.PurchasePackage, 4033, Purchase unit,14;" + 
							   "Items.IsSalesItem, 8771, Sales,,,,,1;" + 
							   "Items.IsPurchaseItem, 8674, Purchase,,,,,1;" + 
							   "[Items.IsAssembled], 0652, Make,,,,,1;" + 
							   "Items.IsExplode, 22169, Explode,,,," + sHideExplode + ",1;" + 
							   "Items.IsStockItem, 8859, Stock,,,,,1;" + 
							   "Items.IsSerialNumberItem, 31404, Serial,,,,,1;" + 
							   "Items.IsBatchItem, 4007, Batch,,,,,1;" + 
							   "Items.Condition, 4332, Status;" + 
							   "HasPicture, 9863, Picture,,,,,1;" + 
							   "SalesPrice, 4851, Sales Price, 10, " + pricePrecision.ToString() + ";" + 
							   "PurchasePrice, 4850, Purchase price, 10, " + pricePrecision.ToString() + ";" + 
							   "MainSupplier, 5098, Supplier, 45;" + 
							   "ItemAccounts.ItemCodeAccount, 5501, Supplier's item code;" + 
							   "Currency, 8509, Currency;" + 
							   "Items.Searchcode, 1816, Search code;" + 
							   "Items.Warehouse, 5071, Main Warehouse;" + 
							   "Recipe.Version, 3823, Version,,,1;" + 
							   "Recipe.MainVersion,8949,Main version,10,,,,1;";

				//BR 18.128.324 Add user number 9 -13
				//TermString = m_Term.String(8915, "Extra")
				ExtraColInfo = "items.UserNumber_01,20993,Items : UserNumber_01;" + 
							   "items.UserNumber_02,21007,Items : UserNumber_02;" + 
							   "items.UserNumber_03,21302,Items : UserNumber_03;" + 
							   "items.UserNumber_04,21307,Items : UserNumber_04;" + 
							   "items.UserNumber_05,21357,Items : UserNumber_05;" + 
							   "items.UserNumber_06,21389,Items : UserNumber_06;" + 
							   "items.UserNumber_07,21533,Items : UserNumber_07;" + 
							   "items.UserNumber_08,21555,Items : UserNumber_08;" + 
							   "items.UserNumber_09,13518,Items : UserNumber_09;" + 
							   "items.UserNumber_10,13525,Items : UserNumber_10;" + 
							   "items.UserNumber_11,13526,Items : UserNumber_11;" + 
							   "items.UserNumber_12,13527,Items : UserNumber_12;" + 
							   "items.UserNumber_13,13529,Items : UserNumber_13;";

				ExtraColInfo = ExtraColInfo + 
							   "items.UserField_01, 20064,Items : UserField_01,60;" + 
							   "items.UserField_02, 20099,Items : UserField_02,60;" + 
							   "items.UserField_03, 20129,Items : UserField_03,60;" + 
							   "items.UserField_04, 20366,Items : UserField_04,60;" + 
							   "items.UserField_05, 20520,Items : UserField_05,60;" + 
							   "items.UserField_06, 20531,Items : UserField_06,60;" + 
							   "items.UserField_07, 20586,Items : UserField_07,60;" + 
							   "items.UserField_08, 20665,Items : UserField_08,60;" + 
							   "items.UserField_09, 20703,Items : UserField_09,60;" + 
							   "items.UserField_10, 20990,Items : UserField_10,60;";

				ExtraColInfo = ExtraColInfo + 
							   "items.UserDate_01,  19397,Items : UserDate_01;" + 
							   "items.UserDate_02,  19442,Items : UserDate_02;" + 
							   "items.UserDate_03,  19461,Items : UserDate_03;" + 
							   "items.UserDate_04,  19463,Items : UserDate_04;" + 
							   "items.UserDate_05,  19531,Items : UserDate_05;";

				ExtraColInfo = ExtraColInfo + 
							   "items.UserYesNo_01, 21567,Items : UserYesNo_01,,,,,1;" + 
							   "items.UserYesNo_02, 19240,Items : UserYesNo_02,,,,,1;" + 
							   "items.UserYesNo_03, 19298,Items : UserYesNo_03,,,,,1;" + 
							   "items.UserYesNo_04, 19339,Items : UserYesNo_04,,,,,1;" + 
							   "items.UserYesNo_05, 19371,Items : UserYesNo_05,,,,,1;";

				if (sType == BROWSE_MAIN)
				{

					//ControlArrayHelper.UnloadControl(this, "Browser", 1);
					//ControlArrayHelper.LoadControl(this, "Browser", 1);
					m_App.ConnectObject(Browser[1], m_Comp, m_Term);

					if (gProps.ModItemBrowser.gbMultiSelect)
					{
						Browser[1].MultiSelect = true;
						Browser[1].MultiSelectMode = 1;
					}
					else
					{
						Browser[1].MultiSelect = false;
					}
					Browser[1].SelectionEvents = true;
					Browser[1].Visible = true;
					Browser[1].StorageKey = "Exact Globe 2003\\[" + Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "]-" + gProps.ModItemBrowser.gParentApp + "-" + gProps.ModItemBrowser.gAppMode;
					Browser[1].ColInfo = OtherColInfo + ExtraColInfo;
					Browser[1].InvisibleCols = InvisibleCols;
					Browser[1].Tables = sTables;
					//ngty@ performance settings
					Browser[1].LockMode = (short) Exact.DataLayer.LockModes.edlReadOnly;
					Browser[1].Options = (int) Exact.DataLayer.QueryOptions.edlOptFetchBackground;
					//BR 16.409.543 don't set this, since now have the functionality of previous,next,and number of row to return
					//these will cause the no valid EDL object error when retrieving large record
					//.RowsetSize = 50
					//.FetchInterval = 100
				}
				else
				{
					//ControlArrayHelper.UnloadControl(this, "BrowserRepl", 1);
					//ControlArrayHelper.LoadControl(this, "BrowserRepl", 1);
					m_App.ConnectObject(BrowserRepl[1], m_Comp, m_Term);
					if (gProps.ModItemBrowser.gbMultiSelect)
					{
						BrowserRepl[1].MultiSelect = true;
						BrowserRepl[1].MultiSelectMode = 1;
					}
					else
					{
						BrowserRepl[1].MultiSelect = false;
					}
					BrowserRepl[1].SelectionEvents = true;
					BrowserRepl[1].Visible = true;
					BrowserRepl[1].StorageKey = "Exact Globe 2000\\[" + Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "]-Replacement-" + gProps.ModItemBrowser.gParentApp + "-" + gProps.ModItemBrowser.gAppMode;
					BrowserRepl[1].ColInfo = OtherColInfo + ExtraColInfo;
					BrowserRepl[1].InvisibleCols = InvisibleCols;
					BrowserRepl[1].Tables = "items,itemassortment,artver";
				}

				FormResize();
			}
			catch
			{
			}

		}

		private void FillItemInfo()
		{

			//ngty@ 08.789.273
			if (!(ItemFilter.bShowdata || ItemFilter.bShowItemData))
			{
				return;
			} //check if its needed in the first place

			if (IsEdlBusy())
			{
				return;
			} //mandatory check on the edl threading

			string sSQL = "";
			string sSerialOrBatch = "";

			fipInfo[0].Value = "";
			fipInfo[1].Value = "";
			fipInfo[2].Value = "";
			fipInfo[3].Value = "";

			//delivery time + sales price
			if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER)
			{ //ngty@ 05.918.865
				sSQL = "SELECT ItemAccounts.DeliveryTimeInDays, Items.SalesPackagePrice, ItemAccounts.PurchasePrice, Items.lev_crdnr, cicmpy.cmp_name, ItemAccounts.PurchasePackage " + 
					   " FROM items " + 
					   " LEFT JOIN cicmpy ON cicmpy.crdnr = items.lev_crdnr AND cicmpy.crdnr IS NOT NULL AND items.lev_crdnr IS NOT NULL" + 
					   " LEFT JOIN ItemAccounts ON items.ItemCode = ItemAccounts.ItemCode AND Items.lev_crdnr = ItemAccounts.crdnr" + 
					   " WHERE items.ItemCode = ?";
			}
			else
			{
				sSQL = "SELECT ItemAccounts.DeliveryTimeInDays, Items.SalesPackagePrice, ItemAccounts.PurchasePrice, Items.lev_crdnr, cicmpy.cmp_name, Items.PackageDescription " + 
					   " FROM items " + 
					   " LEFT JOIN cicmpy ON cicmpy.crdnr = items.lev_crdnr AND cicmpy.crdnr IS NOT NULL AND items.lev_crdnr IS NOT NULL" + 
					   " LEFT JOIN ItemAccounts ON items.ItemCode = ItemAccounts.ItemCode AND Items.lev_crdnr = ItemAccounts.crdnr" + 
					   " WHERE items.ItemCode = ?";
			}

			Exact.DataLayer.EdlObject vInfo = m_Conn.Query(sSQL, gItemCode, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);

			if (!Exact.SystemLayer.Common.ConvertHelper.IsEmpty(vInfo))
			{
				fipInfo[1].Value = (System.String.IsNullOrWhiteSpace((string) vInfo[0])) ? "" : ((string) vInfo[0]) + " " + m_Term.String(1722, "Days");
				fipInfo[3].Value = ((string) vInfo[3]).Trim() + " " + StringsHelper.Replace((string) vInfo[4], "&", "&&", 1, -1, CompareMethod.Binary);

				if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER)
				{
					//purchase currency gsValutacode
					fipInfo[0].Value = (System.String.IsNullOrWhiteSpace((string) vInfo[2])) ? "" : Exact.SystemLayer.API.vbconv.EPriceToStr(gsValutaCode, (double) vInfo[2]) + " " + gsValutaCode + " / " + ((string) vInfo[5]);

					//FC 16.044.993 sales price is not needed
					//        Else
					//            'ngty@ 04.088.070
					//            Dim dDate As Date
					//            Dim i As Integer
					//            dDate = VBGetSysDate
					//
					//            sSQL = "SELECT TOP 1 staffl.prijs83, stfoms.validfrom, stfoms.validto, items.PackageDescription, stfoms.valcode " & _
					//            '                   " FROM stfoms" & _
					//            '                   " INNER JOIN staffl ON stfoms.prijslijst = staffl.prijslijst" & _
					//            '                   " LEFT OUTER JOIN items ON staffl.artcode = items.itemcode" & _
					//            '                   " WHERE stfoms.main_pricelist = 1 AND staffl.artcode = ?"
					//            vInfo = m_Conn.Query(sSQL, gItemCode, edlNoNulls)
					//
					//            If Not IsEmpty(vInfo) Then
					//                If (IsEmpty(vInfo(3)) Or vInfo(3) >= dDate) And vInfo(2) <= dDate Then
					//                    fipInfo(0) = EPriceToStr(vInfo(5), vInfo(1)) & " " & vInfo(5) & " / " & vInfo(4)
					//                End If
					//            End If
				}

				if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.PURCHASE_ORDER)
				{
					fipInfo[3].Value = ((string) vInfo[3]).Trim() + " " + StringsHelper.Replace((string) vInfo[4], "&", "&&", 1, -1, CompareMethod.Binary);
				}
			}
			else
			{
				fipInfo[1].Value = "";
				fipInfo[3].Value = "";
			}

			//yang29501 BR# 12.462.228: Take the 1st Extra Item Description if gExArtCd is empty
			if ((((gProps.ModItemBrowser.gExArtCd) is null) ? 0 : gProps.ModItemBrowser.gExArtCd.Trim().Length) > 0)
			{
				//extra item description
				//UPGRADE_WARNING: (2081) Array has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2081
				vInfo = m_Conn.Query("SELECT artext.tekst FROM artext WHERE artext.ex_artcode = ? AND artext.artcode = ?", new Exact.DataLayer.EdlObject[]{gProps.ModItemBrowser.gExArtCd, gItemCode}, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);
			}
			else
			{
				//UPGRADE_WARNING: (2081) Array has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2081
				vInfo = m_Conn.Query("SELECT Top 1 artext.tekst FROM artext WHERE artext.artcode = ?", new Exact.DataLayer.EdlObject[]{gItemCode}, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);
			}

			if ((((vInfo) is null) ? 0 : vInfo.Length()) > 0)
			{
				fipInfo[2].Value = ((string) vInfo).Trim();
				fipInfo[2].Visible = true;
			}
			else
			{
				fipInfo[2].Visible = false;
			}

			//BR 17.021.427 enable the available serial/batch button for all the entries
			if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_SERIEBATCH)))
			{
				if (IsSerialOrBatchItem(gItemCode, ref sSerialOrBatch))
				{
					if (gProps.ModItemBrowser.gParentApp != GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.RECEIPT || m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_E_SERIEBATCH)))
					{
						lblWInfoHeader[4].Visible = true;
						lblWInfoHeader[4].Caption = (sSerialOrBatch == "B") ? m_Term.String(167, "Available batches") : m_Term.String(166, "Available serial numbers");
						cmdSerialBatch.Visible = true;
					}
					else
					{
						lblWInfoHeader[4].Visible = false;
						cmdSerialBatch.Visible = false;
					}
				}
				else
				{
					lblWInfoHeader[4].Visible = false;
					cmdSerialBatch.Visible = false;
				}
			}

			//display picture
			LoadImage();
		}


		public void LoadImage()
		{
			ref_Renamed.set_Char("Picture", "");
			imgPicture.Image = null;

			string sFileName = "";
			if (ref_Renamed.Find1(gItemCode))
			{
				if ((((ref_Renamed.get_Char("PictureFileName")) is null) ? 0 : ref_Renamed.get_Char("PictureFileName").Length) > 0)
				{
					ref_Renamed.set_Long("Picture", (int) Exact.DataLayer.edlBlobMedium.edlBlobFile);
					sFileName = ref_Renamed.get_Char("Picture");
					if (((int) (new FileInfo(sFileName)).Length) != 0)
					{
						using (FileStream stream = new FileStream(sFileName, FileMode.Open, FileAccess.Read))
						{
							imgPicture.Image = Image.FromStream(stream);
						}
					}
				}
			}
		}

		//UPGRADE_NOTE: (7001) The following declaration (IsHourOrExtraItem) seems to be dead code More Information: https://www.mobilize.net/vbtonet/ewis/ewi7001
		//private object IsHourOrExtraItem(string sItemCode)
		//{
			//if (IsEdlBusy())
			//{
				//return null;
			//} //mandatory check on the edl threading
			//
			//
			//if (Exact.SystemLayer.Common.ConvertHelper.IsEmpty(sItemCode))
			//{
				//return null;
			//}
			//
			//Exact.DataLayer.EdlObject vInfo = m_Conn.Query("SELECT Type, ItemCode FROM items WHERE ItemCode = ?", sItemCode, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);
			//if (!Exact.SystemLayer.Common.ConvertHelper.IsEmpty(vInfo))
			//{
				//BR:12.368.269 chin31862 15/09/2004
				//If machine Hour also open Hour Screen
				//gbIsHourItem = ((string) vInfo[0]) == "L" || ((string) vInfo[0]) == "M";
				//gbIsExtraItem = ((string) vInfo[0]) == "P";
			//}
			//return null;
		//}

		public bool IsSerialOrBatchItem(string sItemCode, ref string sSerialOrBatch)
		{
			bool result = false;
			if (IsEdlBusy())
			{
				return result;
			} //mandatory check on the edl threading


			string sSQL = "SELECT IsSerialNumberItem, IsBatchItem FROM items WHERE (IsSerialNumberItem=1 OR  IsBatchItem=1) AND  itemcode=?";
			Exact.DataLayer.EdlObject vInfo = m_Conn.Query(sSQL, sItemCode, Exact.DataLayer.EdlQueryValueOptions.edlNoNulls);

			if (!Exact.SystemLayer.Common.ConvertHelper.IsEmpty(vInfo))
			{
				result = true;
				sSerialOrBatch = (((double) vInfo[0]) == 1) ? "S" : "B";
			}
			return result;
		}

		private void ClearAllValues(bool bClearInfo = true)
		{
			if (!bClearInfo)
			{
				fipInfo[0].Value = "";
				fipInfo[1].Value = "";
				fipInfo[2].Value = "";
				fipInfo[3].Value = "";
				fipInfo[2].Visible = false; //FC 16.044.993
				imgPicture.Image = null;
			}

		}

		//BR 16.297.817
		//UPGRADE-WARNING: Parameter nSekunden was changed from byref to byval.
		private void Delay(int nSekunden)
		{

			int TimeOut = Convert.ToInt32((Environment.TickCount / 1000d) + nSekunden);

			do 
			{
				Application.DoEvents();
			}
			while(TimeOut >= (Environment.TickCount / 1000d));
		}

		//BR 16.297.817
		//This is to solved for edl still busy fetching data but already coming here to check for browser(1).numrow, it'll give wrong numrow returned
		//this is normal when the record listing is long
		private bool EdlBusyCheck()
		{

			bool result = false;
			int i = 0;
			if (IsEdlBusy())
			{


				while(i != 20000)
				{
					Debug.WriteLine(i.ToString() + "-" + Browser[1].NumRows.ToString());

					//Delay(Convert.ToInt32(0.8d));
					i++;

					if (!IsEdlBusy())
					{
						result = true;
						break;
					}
				};

			}
			else
			{
				result = true;
			}

			return result;
		}

		private void DoButtons(bool bEnable)
		{
			//Call actActionBar.EnableButton(BUT_OPEN, bEnable)
			if (!pnlReplaceBrowser.Visible)
			{
				//        If gbMultiSelect Then
				//            If Not Browser(1).NumRows > 0 Then
				//                fbCommand(1).Enabled = False
				//            Else
				//                fbCommand(1).Enabled = Browser(1).SelectedRowCount > 0
				//            End If
				//        Else
				//
				//        End If
				ActionBar.EnableButton(BUT_OPEN, bEnable);
				ActionBar.EnableButton(BUT_BYWAREHOUSE, bEnable);
				ActionBar.EnableButton(BUT_CARD, bEnable);
				ActionBar.EnableButton(BUT_MRP, bEnable);
				ActionBar.EnableButton(BUT_COPY, bEnable);
				//>>Br:10.026.364
				ActionBar.EnableButton(BUT_ITEMPLAN, bEnable);
			}
			else
			{
				//        fbCommand(1).Enabled = Not BrowserRepl(1).SelectedRowCount > 1
				ActionBar.EnableButton(BUT_OPEN, !(BrowserRepl[1].SelectedRowCount > 1));
				ActionBar.EnableButton(BUT_BYWAREHOUSE, !(BrowserRepl[1].SelectedRowCount > 1));
				ActionBar.EnableButton(BUT_CARD, !(BrowserRepl[1].SelectedRowCount > 1));
				ActionBar.EnableButton(BUT_MRP, !(BrowserRepl[1].SelectedRowCount > 1));
				ActionBar.EnableButton(BUT_COPY, !(BrowserRepl[1].SelectedRowCount > 1));
				//>>Br:10.026.364
				ActionBar.EnableButton(BUT_ITEMPLAN, !(BrowserRepl[1].SelectedRowCount > 1));
			}

			if (gProps.ModItemBrowser.gbMultiSelect)
			{
				if (!(Browser[1].NumRows > 0))
				{
					fbCommand[1].Enabled = false;
					ActionBar.EnableButton(BUT_SELECT, false);
					ActionBar.EnableButton(BUT_CARD, false);
					ActionBar.EnableButton(BUT_MRP, false);
					ActionBar.EnableButton(BUT_COPY, false);
					//>>Br:10.026.364
					ActionBar.EnableButton(BUT_ITEMPLAN, false);
				}
				else
				{
					//angs BR 20.756.775 Hide <add>, <Edit> and copy buttons with E-Branche
					if (!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_POS_BRANCHE_OFFICE)))
					{
						fbCommand[1].Enabled = Browser[1].SelectedRowCount > 0 || BrowserRepl[1].SelectedRowCount > 0;
					}
					ActionBar.EnableButton(BUT_SELECT, Browser[1].SelectedRowCount > 0 || BrowserRepl[1].SelectedRowCount > 0);
					ActionBar.EnableButton(BUT_CARD, Browser[1].SelectedRowCount > 0 || BrowserRepl[1].SelectedRowCount > 0);
					ActionBar.EnableButton(BUT_MRP, Browser[1].SelectedRowCount > 0 || BrowserRepl[1].SelectedRowCount > 0);
					ActionBar.EnableButton(BUT_COPY, Browser[1].SelectedRowCount > 0 || BrowserRepl[1].SelectedRowCount > 0);
					//>>Br:10.026.364
					ActionBar.EnableButton(BUT_ITEMPLAN, Browser[1].SelectedRowCount > 0 || BrowserRepl[1].SelectedRowCount > 0);
				}
			}
			else
			{
				//09.216.558 lohp17191 Make sure its only for Production orders, and not Internal Use screen as well.
				//add by chan24680 for br 09.216.558, for discontinue item for production order
				//user cannot select it.
				if (gProps.ModItemBrowser.gParentApp == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.INTERNAL_ORDER && (gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_FILLED || gProps.ModItemBrowser.gAppMode == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.TYPE_PROD_ALL))
				{
					//BR 23.801.919 - should allow to select discontinued item for PrO BOM lines (Make item line should be disallowed)
					//              - added gbAllowDiscontinued checking
					//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
					if (Convert.ToString(Browser[1].get_value("Item.Condition")) == GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.ITEM_STATUS_DISCONTINUED && !gProps.ModItemBrowser.gbAllowDiscontinued)
					{
						ActionBar.EnableButton(BUT_SELECT, false);
					}
					else
					{
						ActionBar.EnableButton(BUT_SELECT, bEnable);
					}
				}
				else
				{
					ActionBar.EnableButton(BUT_SELECT, bEnable);
				}
				ActionBar.EnableButton(BUT_CARD, bEnable);
				ActionBar.EnableButton(BUT_MRP, bEnable);
				ActionBar.EnableButton(BUT_COPY, bEnable);
				//>>Br:10.026.364
				ActionBar.EnableButton(BUT_ITEMPLAN, bEnable);
			}

			//'ngty@ TEMP only - remove the actual button later!!!
			ActionBar.get_Button(BUT_BYWAREHOUSE).Visible = false;


		}

		//ngty@ function returns TRUE if the edl is busy in a background fetch
		private bool IsEdlBusy()
		{
			bool result = false;
			try
			{ //BR 16.409.543 add error handler

				Exact.DataLayer.IEdlQuery qu = null;

				result = false;
				qu = (Exact.DataLayer.IEdlQuery) Browser[1].QueryObject;

				if (qu.BackgroundFetch((int) Exact.DataLayer.EdlBackgroundFetchOptions.edlInBackgroundFetch))
				{
					result = true;
				}

				qu = null;
			}
			catch
			{
				result = true;
			}

			return result;
		}

		private void SpawnItemCard()
		{
			Exact.SystemLayer.Interfaces.IValueSet vs = new Exact.SystemLayer.Common.ValueSet();
			string sItemCode = "";

			if (BrowserRepl[1].Visible && BrowserRepl[1].SelectedRowCount > 0)
			{
				//UPGRADE_WARNING: (1068) BrowserRepl().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				sItemCode = Convert.ToString(BrowserRepl[1].get_value("items.ItemCode"));
			}
			else
			{
				//UPGRADE_WARNING: (1068) Browser().Value() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				sItemCode = Convert.ToString(Browser[1].get_value("items.ItemCode"));
			}

			vs.Clear();

			vs.Add("record", sItemCode);

			if (m_Comp.GetOpt(OPT_COMPACT))
			{
				vs.Add("report", "B");
				vs.Add("GroupBy", "A");
			}
			else
			{
				vs.Add("report", "S");
				if (~((System.String.IsNullOrWhiteSpace(gProps.ModItemBrowser.gWareHs)) ? -1 : 0) != 0)
				{
					vs.Add("GroupBy", "A");

					// BR 12.626.697 - Warehouse code is wrongly pass in in item card
					if (!ItemFilter.IsWarehouseAll)
					{
						vs.Add("Filter1", "[magcode]");
						vs.Add("[magcode]", gProps.ModItemBrowser.gWareHs);
					}
				}
				else
				{
					vs.Add("GroupBy", "W");
				}
			}

			Exact.SystemLayer.Interfaces.ISpawner spnApp = (Exact.SystemLayer.Interfaces.ISpawner) Exact.SystemLayer.API.misc.GetApp();
			spnApp.Spawn("ESTKITEMCARD.EXE", Exact.SystemLayer.Interfaces.SpawnFlags.spawnContinue, m_Comp, null, vs); //ngty@ 05.138.046
			//gProps.ModItemBrowser.ForceToForeGround();
		}

		//BR 23.650.118 - store the navigation value for the sorting columns in m_sNavItemBrowserCol
		//              - so that the where clause could be built based on these values in case user navigate the record (next/ previous)
		private void StoreNavigateValue()
		{

			string[] arrCol = (string[]) m_sNavItemBrowserCol.Split(',');
			m_sNavItemBrowserVal = "";
			foreach (string arrCol_item in arrCol)
			{
				//UPGRADE_WARNING: (1068) Browser().RowValue() of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
				m_sNavItemBrowserVal = Convert.ToString(m_sNavItemBrowserVal) + Convert.ToString(Browser[1].get_RowValue(Browser[1].NumRows, arrCol_item)) + "#¿¢"; //BR 25.668.309 - When Sorting column containing "," in the data, then will cause RTE, thus change to use "#¿¢" in stead of ","
			}

			// When the user clicks on Next, push the last-row item onto the stack and then set
			// the last-row item as the starting point(by assigning to m_sNavItemBrowserVal)
			//UPGRADE_WARNING: (1068) m_sNavItemBrowserVal of type Variant is being forced to string. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068
			m_sNavItemBrowserVal = Convert.ToString(m_sNavItemBrowserVal).Substring(0, Math.Min((((m_sNavItemBrowserVal) is null) ? 0 : Convert.ToString(m_sNavItemBrowserVal).Length) - 1, Convert.ToString(m_sNavItemBrowserVal).Length));
			m_oStackItemNav.Push(m_sNavItemBrowserVal);
		}

		//FC 16.045.238 Item browser navigation
		//UPGRADE-WARNING: Parameter BtnClicked was changed from byref to byval.
		private void ItemFilter_NavButtonClick(Object Sender, ItemFilter.NavButtonClickEventArgs e)
		{
			GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton BtnClicked = e.BtnClicked;
			gBtnClicked = BtnClicked;
			switch(BtnClicked)
			{
				case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext : 

					 
					// When the user clicks on Next, push the last-row item onto the stack and then set 
					// the last-row item as the starting point(by assigning to m_sNavItemBrowserVal) 
					 
					//BR 23.650.118 - no result shown when pressing on <Next> button if user make use of "Add to sorting order" option 
					//              - use the new function "StoreNavigateValue" instead 
					StoreNavigateValue(); 
					//Call m_oStackItemNav.Push(Browser(1).RowValue(Browser(1).NumRows, m_sNavItemBrowserCol)) 
					//m_sNavItemBrowserVal = Browser(1).RowValue(Browser(1).NumRows, m_sNavItemBrowserCol) 
					 
					if (m_iMaxRows != ItemFilter.MaxRows)
					{
						m_iMaxRows = ItemFilter.MaxRows;
						m_oStackItemNav.Clear();
						//do not clear, else after changing row number and search, when click on next btn, the record won't nagivate
						//m_sNavItemBrowserVal = "": m_sNavItemBrowserCol = ""
					} 
					 
					RefreshBrowser(); 
					 
					//BR 16.297.817 
					DetermineNavBtnState(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.NEXTNAV_REFRESH); 
					 
					break;
				case GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious : 
					// Pop one item off the stack, and then retrieve the topmost item 
					m_oStackItemNav.Pop(); 
					//UPGRADE_WARNING: (1068) m_oStackItemNav.Value of type Variant is being forced to Scalar. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068 
					m_sNavItemBrowserVal = m_oStackItemNav.Value; 
					 
					RefreshBrowser(); 
					 
					// if the stack is empty, disable the Prev and enabled the Next 
					if (m_oStackItemNav.Size == 0)
					{
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);
					}
					else
					{
						ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, true);
					} 
					 
					//next button always enable when previous button is clicked 
					ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, true); 
					 
					break;
			}

			//FC 16.044.993 clear item info
			ClearAllValues(false);
		}

		public void Init(Exact.SystemLayer.Interfaces.IApplication vApp, Exact.SystemLayer.Interfaces.ITranslator vTerm, Exact.SystemLayer.Interfaces.ISettings vSett, Exact.DataLayer.IEdlConnection vConnection)
		{
			m_App = vApp;
			m_Term = vTerm;
			m_Comp = vApp.DefaultCompany;
			m_Conn = vConnection;

			m_gk = (Exact.SystemLayer.Interfaces.IGateKeeper)m_Comp.GateKeeper;
			m_Set = (Exact.SystemLayer.Interfaces.ISettings)m_Comp;
			ref_Renamed = m_Conn.CreateRef("Items", "ItemCode", "PictureFileName,Picture", Exact.DataLayer.LockModes.edlReadOnly);
			m_oStackItemNav = new clsStack(); //FC 16.045.238 Item browser navigation

			//BR41.204.403 tans285567 - Precision of prices is not rounded correctly
			m_CurCalc = m_Comp.CurrencyCalculator;

			GetSettings();

			LoadBrowser();

			ItemFilter.NoRefresh = true;

			hAncient = Exact.SystemLayer.API.Vsb.SetOldApiCompatibility(m_App, m_Comp);
			ItemFilter.ShowAssortment(!m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_STANDARD_EDITION)));
			lUserID = m_Comp.User.ID;

			//UPGRADE_WARNING: (2065) Form property frmMain.Controls has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2065
			//Exact.SystemLayer.API.CTL.InitControls(ContainerHelper.Controls(this), m_Term, m_App.DefaultCompany);
			//UPGRADE_WARNING: (2065) Form property frmMain.Controls has a new behavior. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2065
			m_App.ConnectControls(this.Controls, m_Comp, m_Term);

			SetFormCaptions();

			Exact.SystemLayer.API.misc.EfcSetAccessKeys(efc);
			ActionBar[BUT_CLOSE].Visible = true;

			//[jose276913 14-03-2011 16:10 (GMT +08:00)] 38.542.616
			if (m_Comp.GetOpt(Convert.ToInt16(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.Options.OPT_CENTRAL_MASTER_DATA)))
			{
				LoadObjCMDMToolsGeneral();
				bUseCentralData = m_oCMDMTools.UseCentralMasterData;
				m_oCMDMTools = null;
			}

			ResetItemBrowser(false);
			SetInitialSize();
		}

		//UPGRADE-WARNING: Parameter bForceFocus was changed from byref to byval.
		public void ResetItemBrowser(bool bForceFocus = true)
		{

			bShowReplaceBrowser = false;

			Initializeflags();
			SetFormControlColors();
			//SetFonts();
			FillCaptions();
			SetButtonVisibility();
			SetItemInfoVisibility();
			FillDefaulFilterValues(true);

			RefreshBrowser();

			//FC 16.045.238 Item browser navigation
			ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnPrevious, false);

			if (Browser[1].NumRows == 0)
			{
				ItemFilter.EnableNavButton(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.NavButton.btnNext, false);
			}
			else
			{
				//BR 16.297.817
				DetermineNavBtnState(GlobalInterfaces.GI_Exact.Inventory.ItemBrowser.modItemBrowser.SEARCH_REFRESH);
			}

			m_iMaxRows = ItemFilter.MaxRows;

			ItemFilter.NoRefresh = false;

			//BR 16.297.817 set tab index for browser(1) = browser(0) here and not in loadbrowser() else will not set properly
			Browser[1].TabIndex = 3; //Browser(0).TabIndex
			BrowserRepl[1].TabIndex = 4; //BrowserRepl(0).TabIndex

			if (gProps.ModItemBrowser.gbMultiSelect)
			{
				Browser[1].SelectRow(1, true);
				Browser[1].CurrentRow = 1;
			}
			else
			{
				Browser[1].CurrentRow = 1;
			}

			//BR 23.389.323 Focus issue
			if (System.String.IsNullOrWhiteSpace(gProps.ModItemBrowser.gSelectArtCd))
			{
				return;
			}

			//br: 21.126.896
			if (bForceFocus && Browser[1].NumRows > 0)
			{
				Exact.SystemLayer.Common.PInvoke.SafeNative.user32.SetFocus(pnlMainBrowser.Handle); ;
				Exact.SystemLayer.Common.PInvoke.SafeNative.user32.SetFocus(Browser[1].Handle);
				SendKeys.SendWait("\t");
			}

		}
		protected override void DestroyHandle()
		{
			if (!Modal || Disposing)
				base.DestroyHandle();
		}

		private void ItemFilter_ReassignHotKeys(Object Sender, EventArgs e)
		{
			Exact.SystemLayer.Interfaces.IHotKeys H = m_App.HotKeys(this.Handle);
			H.Initialize(this.Handle, m_Term);
			H.MarkAll();
			H.Assign();
			H = null;
		}
		//[jose276913 14-03-2011 16:10 (GMT +08:00)] 38.542.616
		//Initialisation of CMDM tools.
		private void LoadObjCMDMToolsGeneral()
		{
			if (m_oCMDMTools is null)
			{
				m_oCMDMTools = GlobalInterfaces.Factory.CreateInstance<GlobalInterfaces.GI_Exact.Cmdm.Tools.IclsGeneral>();

				m_App.ConnectObject(m_oCMDMTools, m_Comp, m_Term);
				m_oCMDMTools.Topic = gsCMDMTopicItem;
			}
		}
		static internal void Helper_DisposeArray<T>(ref T[] array)
		{
			if (array == null) return;
			foreach (T element in array)
			{
				(element as IDisposable)?.Dispose();
			}
			Array.Clear(array, 0, array.Length);
			array = null;
		}
		private void UnwireEvents()
        {
			this.ActionBar.ButtonClick -= this.actActionBar_ButtonClick;
			this._fbCommand_1.Click -= this.fbCommand_Click;
			this._fbCommand_0.Click -= this.fbCommand_Click;
			if (_BrowserRepl_0 != null)
			{
				this._BrowserRepl_0.RowChanged -= this.BrowserRepl_RowChanged;
				this._BrowserRepl_0.Selected -= this.BrowserRepl_Selected;
				this._BrowserRepl_0.SelectionChanged -= this.BrowserRepl_SelectionChanged;
			}
			if (_Browser_0 != null)
            {
				this._Browser_0.ColumnsChanged -= this.Browser_ColumnsChanged;
				this._Browser_0.RowsetFetched -= this.Browser_RowsetFetched;
				this._Browser_0.Selected -= this.Browser_Selected;
				this._Browser_0.SelectionChanged -= this.Browser_SelectionChanged;
			}
			this.cmdSerialBatch.Click -= this.cmdSerialBatch_Click;
			if (ItemFilter != null)
            {
				this.ItemFilter.Expand -= this.ItemFilter_Expand;
				this.ItemFilter.ExpandProperty -= this.ItemFilter_ExpandProperty;
				this.ItemFilter.ForceFocus -= this.ItemFilter_ForceFocus;
				this.ItemFilter.ForceRefresh -= this.ItemFilter_ForceRefresh;
				this.ItemFilter.NavButtonClick -= this.ItemFilter_NavButtonClick;
				this.ItemFilter.ReassignHotKeys -= this.ItemFilter_ReassignHotKeys;
			}
			//this.Activated -= this.Form_Activated;
			this.Closed -= this.Form_Closed;
			this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.Form_FormClosing);
			this.Resize -= this.Form_Resize;
		}
		private bool _disposing = false;
		private bool _frmMainDisposed = false;
		protected override void Dispose(bool disposing)
		{
			if (!_frmMainDisposed && disposing && !_disposing)
			{
				_disposing = true;
				this.Close();

				UnwireEvents();
				Events?.Dispose();
				gProps = null;
				m_maint = null;
				ref_Renamed?.Dispose();
				ref_Renamed = null;
				m = null;
				m_App = null;
				m_Comp = null;
				m_Term = null;
				m_Set = null;
				m_Conn = null;
				m_gk = null;
				m_CurCalc = null;
				gObjSerialBatch = null;
				mObjWareH = null;
				mObjStkQty = null;
				m_oStackItemNav = null;
				m_oCMDMTools = null;

				ActionBar?.Dispose();
				ActionBar = null;
				ExactMenu?.Dispose();
				ExactMenu = null;
				TitleBar?.Dispose();
				Icon?.Dispose();
				Icon = null;
				StatusBar?.Dispose();
				StatusBar = null;

				frmMain.Helper_DisposeArray(ref visualControls);
				frmMain.Helper_DisposeArray(ref Browser);
				frmMain.Helper_DisposeArray(ref BrowserRepl);
				frmMain.Helper_DisposeArray(ref fbCommand);
				frmMain.Helper_DisposeArray(ref fipInfo);
				frmMain.Helper_DisposeArray(ref lblWInfoHeader);
				frmMain.Helper_DisposeArray(ref mnuMenu);
				components?.Dispose();
				ToolTipMain?.Dispose();
				_mnuMenu_0?.Dispose();
				_mnuMenu_1?.Dispose();
				_mnuMenu_2?.Dispose();
				_mnuMenu_3?.Dispose();
				_mnuMenu_4?.Dispose();
				_mnuMenu_5?.Dispose();
				_mnuMenu_6?.Dispose();
				_mnuMenu_7?.Dispose();
				_mnuMenu_8?.Dispose();
				_mnuMenu_9?.Dispose();
				_mnuMenu_10?.Dispose();
				_mnuMenu_11?.Dispose();
				_mnuMenu_12?.Dispose();
				_mnuMenu_13?.Dispose();
				_mnuMenu_14?.Dispose();
				_mnuMenu_15?.Dispose();
				_mnuMenu_16?.Dispose();
				_mnuMenu_17?.Dispose();
				mnuShortcut?.Dispose();
				MainMenu1?.Dispose();
				efc?.Dispose();
				_fbCommand_1?.Dispose();
				_fbCommand_0?.Dispose();
				_BrowserRepl_0?.Dispose();
				sepReplace?.Dispose();
				pnlReplaceBrowser?.Dispose();
				_Browser_0?.Dispose();
				pnlMainBrowser?.Dispose();
				_fipInfo_0?.Dispose();
				_fipInfo_1?.Dispose();
				_fipInfo_3?.Dispose();
				_fipInfo_2?.Dispose();
				cmdSerialBatch?.Dispose();
				_lblWInfoHeader_4?.Dispose();
				_lblWInfoHeader_2?.Dispose();
				_lblWInfoHeader_1?.Dispose();
				_lblWInfoHeader_0?.Dispose();
				_lblWInfoHeader_3?.Dispose();
				imgPicture?.Dispose();
				pnlItemInfo?.Dispose();
				ItemFilter?.Dispose();
				pnlMain?.Dispose();

				components = null;
				ToolTipMain = null;
				_mnuMenu_0 = null;
				_mnuMenu_1 = null;
				_mnuMenu_2 = null;
				_mnuMenu_3 = null;
				_mnuMenu_4 = null;
				_mnuMenu_5 = null;
				_mnuMenu_6 = null;
				_mnuMenu_7 = null;
				_mnuMenu_8 = null;
				_mnuMenu_9 = null;
				_mnuMenu_10 = null;
				_mnuMenu_11 = null;
				_mnuMenu_12 = null;
				_mnuMenu_13 = null;
				_mnuMenu_14 = null;
				_mnuMenu_15 = null;
				_mnuMenu_16 = null;
				_mnuMenu_17 = null;
				mnuShortcut = null;
				MainMenu1 = null;
				efc = null;
				_fbCommand_1 = null;
				_fbCommand_0 = null;
				_BrowserRepl_0 = null;
				sepReplace = null;
				pnlReplaceBrowser = null;
				_Browser_0 = null;
				pnlMainBrowser = null;
				_fipInfo_0 = null;
				_fipInfo_1 = null;
				_fipInfo_3 = null;
				_fipInfo_2 = null;
				cmdSerialBatch = null;
				_lblWInfoHeader_4 = null;
				_lblWInfoHeader_2 = null;
				_lblWInfoHeader_1 = null;
				_lblWInfoHeader_0 = null;
				_lblWInfoHeader_3 = null;
				imgPicture = null;
				pnlItemInfo = null;
				ItemFilter = null;
				pnlMain = null;

				_frmMainDisposed = true;
			}
			base.Dispose(disposing);
		}		
    }
}