Ejemplo n.º 1
0
 public void AddFilter(string FormUID, SAPbouiCOM.BoEventTypes eventType)
 {
     oController.AddFilter(FormUID, eventType);
 }
Ejemplo n.º 2
0
 public void AddFilter(string containerUID, SAPbouiCOM.BoEventTypes eventType)
 {
     uiUtils.AddFilter(containerUID, eventType);
 }
Ejemplo n.º 3
0
        private static void oApplication_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
        {
            //For UDOs, FormType is 0 and FormUID starts with UDO.
            if (pVal.FormType != 0 || FormUID.Contains("UDO"))
            {
                SAPbouiCOM.BoEventTypes EventEnum = 0;
                EventEnum = pVal.EventType;

                // To prevent an endless loop of MessageBoxes,
                // we'll not notify et_FORM_ACTIVATE and et_FORM_LOAD events
                //if ( ( EventEnum != SAPbouiCOM.BoEventTypes.et_FORM_ACTIVATE ) & ( EventEnum != SAPbouiCOM.BoEventTypes.et_FORM_LOAD ) )
                if (pVal.BeforeAction)
                {
                    string input = "";

                    //if FormType is 0, it's UDO and use FormType as FormUID (Variable)
                    string formType = pVal.FormType.ToString() == "0" ? FormUID : pVal.FormType.ToString();

                    if (EventEnum == SAPbouiCOM.BoEventTypes.et_VALIDATE || EventEnum == BoEventTypes.et_CHOOSE_FROM_LIST)
                    {
                        SAPbobsCOM.Recordset rsConfigData = AccessMatrixEngine.GetConfiguration(formType, pVal.ItemUID, pVal.ColUID, (int)pVal.EventType);
                        string accessMatrixKey = String.Empty, controlType = String.Empty;

                        if (rsConfigData.RecordCount > 0)
                        {
                            accessMatrixKey = rsConfigData.Fields.Item("U_AccessMatrixKey").Value.ToString();
                            controlType     = rsConfigData.Fields.Item("U_ControlType").Value.ToString();
                            string controlName = rsConfigData.Fields.Item("U_ControlName").Value.ToString();
                            string itemId      = rsConfigData.Fields.Item("U_ItemId").Value.ToString();
                            string colId       = rsConfigData.Fields.Item("U_ColumnId").Value.ToString();
                            string result      = AccessMatrixEngine.CheckIfValidOrNot(rsConfigData);

                            input = AccessMatrixEngine.GetInputValue(itemId, colId, controlType);

                            if (input != "" && result != "")
                            {
                                BubbleEvent = false;
                                AddOnUtilities.oApplication.ActivateMenuItem("7425");
                                return;
                            }

                            if (result != "")
                            {
                                BubbleEvent = false;
                                AddOnUtilities.MsgBoxWrapper(result, Enum.MsgBoxType.B1StatusBar, BoMessageTime.bmt_Short, true);
                                return;
                            }



                            //Set Names from Codes in UDOs.
                            string relatedColumn = rsConfigData.Fields.Item("U_RelatedColumn").Value.ToString();
                            string relatedItem   = rsConfigData.Fields.Item("U_RelatedItem").Value.ToString();

                            if (input != "" && pVal.FormType.ToString() == "0")
                            {
                                if (relatedColumn != "" && relatedItem != "")
                                {
                                    string strName = AccessMatrixEngine.GetNameByCode(input, accessMatrixKey);
                                    AccessMatrixEngine.SetValueToMatrix(relatedItem, relatedColumn, strName);
                                }
                            }

                            BubbleEvent = true;
                            return;
                        }
                    }
                    else if (EventEnum == SAPbouiCOM.BoEventTypes.et_KEY_DOWN && pVal.CharPressed == 9)
                    {
                        SAPbobsCOM.Recordset rsConfigData = AccessMatrixEngine.GetConfiguration(formType, pVal.ItemUID, pVal.ColUID, (int)pVal.EventType);
                        string accessMatrixKey = String.Empty, controlType = String.Empty;

                        if (rsConfigData.RecordCount > 0)
                        {
                            accessMatrixKey = rsConfigData.Fields.Item("U_AccessMatrixKey").Value.ToString();
                            controlType     = rsConfigData.Fields.Item("U_ControlType").Value.ToString();
                            string controlName = rsConfigData.Fields.Item("U_ControlName").Value.ToString();
                            string itemId      = rsConfigData.Fields.Item("U_ItemId").Value.ToString();
                            string colId       = rsConfigData.Fields.Item("U_ColumnId").Value.ToString();
                            string result      = AccessMatrixEngine.CheckIfValidOrNot(rsConfigData);

                            input = AccessMatrixEngine.GetInputValue(itemId, colId, controlType);

                            if (input == "")
                            {
                                BubbleEvent = false;
                                AddOnUtilities.oApplication.ActivateMenuItem("7425");
                                return;
                            }
                            if (result != "")
                            {
                                BubbleEvent = false;
                                AddOnUtilities.oApplication.ActivateMenuItem("7425");
                                return;
                            }
                            BubbleEvent = true;
                            return;
                        }
                    }
                    else if (EventEnum == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED)
                    {
                        SAPbobsCOM.Recordset rsConfigData = AccessMatrixEngine.GetConfigurationForLineLoop(formType, pVal.ItemUID, pVal.ColUID, (int)pVal.EventType);
                        int    recordCount = rsConfigData.RecordCount;
                        string accessMatrixKey = String.Empty, controlType = String.Empty;

                        while (!rsConfigData.EoF)
                        {
                            //To Do : Update following statement to be dynamic.
                            // I = 1 (Item), S = 2 (Service)

                            //Some Document do not have Item or Service Type. Those controls are always ComboBox.
                            //Check if it is ComboBox and if it's ComboBox, assign ControlType as 3 which is not Item or Service.
                            dynamic tmpControl   = AddOnUtilities.oApplication.Forms.ActiveForm.Items.Item("3").Specific;
                            string  documentType = "";
                            if (tmpControl is SAPbouiCOM.ComboBox)
                            {
                                documentType = ((SAPbouiCOM.ComboBox)AddOnUtilities.oApplication.Forms.ActiveForm.Items.Item("3").Specific).Value;
                                documentType = (documentType == "I" ? "1" : "2");
                            }
                            else
                            {
                                documentType = "3";
                            }


                            string configDocumentType = rsConfigData.Fields.Item("U_DocType").Value.ToString();

                            if (documentType != configDocumentType)
                            {
                                rsConfigData.MoveNext();
                                continue;
                            }

                            //if(rsConfigData.Fields.Item("U_DocType").Value.ToString() != documentType && !rsConfigData.EoF)
                            //{
                            //rsConfigData.MoveNext();
                            //}
                            string result = AccessMatrixEngine.CheckIfValidOrNotAllLine(rsConfigData, documentType);
                            rsConfigData.MoveNext();
                            if (result != "")
                            {
                                BubbleEvent = false;
                                AddOnUtilities.MsgBoxWrapper(result, Enum.MsgBoxType.B1StatusBar, BoMessageTime.bmt_Short, true);
                                return;
                            }
                        }
                    }
                }
            }
            BubbleEvent = true;
        }
Ejemplo n.º 4
0
        public Boolean presupEventos(SAPbouiCOM.BoEventTypes evento, ItemEvent pVal)
        {
            Funciones.Comunes oFunc = new Funciones.Comunes();
            switch (evento)
            {
            case BoEventTypes.et_CLICK:

                if (pVal.FormUID == "BOPC" && pVal.ItemUID == "1" && pVal.Before_Action == true && pVal.Action_Success == false)
                {
                    if (pVal.FormMode == 3)
                    {
                        SAPbouiCOM.Form oFormBOPC = null;
                        oFormBOPC = sboapp.Forms.Item("BOPC");
                        EditText            txt01 = (EditText)oFormBOPC.Items.Item("BO_User").Specific;
                        EditText            txt02 = (EditText)oFormBOPC.Items.Item("BO_Nombre").Specific;
                        EditText            txt03 = (EditText)oFormBOPC.Items.Item("BO_Fech").Specific;
                        EditText            txt04 = (EditText)oFormBOPC.Items.Item("BO_Ano").Specific;
                        SAPbouiCOM.ComboBox cbx01 = (SAPbouiCOM.ComboBox)oFormBOPC.Items.Item("BO_Activo").Specific;
                        SAPbouiCOM.ComboBox cbx02 = (SAPbouiCOM.ComboBox)oFormBOPC.Items.Item("BO_Status").Specific;

                        if (String.IsNullOrEmpty(txt01.Value))
                        {
                            oFunc.sendMessageBox(sboapp, "El campo Usuario es obligatorio", 1);
                            txt01.Item.Click();
                            return(false);
                        }
                        else if (String.IsNullOrEmpty(txt02.Value))
                        {
                            oFunc.sendMessageBox(sboapp, "El campo Nombre del Presupuesto es obligatorio", 1);
                            txt02.Item.Click();
                            return(false);
                        }
                        else if (String.IsNullOrEmpty(txt03.Value))
                        {
                            oFunc.sendMessageBox(sboapp, "El campo Fecha es obligatorio", 1);
                            txt03.Item.Click();
                            return(false);
                        }
                        else if (String.IsNullOrEmpty(txt04.Value))
                        {
                            oFunc.sendMessageBox(sboapp, "El campo Año es obligatorio", 1);
                            txt04.Item.Click();
                            return(false);
                        }
                        else if (txt04.Value.Length > 4 || txt04.Value.Length < 4)
                        {
                            oFunc.sendMessageBox(sboapp, "Campo Año debe contener 4 dígitos", 1);
                            txt04.Item.Click();
                            return(false);
                        }
                        else if (txt04.Value.Length == 4 && (txt04.Value.Substring(0, 2) != "20"))
                        {
                            oFunc.sendMessageBox(sboapp, "El Año debe debe se mayor al 2018", 1);
                            txt04.Item.Click();
                            return(false);
                        }
                        else if (String.IsNullOrEmpty(cbx01.Value))
                        {
                            oFunc.sendMessageBox(sboapp, "El campo Activo/Inactivo es obligatorio", 1);
                            cbx01.Item.Click();
                            return(false);
                        }
                        else if (String.IsNullOrEmpty(cbx02.Value))
                        {
                            oFunc.sendMessageBox(sboapp, "El campo Estado es obligatorio", 1);
                            cbx02.Item.Click();
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
                break;

            case BoEventTypes.et_FORM_ACTIVATE:
                if (pVal.FormUID == "BOPC")
                {
                    if (pVal.FormMode == 3)     //from ADD_MODE
                    {
                        string          usrID;
                        string          usrName;
                        SAPbouiCOM.Form oForm = null;
                        oForm = sboapp.Forms.Item("BOPC");
                        EditText et01 = (EditText)oForm.Items.Item("BO_User").Specific;
                        EditText et02 = (EditText)oForm.Items.Item("BO_UserID").Specific;

                        usrID      = oFunc.GetUsrID(oCompany, sboapp, et01.Value);
                        usrName    = oFunc.GetUsrName(oCompany, sboapp, et01.Value);
                        et02.Value = usrID;
                        et01.Item.Click();
                        return(true);
                    }
                }
                break;

            case BoEventTypes.et_FORM_VISIBLE:
                if (pVal.FormUID == "BOPC")
                {
                    SAPbouiCOM.Form oForm = null;
                    oForm = sboapp.Forms.Item("BOPC");
                    return(true);
                }

                break;

            default:
                return(true);

                break;
            }
            return(true);
        }