public void GetApplicationMenuEvent(ref SAPbouiCOM.MenuEvent pObjMenuEvent, out bool pObjBubbleEvent) { pObjBubbleEvent = true; try { if (pObjMenuEvent.BeforeAction) { //Get menu unique id //string lStrMenuUID = pObjMenuEvent.MenuUID; //If is a section //if(Menu.SelectMany(m=> m.Sections).Where(s=> s.UniqueID == lStrMenuUID).Count() > 0) //{ // //Get section // Section lObjSection = Menu.SelectMany(m=> m.Sections).FirstOrDefault(s=> s.UniqueID == lStrMenuUID); // //Is valid form // if(lObjSection.Form != null) // { // lObjSection.Form. // } //} switch (pObjMenuEvent.MenuUID) { case "TicketForm": bool lBolIsOpen = false; SAPbouiCOM.Forms lObjForms = UIApplication.GetApplication().Forms; foreach (Form lObjForm in lObjForms) { if (lObjForm.TypeEx == "UGRS.PlantaAlimentos.Forms.TicketForm" && lObjForm.Visible) { lBolIsOpen = true; } } if (!lBolIsOpen) { TicketForm lObjTicketForm = new TicketForm(); lObjTicketForm.UIAPIRawForm.Left = GetLeftMargin(lObjTicketForm.UIAPIRawForm); lObjTicketForm.UIAPIRawForm.Top = GetTopMargin(lObjTicketForm.UIAPIRawForm); lObjTicketForm.Show(); } else { UIApplication.ShowMessageBox("Ya se tiene abierta una ventana de tickets"); } break; case "TicketsListForm": TicketsListForm lObjTicketsListFrm = new TicketsListForm(); lObjTicketsListFrm.UIAPIRawForm.Left = GetLeftMargin(lObjTicketsListFrm.UIAPIRawForm); lObjTicketsListFrm.UIAPIRawForm.Top = GetTopMargin(lObjTicketsListFrm.UIAPIRawForm); lObjTicketsListFrm.Show(); break; //case "ReceptionForm": // ReceptionForm lObjReceptionFrm = new ReceptionForm(); // lObjReceptionFrm.UIAPIRawForm.Left = GetLeftMargin(lObjReceptionFrm.UIAPIRawForm); // lObjReceptionFrm.UIAPIRawForm.Top = GetTopMargin(lObjReceptionFrm.UIAPIRawForm); // lObjReceptionFrm.Show(); //DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); //Application.SBO_Application.Company //ReceptionForm lObjReceptionFrm = new ReceptionForm(UI.UIApplication.Company); break; } } } catch (Exception ex) { LogService.WriteError(ex.Message); LogService.WriteError(ex); UIApplication.ShowError(string.Format("MenuException: {0}", ex.Message)); UIApplication.ShowMessageBox(ex.Message); } }
public void GetApplicationMenuEvent(ref SAPbouiCOM.MenuEvent pObjMenuEvent, out bool pObjBubbleEvent) { pObjBubbleEvent = true; try { if (pObjMenuEvent.BeforeAction) { //Get menu unique id //string lStrMenuUID = pObjMenuEvent.MenuUID; //If is a section //if(Menu.SelectMany(m=> m.Sections).Where(s=> s.UniqueID == lStrMenuUID).Count() > 0) //{ // //Get section // Section lObjSection = Menu.SelectMany(m=> m.Sections).FirstOrDefault(s=> s.UniqueID == lStrMenuUID); // //Is valid form // if(lObjSection.Form != null) // { // lObjSection.Form. // } //} switch (pObjMenuEvent.MenuUID) { case "TicketForm": TicketForm lObjTicketForm = new TicketForm(); lObjTicketForm.UIAPIRawForm.Left = GetLeftMargin(lObjTicketForm.UIAPIRawForm); lObjTicketForm.UIAPIRawForm.Top = GetTopMargin(lObjTicketForm.UIAPIRawForm); lObjTicketForm.Show(); break; case "TicketsListForm": TicketsListForm lObjTicketsListFrm = new TicketsListForm(); lObjTicketsListFrm.UIAPIRawForm.Left = GetLeftMargin(lObjTicketsListFrm.UIAPIRawForm); lObjTicketsListFrm.UIAPIRawForm.Top = GetTopMargin(lObjTicketsListFrm.UIAPIRawForm); lObjTicketsListFrm.Show(); break; case "ReceptionForm": ReceptionForm lObjReceptionFrm = new ReceptionForm(); lObjReceptionFrm.UIAPIRawForm.Left = GetLeftMargin(lObjReceptionFrm.UIAPIRawForm); lObjReceptionFrm.UIAPIRawForm.Top = GetTopMargin(lObjReceptionFrm.UIAPIRawForm); lObjReceptionFrm.Show(); //DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); //Application.SBO_Application.Company //ReceptionForm lObjReceptionFrm = new ReceptionForm(UI.UIApplication.Company); break; } } } catch (Exception ex) { LogService.WriteError(ex.Message); LogService.WriteError(ex); UIApplication.ShowError(string.Format("MenuException: {0}", ex.Message)); UIApplication.ShowMessageBox(ex.Message); } }