}//fin Initform

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            string sErr;

            //SAPbouiCOM.DataTable oDataTable;
            //Int32 iDif;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            try
            {
                if (pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    if ((pVal.ItemUID == "btn1") && (!pVal.BeforeAction))
                    {
                        BubbleEvent = false;
                        ActualizarRegistrosWS();
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            IvkFormInterface oFormB;
            String           oUid;

            try
            {
                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (!pVal.BeforeAction))
                {
                    if (pVal.ItemUID == "btn1")
                    {
                        oFormB            = (IvkFormInterface)(new TLibros());
                        TLibros.TipoLibro = "C";
                        oEditText         = (EditText)(oForm.Items.Item("Desde").Specific);
                        TLibros.Desde     = oEditText.Value;
                        oEditText         = (EditText)(oForm.Items.Item("Hasta").Specific);
                        TLibros.Hasta     = oEditText.Value;
                        oUid = FSBOf.generateFormId(FGlobalSettings.SBOSpaceName, FGlobalSettings);
                        oFormB.InitForm(oUid, "forms\\", ref FSBOApp, ref FCmpny, ref FSBOf, ref FGlobalSettings);
                        FoForms.Add(oFormB);
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
        }//fin InitForm

        public void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            try
            {
                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (pVal.BeforeAction))
                {
                    if ((pVal.ItemUID == "1") && ((oForm.Mode == BoFormMode.fm_ADD_MODE) || (oForm.Mode == BoFormMode.fm_UPDATE_MODE)))
                    {
                        BubbleEvent = false;
                        if (ValidarMatrix())
                        {
                            GuardarRegistros();
                        }
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (!pVal.BeforeAction))
                {
                    if (pVal.ItemUID == "btnProbar")
                    {
                        ProbarConexion();
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            SAPbouiCOM.ComboBox oComboBox;
            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);

            try
            {
                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (pVal.BeforeAction))
                {
                    if ((pVal.ItemUID == "1") && (oForm.Mode == BoFormMode.fm_ADD_MODE))
                    {
                        BubbleEvent = false;
                        GuardarRegistros();
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_COMBO_SELECT) && (!pVal.BeforeAction))
                {
                    if ((pVal.ItemUID == "TipoDoc") && (oForm.Mode == BoFormMode.fm_ADD_MODE))
                    {
                        //carga Rango de Folios
                        if (GlobalSettings.RunningUnderSQLServer)
                        {
                            s = @"select Code 'Code', CAST(U_Desde as varchar(20)) + '-' + CAST(U_Hasta as varchar(20))  'Name' 
                                    from [@VID_FECAF]
                                    where U_TipoDoc = '{0}'";
                        }
                        else
                        {
                            s = @"select ""Code"" ""Code"", CAST(""U_Desde"" as varchar(20)) + '-' + CAST(""U_Hasta"" as varchar(20))  ""Name""
                                    from ""@VID_FECAF""
                                   where ""U_TipoDoc"" = '{0}' ";
                        }
                        oComboBox = (ComboBox)(oForm.Items.Item("TipoDoc").Specific);
                        s         = String.Format(s, (System.String)(oComboBox.Value).Trim());
                        oRecordSet.DoQuery(s);
                        FSBOf.FillCombo((ComboBox)(oForm.Items.Item("RangoF").Specific), ref oRecordSet, true);
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (!pVal.BeforeAction) && (pVal.ItemUID == "btnDist") && (oForm.Mode == BoFormMode.fm_ADD_MODE))
                {
                    if (Validar())
                    {
                        Distribuir();
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            SAPbouiCOM.DataTable oDataTable;
            String sValue, sValue1;

            SAPbouiCOM.IChooseFromListEvent oCFLEvento = null;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            try
            {
                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (pVal.BeforeAction))
                {
                    if ((pVal.ItemUID == "1") && (oForm.Mode == BoFormMode.fm_ADD_MODE))
                    {
                        //BubbleEvent := ValidarDatosFE();
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_CHOOSE_FROM_LIST) && (!pVal.BeforeAction))
                {
                    if (pVal.ColUID == "V_0")
                    {
                        oCFLEvento = (SAPbouiCOM.IChooseFromListEvent)(pVal);
                        oDataTable = oCFLEvento.SelectedObjects;
                        if (oDataTable != null)
                        {
                            sValue  = (System.String)(oDataTable.GetValue("Code", 0));
                            sValue1 = (System.String)(oDataTable.GetValue("Name", 0));

                            oMtx.FlushToDataSource();
                            oDBDSD.SetValue("U_Indicato", pVal.Row - 1, sValue);
                            oDBDSD.SetValue("U_Descrip", pVal.Row - 1, sValue1);
                            if (pVal.Row == oMtx.RowCount)
                            {
                                oDBDSD.InsertRecord(pVal.Row);
                            }
                            oMtx.LoadFromDataSource();
                            oMtx.AutoResizeColumns();
                            if (oForm.Mode == BoFormMode.fm_OK_MODE)
                            {
                                oForm.Mode = BoFormMode.fm_UPDATE_MODE;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
示例#6
0
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            SAPbouiCOM.EditText      oEditText;
            SAPbouiCOM.ComboBox      oComboBox;
            SAPbouiCOM.CommonSetting oSetting;
            Int32 i;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            try
            {
                if (pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    if ((pVal.ItemUID == "1") && ((oForm.Mode == BoFormMode.fm_ADD_MODE) || (oForm.Mode == BoFormMode.fm_UPDATE_MODE)) && (pVal.BeforeAction))
                    {
                        BubbleEvent = false;
                        if (Limpiar())
                        {
                            GuardarRegistros();
                            oMtx.FlushToDataSource();
                            i = oMtx.RowCount + 1;
                            oMtx.AddRow(1, i);
                            oEditText       = (EditText)(oMtx.Columns.Item("Code").Cells.Item(i).Specific);
                            oEditText.Value = "";

                            oEditText       = (EditText)(oMtx.Columns.Item("Name").Cells.Item(i).Specific);
                            oEditText.Value = "";

                            oComboBox = (ComboBox)(oMtx.Columns.Item("Habilitada").Cells.Item(i).Specific);
                            oComboBox.Select("Y", BoSearchKey.psk_ByValue);


                            oSetting = oMtx.CommonSetting;
                            i        = 1;
                            while (i < oMtx.RowCount)
                            {
                                if ((System.String)(oDBDSH.GetValue("Code", i - 1)).Trim() != "")
                                {
                                    oSetting.SetCellEditable(i, 1, false);
                                }
                                i++;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
示例#7
0
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);

            try
            {
                if (pVal.ItemUID == "3")
                {
                    if ((pVal.ColUID == "Code") && (!pVal.BeforeAction) && (pVal.EventType == BoEventTypes.et_COMBO_SELECT))
                    {
                        if (pVal.Row == oDataTable.Rows.Count - 1)
                        {
                            if ((System.String)(oDataTable.GetValue("Code", oDataTable.Rows.Count - 1)) != "")
                            {
                                oDataTable.Rows.Add(1);
                                oDataTable.SetValue("Code", oDataTable.Rows.Count - 1, "");
                                oDataTable.SetValue("Name", oDataTable.Rows.Count - 1, "");
                                oDataTable.SetValue("U_TypeCode", oDataTable.Rows.Count - 1, "");
                            }
                        }
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (pVal.BeforeAction))
                {
                    var paso = false;
                    if ((pVal.ItemUID == "1") && ((oForm.Mode == BoFormMode.fm_ADD_MODE) || (oForm.Mode == BoFormMode.fm_UPDATE_MODE)))
                    {
                        BubbleEvent = false;
                        if (LimpiarGrid())
                        {
                            paso = CrearDatos();
                        }

                        if ((paso) && (oForm.Mode != BoFormMode.fm_OK_MODE))
                        {
                            oForm.Mode = BoFormMode.fm_OK_MODE;
                        }
                    }
                    else if ((pVal.ItemUID == "1") && (oForm.Mode == BoFormMode.fm_OK_MODE))
                    {
                        BubbleEvent = true;
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
示例#8
0
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            //IvkFormInterface oFormB;
            String oUid;
            String AbsDesde;
            String FDesde, FHasta;
            String TipoLibro;

            try
            {
                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (!pVal.BeforeAction))
                {
                    if (pVal.ItemUID == "btn1")
                    {
                        //enviar libro al portal
                        oComboBox = ((ComboBox)oForm.Items.Item("Periodo").Specific);
                        AbsDesde  = oComboBox.Selected.Value;

                        if (GlobalSettings.RunningUnderSQLServer)
                        {
                            s = @"select F_RefDate, T_RefDate,* from OFPR where AbsEntry = {0}";
                        }
                        else
                        {
                            s = @"select ""F_RefDate"", ""T_RefDate"" from ""OFPR"" where ""AbsEntry"" = {0}";
                        }
                        s = String.Format(s, AbsDesde);
                        oRecordSet.DoQuery(s);
                        FDesde = ((System.DateTime)oRecordSet.Fields.Item("F_RefDate").Value).ToString("yyyyMMdd");
                        FHasta = ((System.DateTime)oRecordSet.Fields.Item("T_RefDate").Value).ToString("yyyyMMdd");

                        oComboBox = ((ComboBox)oForm.Items.Item("TipoLibro").Specific);
                        TipoLibro = oComboBox.Selected.Value;

                        if (FSBOApp.MessageBox("¿ Desea enviar libro electronico al portal ?", 1, "Si", "No", "") == 1)
                        {
                            EnviarLibros(TipoLibro, FDesde, FHasta);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
示例#9
0
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            try
            {
                if ((pVal.EventType == BoEventTypes.et_FORM_ACTIVATE) && (!pVal.BeforeAction))
                {
                    GlobalSettings.PrevFormUID = oForm.UniqueID;
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            SAPbouiCOM.Form oFormAux;
            String          DocEntry;
            String          Tabla;
            XmlDocument     _xmlDocument;
            XmlNode         N;
            Boolean         FolioUnico;

            SAPbouiCOM.EditText oEditText;
            String[]            FE52 = { "15", "67", "21" };

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            try
            {
                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (pVal.BeforeAction))
                {
                    if (Localidad == "CL")
                    {
                        if (pVal.ItemUID == "4")
                        {
                            s        = GlobalSettings.PrevFormUID;
                            oFormAux = FSBOApp.Forms.Item(s);
                            //if (oFormAux.BusinessObject.Type in ['15','67'])
                            if (FE52.Contains(oFormAux.BusinessObject.Type))
                            {
                                if (GlobalSettings.RunningUnderSQLServer)
                                {
                                    s = @"select isnull(U_FolioGuia,'N') FolioUnico from [@VID_FEPARAM] where code = '1'";
                                }
                                else
                                {
                                    s = @"select IFNULL(""U_FolioGuia"",'N') ""FolioUnico"" from ""@VID_FEPARAM"" where ""Code"" = '1' ";
                                }
                                oRecordSet.DoQuery(s);
                                if ((System.String)(oRecordSet.Fields.Item("FolioUnico").Value) == "Y")
                                {
                                    FolioUnico = true;
                                }
                                else
                                {
                                    FolioUnico = false;
                                }

                                if (FolioUnico)
                                {
                                    if (oFormAux.BusinessObject.Type == "15")
                                    {
                                        Tabla = "ODLN";
                                    }
                                    else if (oFormAux.BusinessObject.Type == "21")
                                    {
                                        Tabla = "ORPD";
                                    }
                                    else
                                    {
                                        Tabla = "OWTR";
                                    }

                                    _xmlDocument = new XmlDocument();
                                    _xmlDocument.LoadXml(oFormAux.BusinessObject.Key);
                                    N        = _xmlDocument.SelectSingleNode("DocumentParams");
                                    DocEntry = N.InnerText;

                                    if (GlobalSettings.RunningUnderSQLServer)
                                    {
                                        s = @"SELECT Count(*) Cont
                                            FROM NNM1 T0
                                            JOIN {0} T1 ON T1.Series = T0.Series
                                           WHERE (SUBSTRING(UPPER(T0.BeginStr), 1, 1) = 'E') 
                                             AND T1.DocEntry = {1}
                                             --AND T0.ObjectCode = '{2}'";
                                    }
                                    else
                                    {
                                        s = @"SELECT Count(*) ""Cont""
                                            FROM ""NNM1"" T0
                                            JOIN ""{0}"" T1 ON T1.""Series"" = T0.""Series""
                                           WHERE (SUBSTRING(UPPER(T0.""BeginStr""), 1, 1) = 'E') 
                                             AND T1.""DocEntry"" = {1}
                                             --AND T0.""ObjectCode"" = '{2}'";
                                    }
                                    s = String.Format(s, Tabla, DocEntry, oFormAux.BusinessObject.Type);
                                    oRecordSet.DoQuery(s);
                                    if ((System.Int32)(oRecordSet.Fields.Item("Cont").Value) > 0)
                                    {
                                        BubbleEvent = false;
                                        oForm.Close();
                                    }
                                }
                            }
                        }
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_FORM_LOAD) && (!pVal.BeforeAction))
                {
                    s        = GlobalSettings.PrevFormUID;
                    oFormAux = FSBOApp.Forms.Item(s);
                    //if (oFormAux.BusinessObject.Type in ['15','67'])
                    if (Localidad == "CL")
                    {
                        if (FE52.Contains(oFormAux.BusinessObject.Type))
                        {
                            if (GlobalSettings.RunningUnderSQLServer)
                            {
                                s = @"select isnull(U_FolioGuia,'N') FolioUnico from [@VID_FEPARAM] where code = '1'";
                            }
                            else
                            {
                                s = @"select IFNULL(""U_FolioGuia"",'N') ""FolioUnico"" from ""@VID_FEPARAM"" where ""Code"" = '1'";
                            }

                            oRecordSet.DoQuery(s);
                            if ((System.String)(oRecordSet.Fields.Item("FolioUnico").Value) == "Y")
                            {
                                FolioUnico = true;
                            }
                            else
                            {
                                FolioUnico = false;
                            }

                            if (FolioUnico)
                            {
                                if (oFormAux.BusinessObject.Type == "15")
                                {
                                    Tabla = "ODLN";
                                }
                                else if (oFormAux.BusinessObject.Type == "21")
                                {
                                    Tabla = "ORPD";
                                }
                                else
                                {
                                    Tabla = "OWTR";
                                }

                                _xmlDocument = new XmlDocument();
                                _xmlDocument.LoadXml(oFormAux.BusinessObject.Key);
                                N        = _xmlDocument.SelectSingleNode("DocumentParams");
                                DocEntry = N.InnerText;

                                if (GlobalSettings.RunningUnderSQLServer)
                                {
                                    s = @"SELECT Count(*) Cont
                                        FROM NNM1 T0
                                        JOIN {0} T1 ON T1.Series = T0.Series
                                       WHERE (SUBSTRING(UPPER(T0.BeginStr), 1, 1) = 'E') 
                                         AND T1.DocEntry = {1}
                                         --AND T0.ObjectCode = '{2}'";
                                }
                                else
                                {
                                    s = @"SELECT Count(*) ""Cont""
                                        FROM ""NNM1"" T0
                                        JOIN ""{0}"" T1 ON T1.""Series"" = T0.""Series""
                                       WHERE (SUBSTRING(UPPER(T0.""BeginStr""), 1, 1) = 'E') 
                                         AND T1.""DocEntry"" = {1}
                                         --AND T0.""ObjectCode"" = '{2}'";
                                }
                                s = String.Format(s, Tabla, DocEntry, oFormAux.BusinessObject.Type);
                                oRecordSet.DoQuery(s);
                                if ((System.Int32)(oRecordSet.Fields.Item("Cont").Value) > 0)
                                {
                                    if (GlobalSettings.RunningUnderSQLServer)
                                    {
                                        s = @"SELECT 'GE' BeginStr, NextNumber FROM NNM1 WHERE (ObjectCode = 'VD_FEEntreg')";
                                    }
                                    else
                                    {
                                        s = @"SELECT 'GE' ""BeginStr"", ""NextNumber"" FROM ""NNM1"" WHERE (""ObjectCode"" = 'VD_FEEntreg')";
                                    }
                                    oRecordSet.DoQuery(s);
                                    s               = Convert.ToString((System.Int32)(oRecordSet.Fields.Item("NextNumber").Value));
                                    oEditText       = (EditText)(oForm.Items.Item("7").Specific);
                                    oEditText.Value = s;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            SAPbouiCOM.EditText oEditText;
            SAPbouiCOM.ComboBox oComboBox;
            Int32 i;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            try
            {
                if (pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    if ((pVal.ItemUID == "1") && ((oForm.Mode == BoFormMode.fm_ADD_MODE) || (oForm.Mode == BoFormMode.fm_UPDATE_MODE)) && (pVal.BeforeAction))
                    {
                        BubbleEvent = false;
                        if (Validar())
                        {
                            if (Limpiar())
                            {
                                oForm.Freeze(true);
                                GuardarRegistros();
                                oMtx.FlushToDataSource();
                                i = oMtx.RowCount + 1;
                                oMtx.AddRow(1, i);
                                oComboBox = (ComboBox)(oMtx.Columns.Item("TipoDoc").Cells.Item(i).Specific);
                                oComboBox.Select("33", BoSearchKey.psk_ByValue);

                                oEditText       = (EditText)(oMtx.Columns.Item("ProcNomE").Cells.Item(i).Specific);
                                oEditText.Value = "";

                                oEditText       = (EditText)(oMtx.Columns.Item("ProcNomD").Cells.Item(i).Specific);
                                oEditText.Value = "";

                                oEditText       = (EditText)(oMtx.Columns.Item("ProcNomR").Cells.Item(i).Specific);
                                oEditText.Value = "";

                                oEditText       = (EditText)(oMtx.Columns.Item("ProcNomC").Cells.Item(i).Specific);
                                oEditText.Value = "";

                                oEditText       = (EditText)(oMtx.Columns.Item("ProcNomDe").Cells.Item(i).Specific);
                                oEditText.Value = "";

                                oEditText       = (EditText)(oMtx.Columns.Item("ProcNomL").Cells.Item(i).Specific);
                                oEditText.Value = "";

                                oEditText       = (EditText)(oMtx.Columns.Item("ProcNomS").Cells.Item(i).Specific);
                                oEditText.Value = "";

                                oComboBox = (ComboBox)(oMtx.Columns.Item("Habili").Cells.Item(i).Specific);
                                oComboBox.Select("Y", BoSearchKey.psk_ByValue);

                                oEditText       = (EditText)(oMtx.Columns.Item("DocEntry").Cells.Item(i).Specific);
                                oEditText.Value = "";

                                oEditText       = (EditText)(oMtx.Columns.Item("CantLineas").Cells.Item(i).Specific);
                                oEditText.Value = "60";

                                oMtx.FlushToDataSource();
                            }
                        }
                    }

                    if ((pVal.ItemUID == "btnBorrar") && (!pVal.BeforeAction))
                    {
                        Borrar();
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
            oForm.Freeze(false);
        }//fin FormEvent
示例#12
0
        private void GuardarRegistros()
        {
            SAPbouiCOM.Grid oGrid;
            Boolean         Paso = false;
            String          ObjType;
            Int32           DocEntry;
            String          Tipo;
            String          Serie;
            String          Folio;
            Int32           lRetCode;
            String          errMsg;
            Int32           errCode;
            XDocument       miXMLDoc;
            XmlDocument     oXml;
            String          UserWS        = "";
            String          PassWS        = "";
            String          TaxIdNum      = "";
            String          URL           = "";
            String          ExternalFolio = "";
            XmlNode         oNode;

            SAPbobsCOM.Documents     oDocs;
            SAPbobsCOM.StockTransfer oStock;
            SAPbobsCOM.Payments      oPay;
            try
            {
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"SELECT T0.U_URLDarBaja 'URL', ISNULL(T0.U_UserWS,'') 'UserWS', ISNULL(T0.U_PassWS,'') 'PassWS', ISNULL(T0.U_MostrarXML,'N') 'MostrarXML', ISNULL(A0.TaxIdNum,'') 'TaxIdNum' 
                           FROM [@VID_FEPARAM] T0 , OADM A0";
                }
                else
                {
                    s = @"SELECT T0.""U_URLDarBaja"" ""URL"", IFNULL(T0.""U_UserWS"",'') ""UserWS"", IFNULL(T0.""U_PassWS"",'') ""PassWS"", IFNULL(T0.""U_MostrarXML"",'N') ""MostrarXML"", IFNULL(A0.""TaxIdNum"",'') ""TaxIdNum"" 
                           FROM ""@VID_FEPARAM"" T0, ""OADM"" A0";
                }

                oRecordSet.DoQuery(s);
                if (oRecordSet.RecordCount == 0)
                {
                    FSBOApp.StatusBar.SetText("No se ha ingresado URL", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                }
                else if (((System.String)oRecordSet.Fields.Item("URL").Value).Trim() == "")
                {
                    FSBOApp.StatusBar.SetText("No se ha ingresado URL", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                }
                //else if (((System.String)oRecordSet.Fields.Item("UserWS").Value).Trim() == "")
                //    throw new Exception("No se encuentra usuario en Parametros");
                //else if (((System.String)oRecordSet.Fields.Item("PassWS").Value).Trim() == "")
                //    throw new Exception("No se encuentra password en Parametros");
                else if (((System.String)oRecordSet.Fields.Item("TaxIdNum").Value).Trim() == "")
                {
                    throw new Exception("No se encuentra RUC de Emisor, Gestión -> Inicialización Sistema -> Detalle Sociedad -> Datos de Contabilidad -> ID fiscal general 1");
                }
                else
                {
                    UserWS   = Funciones.DesEncriptar((System.String)(oRecordSet.Fields.Item("UserWS").Value).ToString().Trim());
                    PassWS   = Funciones.DesEncriptar((System.String)(oRecordSet.Fields.Item("PassWS").Value).ToString().Trim());
                    TaxIdNum = ((System.String)oRecordSet.Fields.Item("TaxIdNum").Value).Trim();
                    URL      = ((System.String)oRecordSet.Fields.Item("URL").Value).Trim();
                }

                oGrid = ((SAPbouiCOM.Grid)oForm.Items.Item("grid").Specific);
                FCmpny.StartTransaction();
                for (Int32 iLinea = 0; iLinea <= oGrid.DataTable.Rows.Count - 1; iLinea++)
                {
                    if (((System.String)oGrid.DataTable.GetValue("Sel", iLinea)).Trim() == "Y")
                    {
                        try
                        {
                            Paso          = true;
                            ObjType       = ((System.String)oGrid.DataTable.GetValue("ObjType", iLinea));
                            DocEntry      = ((System.Int32)oGrid.DataTable.GetValue("DocEntry", iLinea));
                            Tipo          = ((System.String)oGrid.DataTable.GetValue("TipoDoc", iLinea));
                            Serie         = ((System.String)oGrid.DataTable.GetValue("Serie", iLinea));
                            Folio         = ((System.String)oGrid.DataTable.GetValue("Folio", iLinea));
                            ExternalFolio = ((System.String)oGrid.DataTable.GetValue("ExtFolio", iLinea));

                            if (ObjType == "67")
                            {
                                oStock = ((SAPbobsCOM.StockTransfer)FCmpny.GetBusinessObject(BoObjectTypes.oStockTransfer));
                                if (oStock.GetByKey(DocEntry))
                                {
                                    lRetCode = oStock.Cancel();
                                }
                            }
                            else if (ObjType == "46")
                            {
                                oPay = ((SAPbobsCOM.Payments)FCmpny.GetBusinessObject(BoObjectTypes.oVendorPayments));
                                if (oPay.GetByKey(DocEntry))
                                {
                                    lRetCode = oPay.Cancel();
                                }
                            }
                            else
                            {
                                if (ObjType == "21")
                                {
                                    oDocs = ((SAPbobsCOM.Documents)FCmpny.GetBusinessObject(BoObjectTypes.oPurchaseReturns));
                                }
                                else if (ObjType == "15")
                                {
                                    oDocs = ((SAPbobsCOM.Documents)FCmpny.GetBusinessObject(BoObjectTypes.oDeliveryNotes));
                                }
                                else if (ObjType == "14")
                                {
                                    oDocs = ((SAPbobsCOM.Documents)FCmpny.GetBusinessObject(BoObjectTypes.oCreditNotes));
                                }
                                else if (ObjType == "203")
                                {
                                    oDocs = ((SAPbobsCOM.Documents)FCmpny.GetBusinessObject(BoObjectTypes.oDownPayments));
                                }
                                else
                                {
                                    oDocs = ((SAPbobsCOM.Documents)FCmpny.GetBusinessObject(BoObjectTypes.oInvoices));
                                }
                                if (oDocs.GetByKey(DocEntry))
                                {
                                    var oDocCancel = oDocs.CreateCancellationDocument();
                                    lRetCode = oDocCancel.Add();// Cancel();
                                    if (lRetCode != 0)
                                    {
                                        FCmpny.GetLastError(out errCode, out errMsg);
                                        throw new Exception("No se ha encontrado Documento " + Tipo + " " + Serie + "-" + Folio + ": " + errMsg);
                                    }
                                    else
                                    {
                                        //enviar baja al portal
                                        miXMLDoc = new XDocument(
                                            new XDeclaration("1.0", "utf-8", "yes")
                                            , new XElement("documentoelectronico",
                                                           new XElement("DocNum", TaxIdNum),
                                                           new XElement("DocType", Tipo),
                                                           new XElement("IdDocumento", ExternalFolio.Trim()
                                                                        ))
                                            );
                                        oXml = new XmlDocument();
                                        using (var xmlReader = miXMLDoc.CreateReader())
                                        {
                                            oXml.Load(xmlReader);
                                        }

                                        s = Funciones.UpLoadDocumentByUrl(oXml, null, GlobalSettings.RunningUnderSQLServer, URL, UserWS, PassWS, "D-" + ExternalFolio);

                                        oXml.LoadXml(s);

                                        oNode = oXml.DocumentElement.SelectSingleNode("/Error/ErrorCode");

                                        string ticket = oNode.InnerText;

                                        oNode = oXml.DocumentElement.SelectSingleNode("/Error/ErrorText");

                                        string errorText = oNode.InnerText;

                                        oNode = oXml.DocumentElement.SelectSingleNode("/Error/IdDocument");

                                        string idDocument = oNode.InnerText;

                                        if (errorText != "OK")
                                        {
                                            FSBOApp.StatusBar.SetText("Mensaje: " + errorText + " " + Tipo + " " + Serie + "-" + Folio, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning);
                                        }
                                        else
                                        {
                                            FSBOApp.StatusBar.SetText("Se ha creado cancelacion del documento " + Tipo + " " + Serie + "-" + Folio, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success);

                                            //insertar en la tabla  y consultar por el estado mismo codigo que insert de factura
                                        }
                                    }
                                }
                                else
                                {
                                    FSBOApp.StatusBar.SetText("No se ha encontrado Documento " + Tipo + " " + Serie + "-" + Folio, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning);
                                }
                            }

                            oDocs  = null;
                            oPay   = null;
                            oStock = null;
                        }
                        catch (Exception ss)
                        {
                            FSBOApp.StatusBar.SetText("Dar de Baja: " + ss.Message + " ** Trace: " + ss.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                            OutLog("Dar de Baja: " + ss.Message + " ** Trace: " + ss.StackTrace);
                            if (FCmpny.InTransaction)
                            {
                                FCmpny.EndTransaction(BoWfTransOpt.wf_RollBack);
                            }
                        }
                    }
                }

                if (!Paso)
                {
                    FSBOApp.StatusBar.SetText("Debe seleccionar un documento minimo", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning);
                }
                else
                {
                    if (FCmpny.InTransaction)
                    {
                        FCmpny.EndTransaction(BoWfTransOpt.wf_Commit);
                    }
                }
            }
            catch (Exception e)
            {
                FSBOApp.StatusBar.SetText("GuardarRegistros: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("GuardarRegistros: " + e.Message + " ** Trace: " + e.StackTrace);
                if (FCmpny.InTransaction)
                {
                    FCmpny.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
            }
        }
示例#13
0
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            Int32  nErr;
            String sErr;

            SAPbouiCOM.DataTable oDataTable;
            String sValue, sValue1;

            SAPbouiCOM.IChooseFromListEvent oCFLEvento = null;
            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);

            try
            {
                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (pVal.BeforeAction))
                {
                    if ((pVal.ItemUID == "1") && (oForm.Mode == BoFormMode.fm_ADD_MODE))
                    {
                        //BubbleEvent := ValidarDatosFE();
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_COMBO_SELECT) && (!pVal.BeforeAction) && (pVal.ItemUID == "mtx"))
                {
                    if (pVal.ColUID == "V_0")
                    {
                        oMtx.FlushToDataSource();
                        sValue = ((System.String)oDBDSD.GetValue("U_CodeImp", pVal.Row - 1)).Trim();
                        if (GlobalSettings.RunningUnderSQLServer)
                        {
                            s = @"select Code, Name from OSTA where Code = '{0}'
                                  UNION ALL
                                  select WTCode 'Code', WTName 'Name' from OWHT where Inactive = 'N' and WTCode = '{0}'";
                        }
                        else
                        {
                            s = @"select ""Code"", ""Name"" from ""OSTA"" where ""Code"" = '{0}'
                                  UNION ALL
                                  select ""WTCode"" ""Code"", ""WTName"" ""Name"" from ""OWHT"" where ""Inactive"" = 'N' and ""WTCode"" = '{0}' ";
                        }
                        s = String.Format(s, sValue);
                        oRecordSet.DoQuery(s);

                        if (oRecordSet.RecordCount == 0)
                        {
                            FSBOApp.StatusBar.SetText("No se encuentra Impuesto o Retención: " + sValue, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                        }
                        else
                        {
                            sValue1 = ((System.String)oRecordSet.Fields.Item("Name").Value).Trim();


                            oDBDSD.SetValue("U_CodeImp", pVal.Row - 1, sValue);
                            oDBDSD.SetValue("U_Descrip", pVal.Row - 1, sValue1);
                            if (pVal.Row == oMtx.RowCount)
                            {
                                oDBDSD.InsertRecord(pVal.Row);
                            }
                            oMtx.LoadFromDataSource();
                            oMtx.AutoResizeColumns();
                            if (oForm.Mode == BoFormMode.fm_OK_MODE)
                            {
                                oForm.Mode = BoFormMode.fm_UPDATE_MODE;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                FCmpny.GetLastError(out nErr, out sErr);
                FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin FormEvent