// Hook event
		public void Init(IslAppContext appContext, IslsForm form)
		{
			switch (form.GetType().ToString())
			{
				case "Glx.WUI.CO.CommercialEntry.gxPurchaseEntryF":
					_appContext = appContext;
					_form = form;
					(_form as gxPurchaseEntryF).Items.PreviewPropertyChanged += new EventHandler<slEventArgs<slPreviewPropChangedArgs>>(Items_PreviewPropertyChanged);
					break;
				default:
					break;

			}
		}
        // Hook event
        public void Init(IslAppContext appContext, IslsForm form)
        {
            switch (form.GetType().ToString())
            {
                case "Glx.WUI.CO.CommercialEntry.gxSalesEntryF":

                    _form = form;
                    _appContext = appContext;
                    (_form as gxSalesEntryF).Items.PreviewPropertyChanged += Items_PreviewPropertyChanged;
                    break;
                default:
                    break;

            }
        }
		// Add custom action to user menu
		public Dictionary<string, string> GetLinks(IslAppContext appContext, IslsForm form)
		{
			Dictionary<string, string> dc = null;
			switch (form.GetType().ToString())
			{
				case "Glx.WUI.CO.CommercialEntry.gxSalesEntryF":
				case "Glx.WUI.CO.CommercialEntry.gxPurchaseEntryF":
					dc = new Dictionary<string, string>();
					dc.Add(cmdSNEntry, infnvObjectNames.sObjSNEntry);
                    dc.Add(cmdSNEntryExcel, infnvObjectNames.sObjSNEntry + " - " + infnvResources.sEntryExcel);
					break;
				case "Glx.WUI.CO.ItemEntry.gxItemEntryF":
					dc = new Dictionary<string, string>();
					dc.Add(cmdSNEntry, infnvObjectNames.sObjSNEntry);
					dc.Add(cmdSNEntryComposite, infnvObjectNames.sObjSNEntry + " - " + infnvResources.sComposite);
                    dc.Add(cmdSNEntryExcel, infnvObjectNames.sObjSNEntry + " - " + infnvResources.sEntryExcel);
                    dc.Add(cmdSNEntryExcelComposite, infnvObjectNames.sObjSNEntry + " - " + infnvResources.sEntryExcelComposite);
					break;
				default:
					break;
			}
			return dc;
		}
 public Dictionary<string, string> GetLinks(IslAppContext appContext, IslsForm form)
 {
     Dictionary<string, string> dc = null;
     return dc;
 }
 public void ExecuteLink(IslAppContext appContext, IslsForm form, string command) { }
 public void Create(IslAppContext appContext, IslsForm form) { }
 public void SyncScreen(IslAppContext appContext, IslsForm form) { }
		// Handle custom action execution
		public void ExecuteLink(IslAppContext appContext, IslsForm form, string command)
		{
			switch (form.GetType().ToString())
			{
				case "Glx.WUI.CO.CommercialEntry.gxSalesEntryF":
				case "Glx.WUI.CO.CommercialEntry.gxPurchaseEntryF":
					if (command == cmdSNEntry)
					{
						// Get commercail entry lines collection current item
						var bsCenl = slsBaseF.GetDataSources(form)["bsItemLines"];
						if (bsCenl.Current != null)
						{
							var cenlObj = (bsCenl.Current as slObjectView<gxCommercEntryLinesDataObject>).DataObjectItem;
							if (cenlObj != null)
							{
								// Prepare args
								var fArgs = new slsFormArgs();
								fArgs.NamedArgs["Item"] = String.Format("{0} - {1}", cenlObj.ItemCode, cenlObj.ItemDescr);

								// Open form
								var fa = appContext.ServiceLocator.GetService<IslsFormActivator>();
								using (var f = fa.CreateForm(infnvSys.GetRegName(infnvObjRegName.SNEntry), fArgs))
									if (f.ShowDialog(form) == slsDialogResult.OK)
									{
										var entries = (f as infnvSNEntryF).Entries;
										foreach (var item in entries)
											AddSerialNumber(cenlObj, appContext, item);
									}
							}
						}
					}
                    else if (command == cmdSNEntryExcel)
                    {
                        // Get commercail entry lines collection current item
                        var bsCenl = slsBaseF.GetDataSources(form)["bsItemLines"];
                        if (bsCenl.Current != null)
                        {
                            var cenlObj = (bsCenl.Current as slObjectView<gxCommercEntryLinesDataObject>).DataObjectItem;
                            if (cenlObj != null)
                            {
                                // Prepare args
                                var fArgs = new slsFormArgs();
                                fArgs.NamedArgs["Item"] = String.Format("{0} - {1}", cenlObj.ItemCode, cenlObj.ItemDescr);

                                // Select file
                                var path = GetFilePath();
                                if (path !=String.Empty)
                                {
                                    var list = PopulateFromXls(path);
                                    foreach(var sn in list)
                                    {
                                        AddSerialNumber(cenlObj, appContext, sn);
                                    }
                                }
                            }
                        }
                    }
					break;
				case "Glx.WUI.CO.ItemEntry.gxItemEntryF":
					if (command == cmdSNEntry || command == cmdSNEntryComposite)
					{
						// Get commercail entry lines collection current item
						var bsIenl = slsBaseF.GetDataSources(form)["bsItemLines"];
						if (bsIenl.Current != null)
						{
							gxItemEntryLinesDataObject ienlObj = null;
							if (command == cmdSNEntry)
								ienlObj = (bsIenl.Current as slObjectView<gxItemEntryLinesDataObject>).DataObjectItem;
							if (command == cmdSNEntryComposite)
							{
								var col = (bsIenl.DataSource as slBindingCollectionView<gxItemEntryLinesDataObject>).Collection as gxItemEntryLinesCollection;
								ienlObj = col.Find(i => i.Linenum == -1);
							}
							if (ienlObj != null)
							{
								// Prepare args
								var fArgs = new slsFormArgs();
								fArgs.NamedArgs["Item"] = String.Format("{0} - {1}", ienlObj.ItemCode, ienlObj.ItemDescr);

								// Open form
								var fa = appContext.ServiceLocator.GetService<IslsFormActivator>();
								using (var f = fa.CreateForm(infnvSys.GetRegName(infnvObjRegName.SNEntry), fArgs))
									if (f.ShowDialog(form) == slsDialogResult.OK)
									{
										var entries = (f as infnvSNEntryF).Entries;
										foreach (var item in entries)
											AddSerialNumber(ienlObj, appContext, item);
									}
							}
						}
					}
                    else if (command == cmdSNEntryExcel || command == cmdSNEntryExcelComposite)
                    {
                        // Get commercail entry lines collection current item
                        var bsIenl = slsBaseF.GetDataSources(form)["bsItemLines"];
                        if (bsIenl.Current != null)
                        {
                            gxItemEntryLinesDataObject ienlObj = null;
                            //var ienlObj = (bsIenl.Current as slObjectView<gxItemEntryLinesDataObject>).DataObjectItem;
                            if (command == cmdSNEntryExcel)
                                ienlObj = (bsIenl.Current as slObjectView<gxItemEntryLinesDataObject>).DataObjectItem;
                            if (command == cmdSNEntryExcelComposite)
                            {
                                var col = (bsIenl.DataSource as slBindingCollectionView<gxItemEntryLinesDataObject>).Collection as gxItemEntryLinesCollection;
                                ienlObj = col.Find(i => i.Linenum == -1);
                            }
                            if (ienlObj != null)
                            {
                                // Prepare args
                                var fArgs = new slsFormArgs();
                                fArgs.NamedArgs["Item"] = String.Format("{0} - {1}", ienlObj.ItemCode, ienlObj.ItemDescr);

                                // Select file
                                var path = GetFilePath();
                                if (path !=String.Empty)
                                {
                                    var list = PopulateFromXls(path);
                                    foreach (var sn in list)
                                    {
                                        AddSerialNumber(ienlObj, appContext, sn);
                                    }
                                }
                                
                            }
                        }
                    }
					break;
				default:
					break;
			}
		}