public override void CreateForm(SAPbouiCOM.Application SboApp, string strXml, SAPbobsCOM.Company cmp, string frmId) { base.CreateForm(SboApp, strXml, cmp, frmId); oForm.EnableMenu("1282", false); // Add New Record oForm.EnableMenu("1288", false); // Next Record oForm.EnableMenu("1289", false); // Pevious Record oForm.EnableMenu("1290", false); // First Record oForm.EnableMenu("1291", false); // Last record oForm.EnableMenu("1281", false); // Find record InitiallizeForm(); SAPbouiCOM.Menus mnus = oApplication.Menus.Item("43557").SubMenus; foreach (SAPbouiCOM.MenuItem mnu in mnus) { string menuTitel = mnu.String; if (menuTitel == "Inspection Report") { printMenuId = mnu.UID.ToString(); } } // oForm.Items.Item("btUpd").Visible = false; }
public static void AddMenuItemContext(string uniqueId, string descricao, int posicao) { SAPbouiCOM.MenuItem oMenuItem = null; SAPbouiCOM.Menus oMenus = null; try { SAPbouiCOM.MenuCreationParams oCreationPackage = null; oCreationPackage = ((SAPbouiCOM.MenuCreationParams)(B1AppDomain.Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams))); oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING; oCreationPackage.UniqueID = uniqueId; oCreationPackage.String = descricao; oCreationPackage.Enabled = true; oCreationPackage.Position = posicao; oMenuItem = B1AppDomain.Application.Menus.Item("1280"); // Data' oMenus = oMenuItem.SubMenus; oMenus.AddEx(oCreationPackage); } catch { } }
private void loadMenu(string lang) { SAPbouiCOM.Menus mnus = oApplication.Menus; if (mnus.Exists("mnu_DRSC")) { mnus.RemoveEx("mnu_DRSC"); } mnus.Item("2048").SubMenus.Add("mnu_DRSC", "Reschedule Reserve Invoice", BoMenuType.mt_STRING, 47646); }
/** * Adiciona um item de menu em um menu ja existente ou adicionado. * * * menuItemB1ID Id do menu pai onde o item de menu devera ser inserido * menuItemDescr Texto do item de menu * menuItemID ID do item de menu que esta sendo criado * position posicao na lista de itens dentro de um menu * type tipo... * imagePath caminho para o arquivo de imagem a ser utilizado como icone no menu * */ public static void AddMenuItem(string menuItemB1ID, string menuItemDescr, string menuItemID , int position, BoMenuType type, string imagePath = "", bool remove = true) { SAPbouiCOM.Menus oMenus = null; SAPbouiCOM.MenuItem oMenuItem = null; SAPbouiCOM.MenuCreationParams oCreationPackage = null; oCreationPackage = ((SAPbouiCOM.MenuCreationParams)(B1AppDomain.Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams))); oMenuItem = B1AppDomain.Application.Menus.Item(menuItemB1ID); oMenus = oMenuItem.SubMenus; bool exist = (oMenus != null) && oMenuItem.SubMenus.Exists(menuItemID); if (exist && remove) { oMenuItem.SubMenus.RemoveEx(menuItemID); exist = false; } else { exist = false; } if (!(exist && remove)) { oCreationPackage.Type = type; oCreationPackage.UniqueID = menuItemID; oCreationPackage.String = menuItemDescr; oCreationPackage.Enabled = true; oCreationPackage.Position = position; //posição onde vai criar o modulo oCreationPackage.Image = imagePath; try { if (oMenus == null) { oMenuItem.SubMenus.Add(menuItemID, menuItemDescr, type, position); oMenus = oMenuItem.SubMenus; } oMenus.AddEx(oCreationPackage); } catch (Exception ex) { // B1Exception.throwException("Erro ao criar Menu ::", ex); } } }
private void AddMenuItems() { SAPbouiCOM.Menus oMenus = null; SAPbouiCOM.MenuItem oMenuItem = null; int i = 0; int iAddAfter = 0; string sXML = null; string sPath = null; oMenus = oApplication.Menus; SAPbouiCOM.MenuCreationParams oMenuCreationParams = null; oMenuCreationParams = (SAPbouiCOM.MenuCreationParams)(oApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)); oMenuItem = oApplication.Menus.Item("43520"); sPath = Application.StartupPath; //sPath = sPath.Remove(sPath.Length - 9, 0); oMenuCreationParams.Type = BoMenuType.mt_POPUP; oMenuCreationParams.UniqueID = "menu01"; oMenuCreationParams.String = "Menu Exemplo"; oMenuCreationParams.Enabled = true; oMenuCreationParams.Image = sPath + @"\\UI.bmp"; oMenuCreationParams.Position = 99; oMenus = oMenuItem.SubMenus; try { oMenus.AddEx(oMenuCreationParams); oMenuItem = oApplication.Menus.Item("menu01"); oMenus = oMenuItem.SubMenus; oMenuCreationParams.Type = BoMenuType.mt_STRING; oMenuCreationParams.UniqueID = "menu02"; oMenuCreationParams.String = "Sub Menu Exemplo"; oMenus.AddEx(oMenuCreationParams); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
public override void initApp() { String XlsFile; String s; base.initApp(); String Local; Boolean bCargar = false; try { // compilacion SQL HANA GlobalSettings.SBO_f = SBOFunctions; GlobalSettings.SBOMeta = SBOMetaData; // //oLog.LogFile = "C:\\Visualk\\xxx.log"; oLog.LogFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\VD.log"; SAPbobsCOM.Recordset oRecordSet; oRecordSet = (SAPbobsCOM.Recordset)(SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)); try { if (GlobalSettings.RunningUnderSQLServer) { s = "SELECT SUPERUSER FROM OUSR WHERE USER_CODE = '{0}'"; } else { s = @"SELECT ""SUPERUSER"" FROM ""OUSR"" WHERE ""USER_CODE"" = '{0}'"; } s = String.Format(s, SBOCompany.UserName.Trim()); oRecordSet.DoQuery(s); if (((System.String)oRecordSet.Fields.Item("SUPERUSER").Value).Trim() == "Y") { bCargar = true; } } catch { if (bCargar == false) { SBOApplication.MessageBox("El addon se esta iniciando por primera vez, debe inicar con un super usuario"); } } finally { SBOFunctions._ReleaseCOMObject(oRecordSet); oRecordSet = null; } //if (SBOCompany.UserName == "manager") if (bCargar) { XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFFELEC.xls"; if (!SBOFunctions.ValidEstructSHA1(XlsFile)) { oLog.OutLog("InitApp: Estructura de datos 1 - Facturación Electronica"); SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(1).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile)) { SBOFunctions.DeleteSHA1FromTable("EDAG.xls"); oLog.OutLog("InitApp: sincronización de Estructura de datos fallo"); CloseSplash(); SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", ""); Halt(0); } } XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFFELECCL.xls"; if (!SBOFunctions.ValidEstructSHA1(XlsFile)) { oLog.OutLog("InitApp: Estructura de datos 2 - Facturación Electronica CL"); SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(2).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile)) { SBOFunctions.DeleteSHA1FromTable("UDFFELECCL.xls"); oLog.OutLog("InitApp: sincronización de Estructura de datos fallo"); SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", ""); } } XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFSAP.xls"; if (!SBOFunctions.ValidEstructSHA1(XlsFile)) { oLog.OutLog("InitApp: Estructura de datos 3 - Facturación Electronica CL"); SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(3).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile)) { SBOFunctions.DeleteSHA1FromTable("UDFSAP.xls"); oLog.OutLog("InitApp: sincronización de Estructura de datos fallo"); SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", ""); } } } oLog.DebugLvl = 20; MainObj[0].GlobalSettings = GlobalSettings; MainObj[0].SBOApplication = SBOApplication; MainObj[0].SBOCompany = SBOCompany; MainObj[0].oLog = oLog; MainObj[0].SBOFunctions = SBOFunctions; //SetFiltros(); MainObj[0].AddMenus(); InitOK = true; oLog.OutLog("App SBO in C# - Init!"); SBOApplication.StatusBar.SetText("Aplicación Inicializada.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); if (1 == 1) //(SBOFunctions.AccessStr.Substring(10,1) = 'P') then { GlobalSettings.SBO_f = SBOFunctions; MainObj[0].GlobalSettings = GlobalSettings; MainObj[0].SBOApplication = SBOApplication; MainObj[0].SBOCompany = SBOCompany; MainObj[0].oLog = oLog; MainObj[0].SBOFunctions = SBOFunctions; } SetFiltros(); if (1 == 1) // (SBOFunctions.AccessStr.Substring(10,1) = 'P') then { //MainObj[0].AddMenus(); SAPbouiCOM.Menus oMenus = null; SAPbouiCOM.MenuItem oMenuItem = null; System.Xml.XmlDocument oXmlDoc = null; oXmlDoc = new System.Xml.XmlDocument(); oXmlDoc.Load(System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Menus\\RemoveMenu.xml"); string sXML = oXmlDoc.InnerXml.ToString(); SBOApplication.LoadBatchActions(ref sXML); oXmlDoc.Load(System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Menus\\Menu.xml"); sXML = oXmlDoc.InnerXml.ToString(); SBOApplication.LoadBatchActions(ref sXML); //GlobalSettings.AddMenusRepAux(False); //GlobalSettings.AddMenusRepAux(True); } InitOK = true; oLog.OutLog("C# - Shine your crazy diamond!"); SBOApplication.StatusBar.SetText("Aplicación Inicializada.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); } catch (Exception ex) { oLog.OutLog("Error iniApp, " + ex.Message + ", TRACE " + ex.StackTrace); } finally { CloseSplash(); } }
public override void etAfterActClick(ref ItemEvent pVal, ref bool BubbleEvent) { base.etAfterActClick(ref pVal, ref BubbleEvent); if (pVal.ItemUID == "btFinal") { int confirm = oApplication.MessageBox("Are you sure you want to post stock?", 2, "Yes", "No"); if (confirm == 1) { int postingStatus = -1; int trsnsferResult = -1; int selRow = mtSelRow(mtDocs); if (selRow > 0) { string strCode = Convert.ToString(dtDoc.GetValue("OT", selRow - 1)); string dn = Convert.ToString(dtDoc.GetValue("DE", selRow - 1)); string docType = Convert.ToString(dtDoc.GetValue("DT", selRow - 1)); if (docType == "Offer for Inspection") { string strProdNum = "SELECT \"U_B1_QA_INSP_PN\" FROM \"OIGN\" WHERE \"DocEntry\" ='" + dn + "'"; System.Data.DataTable dtProdNum = Program.objHrmsUI.getDataTable(strProdNum, "ProdNum"); if (dtProdNum != null && dtProdNum.Rows.Count > 0) { if (dtProdNum.Rows[0]["U_B1_QA_INSP_PN"] != DBNull.Value && Convert.ToInt32(dtProdNum.Rows[0]["U_B1_QA_INSP_PN"]) > 0) { postingStatus = ReleaseInspaction(dn); } } } else { postingStatus = PostTransfer(strCode, dn); } string strDocCode = strCode + "-" + dn; if (strCode.Trim() != "" && postingStatus != -1) { string strInsert = "UPDATE \"@B1_QA_DOC\" SET \"U_Date\" = '" + DateTime.Now.ToString("yyyyMMdd") + "' , \"U_Final\"='Y' , \"U_WTRentry\" = '" + postingStatus + "' WHERE \"Code\" = '" + strDocCode + "'"; Program.objHrmsUI.ExecQuery(strInsert, "Finalllizing Inspaction"); } } // _iniForm(); getDocs(); } } if (pVal.ItemUID == "btPrint") { SAPbouiCOM.Menus mnus = oApplication.Menus; if (mnus.Exists(printMenuId) && printMenuId != "") { int selRow = mtSelRow(mtDocs); string strCode = Convert.ToString(dtDoc.GetValue("OT", selRow - 1)); string dn = Convert.ToString(dtDoc.GetValue("DE", selRow - 1)); mnus.Item(printMenuId).Activate(); SAPbouiCOM.Form prmForm = oApplication.Forms.ActiveForm; EditText objType = (SAPbouiCOM.EditText)prmForm.Items.Item("1000003").Specific; EditText DocKey = (SAPbouiCOM.EditText)prmForm.Items.Item("1000009").Specific; SAPbouiCOM.Button ok = (SAPbouiCOM.Button)prmForm.Items.Item("1").Specific; // SAPbouiCOM.Button cancel = (SAPbouiCOM.Button)prmForm.Items.Item("2").Specific; objType.Value = strCode; DocKey.Value = dn; prmForm.ActiveItem = ok.Item.UniqueID; objType.Item.Enabled = false; // DocKey.Item.Enabled = false; ok.Item.Click(); // prmForm.Select(); // cancel.Item.Click(); } else { oApplication.MessageBox("Please upload \"Inspection Report\" in production report menu"); } } if (pVal.ItemUID == "txAtt") { try { // txAtt.ClickPicker(); System.Diagnostics.Process.Start(dtHead.GetValue("Att", 0).ToString()); } catch (Exception ex) { string errmsg = ex.Message; } } if (pVal.ItemUID == btAtt.Item.UniqueID) { string strFileName = Program.objHrmsUI.addAttacment(""); if (strFileName != "") { dtHead.SetValue("Att", 0, strFileName); int selRow = mtSelRow(mtDocs); string strCode = Convert.ToString(dtDoc.GetValue("OT", selRow - 1)); string dn = Convert.ToString(dtDoc.GetValue("DE", selRow - 1)); string strDocCode = strCode + "-" + dn; string strInsert = "UPDATE \"@B1_QA_DOC\" SET \"U_Att\" = '" + strFileName + "' WHERE \"Code\" = '" + strDocCode + "'"; Program.objHrmsUI.ExecQuery(strInsert, "Finalllizing Inspaction"); } } if (pVal.ItemUID == "1000001") { string RC = Convert.ToString(dtHead.GetValue("RC", 0)); string SBC = Convert.ToString(dtHead.GetValue("SBC", 0)); string strCode = RC + "-" + SBC; saveReport(strCode); } if (pVal.ItemUID == mtDocs.Item.UniqueID && pVal.Row > 0 && pVal.Row <= mtDocs.RowCount) { mtDocs.SelectRow(pVal.Row, true, false); int selRow = pVal.Row; if (selRow > 0) { string strCode = Convert.ToString(dtDoc.GetValue("OT", selRow - 1)); string dn = Convert.ToString(dtDoc.GetValue("DE", selRow - 1)); string tbl = Convert.ToString(dtDoc.GetValue("Tbl", selRow - 1)); if (strCode.Trim() != "") { string strDocCode = strCode + "-" + dn; string strExist = "SELECT * from \"@B1_QA_DOC\" where \"Code\" = '" + strDocCode + "'"; System.Data.DataTable dtExist = Program.objHrmsUI.getDataTable(strExist, "DocDetExist"); if (dtExist.Rows.Count == 0) { string strInsert = "INSERT INTO \"@B1_QA_DOC\" (\"Code\",\"Name\",\"U_ObjType\",\"U_DocEntry\",\"U_Date\")"; strInsert += " VALUES ('" + strDocCode + "','" + strDocCode + "','" + strCode + "','" + dn + "','" + DateTime.Now.ToString("yyyyMMdd") + "')"; Program.objHrmsUI.ExecQuery(strInsert, "Rpt Doc Entry into UDT"); } else { dtHead.SetValue("Att", 0, dtExist.Rows[0]["U_Att"].ToString()); } getRows(tbl, dn); } } else { oApplication.MessageBox("Please select a document before inspaction"); } } if (pVal.ItemUID == mtDocRows.Item.UniqueID && pVal.Row > 0 && pVal.Row <= mtDocRows.RowCount) { mtDocRows.SelectRow(pVal.Row, true, false); int selRow = pVal.Row;// mtSelRow(mtDocRows); if (selRow > 0) { string strCode = Convert.ToString(dtRow.GetValue("ItemCode", selRow - 1)); string MM = Convert.ToString(dtRow.GetValue("MM", selRow - 1)); string OBT = Convert.ToString(dtRow.GetValue("OBT", selRow - 1)); string LN = Convert.ToString(dtRow.GetValue("LN", selRow - 1)); string ItemCode = Convert.ToString(dtRow.GetValue("ItemCode", selRow - 1)); string Qty = Convert.ToString(dtRow.GetValue("Quantity", selRow - 1)); int DocselRow = mtSelRow(mtDocs); string DE = Convert.ToString(dtDoc.GetValue("DE", DocselRow - 1)); dtHead.SetValue("RC", 0, OBT + "-" + DE + "-" + LN); dtHead.SetValue("MM", 0, MM); dtHead.SetValue("OBT", 0, OBT); dtHead.SetValue("LN", 0, LN); dtHead.SetValue("DE", 0, DE); dtHead.SetValue("Qty", 0, Qty); dtHead.SetValue("ItemCode", 0, ItemCode); if (strCode.Trim() != "") { getAttributes(strCode); fillSerilaOrBatch(Qty, DE, LN, OBT, MM); } } else { oApplication.MessageBox("Please select an item before inspaction"); } } if (pVal.ItemUID == mtSB.Item.UniqueID && pVal.Row > 0 && pVal.Row <= mtSB.RowCount) { mtSB.SelectRow(pVal.Row, true, false); int selRow = pVal.Row;// mtSelRow(mtSB); if (selRow > 0) { string RC = Convert.ToString(dtHead.GetValue("RC", 0)); string MM = Convert.ToString(dtHead.GetValue("MM", 0)); string OBT = Convert.ToString(dtHead.GetValue("OBT", 0)); string LN = Convert.ToString(dtHead.GetValue("LN", 0)); string DE = Convert.ToString(dtHead.GetValue("DE", 0)); string ItemCode = Convert.ToString(dtHead.GetValue("ItemCode", 0)); string Qty = Convert.ToString(dtHead.GetValue("Qty", 0)); string strCode = Convert.ToString(dtSB.GetValue("Code", selRow - 1)); string strQty = Convert.ToString(dtSB.GetValue("Qty", selRow - 1)); dtHead.SetValue("SBC", 0, strCode); getReport(RC + "-" + strCode, OBT, DE, LN, MM, strQty, ItemCode, strCode); } } }