/// <summary> /// Busca Filial Padrão /// </summary> /// <returns>Id Filial Padrão</returns> public static int GetCurrentBPlId() { // FH: unica solucao encontrada no forum foi buscar a string da tela para pegar a filial selecionada. SAPbouiCOM.Forms forms = SBOApp.Application.Forms; int formType = 169; int bplId = 0; for (int I = 0; I < forms.Count; I++) { if (forms.Item(I).Type == formType) { Form form = forms.Item(I); string bplName = ((StaticText)form.Items.Item(6).Specific).Caption; if (bplName.Contains("Filial: ")) { bplName = bplName.Substring(bplName.IndexOf("Filial: ")); bplName = bplName.Replace("Filial: ", String.Empty); Recordset rsBpl = (Recordset)SBOApp.Company.GetBusinessObject(BoObjectTypes.BoRecordset); string sql = " SELECT BPlId FROM OBPL WHERE BPLName = '{0}' "; sql = String.Format(sql, bplName); sql = SBOApp.TranslateToHana(sql); rsBpl.DoQuery(sql); if (rsBpl.RecordCount > 0) { bplId = Convert.ToInt32(rsBpl.Fields.Item(0).Value); } else { bplId = 1; } Marshal.ReleaseComObject(rsBpl); rsBpl = null; GC.Collect(); } break; } } return(bplId); }
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); } }