}//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
        public new bool InitForm(string uid, string xmlPath, ref SAPbouiCOM.Application application, ref SAPbobsCOM.Company company, ref CSBOFunctions SBOFunctions, ref TGlobalVid _GlobalSettings)
        {
            Int32 CantRol;

            bool Result = base.InitForm(uid, xmlPath, ref application, ref company, ref SBOFunctions, ref _GlobalSettings);

            oRecordSet      = (SAPbobsCOM.Recordset)(FCmpny.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset));
            Funciones.SBO_f = FSBOf;
            try
            {
                Lista = new List <string>();
                FSBOf.LoadForm(xmlPath, "VID_FEMonDTE.srf", uid);
                //EnableCrystal := true;
                oForm = FSBOApp.Forms.Item(uid);
                oForm.Freeze(true);
                oForm.AutoManaged    = false;
                oForm.SupportedModes = -1;       // afm_All
                oForm.EnableMenu("1282", false); //Crear
                oForm.EnableMenu("1281", false); //Actualizar

                // Ok Ad  Fnd Vw Rq Sec
                //Lista.Add('DocNum    , f,  f,  t,  f, n, 1');
                //Lista.Add('DocDate   , f,  t,  f,  f, r, 1');
                //Lista.Add('CardCode  , f,  t,  t,  f, r, 1');
                //FSBOf.SetAutoManaged(var oForm, Lista);

                oDBDSHC = oForm.DataSources.DBDataSources.Add("@VID_FEDTECPRA");
                oDBDSHV = oForm.DataSources.DBDataSources.Add("@VID_FEDTEVTA");

                oForm.DataSources.UserDataSources.Add("FechaD", BoDataType.dt_DATE, 10);
                oEditText = (EditText)(oForm.Items.Item("FechaD").Specific);
                oEditText.DataBind.SetBound(true, "", "FechaD");
                oEditText.Value = DateTime.Now.ToString("yyyyMMdd");

                oForm.DataSources.UserDataSources.Add("FechaH", BoDataType.dt_DATE, 10);
                oEditText = (EditText)(oForm.Items.Item("FechaH").Specific);
                oEditText.DataBind.SetBound(true, "", "FechaH");
                oEditText.Value = DateTime.Now.ToString("yyyyMMdd");

                oComboBox = (ComboBox)(oForm.Items.Item("TipoDTE").Specific);
                oForm.DataSources.UserDataSources.Add("TipoDTE", BoDataType.dt_SHORT_TEXT, 10);
                oComboBox.DataBind.SetBound(true, "", "TipoDTE");
                oComboBox.ValidValues.Add("V", "Venta");
                oComboBox.ValidValues.Add("C", "Compra");
                oComboBox.Select("V", BoSearchKey.psk_ByValue);
                oForm.Items.Item("TipoDTE").DisplayDesc = true;

                oDataTable      = oForm.DataSources.DataTables.Add("dt");
                oGrid           = (Grid)(oForm.Items.Item("grid").Specific);
                oGrid.DataTable = oDataTable;

                DSOpFec = oForm.DataSources.UserDataSources.Add("FechaEmi", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 1);
                ((OptionBtn)oForm.Items.Item("FechaEmi").Specific).DataBind.SetBound(true, "", "FechaEmi");

                ((OptionBtn)oForm.Items.Item("FechaRecep").Specific).DataBind.SetBound(true, "", "FechaEmi");
                ((OptionBtn)oForm.Items.Item("FechaRecep").Specific).GroupWith("FechaEmi");
                ((OptionBtn)oForm.Items.Item("FechaEmi").Specific).Selected = true;


                oComboBox = (ComboBox)(oForm.Items.Item("Cliente").Specific);
                oForm.DataSources.UserDataSources.Add("Cliente", BoDataType.dt_SHORT_TEXT, 10);
                oComboBox.DataBind.SetBound(true, "", "Cliente");
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"SELECT 'Todos' Code, 'Todos' Name UNION ALL 
                          SELECT T1.FldValue Code, T1.Descr Name
                          FROM CUFD T0
                          JOIN UFD1 T1 ON T1.TableID = T0.TableID
                                      AND T1.FieldID = T0.FieldID
                         WHERE T0.TableID = '{0}'
                           AND T0.AliasID = 'EstadoC'";
                }
                else
                {
                    s = @"SELECT 'Todos' ""Code"", 'Todos' ""Name"" FROM DUMMY UNION ALL
                          SELECT T1.""FldValue"" ""Code"", T1.""Descr"" ""Name""
                          FROM ""CUFD"" T0
                          JOIN ""UFD1"" T1 ON T1.""TableID"" = T0.""TableID""
                                      AND T1.""FieldID"" = T0.""FieldID""
                         WHERE T0.""TableID"" = '{0}'
                           AND T0.""AliasID"" = 'EstadoC'";
                }
                s = String.Format(s, "@VID_FEDTEVTA");
                oRecordSet.DoQuery(s);
                FSBOf.FillCombo(oComboBox, ref oRecordSet, false);
                oComboBox.Select("Todos", BoSearchKey.psk_ByValue);

                oComboBox = (ComboBox)(oForm.Items.Item("SII").Specific);
                oForm.DataSources.UserDataSources.Add("SII", BoDataType.dt_SHORT_TEXT, 10);
                oComboBox.DataBind.SetBound(true, "", "SII");
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"SELECT 'Todos' Code, 'Todos' Name UNION ALL
                          SELECT T1.FldValue Code, T1.Descr Name
                          FROM CUFD T0
                          JOIN UFD1 T1 ON T1.TableID = T0.TableID
                                      AND T1.FieldID = T0.FieldID
                         WHERE T0.TableID = '{0}'
                           AND T0.AliasID = 'EstadoSII'";
                }
                else
                {
                    s = @"SELECT 'Todos' ""Code"", 'Todos' ""Name"" FROM DUMMY UNION ALL
                          SELECT T1.""FldValue"" ""Code"", T1.""Descr"" ""Name""
                          FROM ""CUFD"" T0
                          JOIN ""UFD1"" T1 ON T1.""TableID"" = T0.""TableID""
                                      AND T1.""FieldID"" = T0.""FieldID""
                         WHERE T0.""TableID"" = '{0}'
                           AND T0.""AliasID"" = 'EstadoSII'";
                }
                s = String.Format(s, "@VID_FEDTEVTA");
                oRecordSet.DoQuery(s);
                FSBOf.FillCombo(oComboBox, ref oRecordSet, false);
                oComboBox.Select("Todos", BoSearchKey.psk_ByValue);

                oComboBox = (ComboBox)(oForm.Items.Item("Ley").Specific);
                oForm.DataSources.UserDataSources.Add("Ley", BoDataType.dt_SHORT_TEXT, 10);
                oComboBox.DataBind.SetBound(true, "", "Ley");
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"SELECT 'Todos' Code, 'Todos' Name UNION ALL
                          SELECT T1.FldValue Code, T1.Descr Name
                          FROM CUFD T0
                          JOIN UFD1 T1 ON T1.TableID = T0.TableID
                                      AND T1.FieldID = T0.FieldID
                         WHERE T0.TableID = '{0}'
                           AND T0.AliasID = 'EstadoLey'";
                }
                else
                {
                    s = @"SELECT 'Todos' ""Code"", 'Todos' ""Name"" FROM DUMMY UNION ALL
                          SELECT T1.""FldValue"" ""Code"", T1.""Descr"" ""Name""
                          FROM ""CUFD"" T0
                          JOIN ""UFD1"" T1 ON T1.""TableID"" = T0.""TableID""
                                      AND T1.""FieldID"" = T0.""FieldID""
                         WHERE T0.""TableID"" = '{0}'
                           AND T0.""AliasID"" = 'EstadoLey'";
                }
                s = String.Format(s, "@VID_FEDTEVTA");
                oRecordSet.DoQuery(s);
                FSBOf.FillCombo(oComboBox, ref oRecordSet, false);
                oComboBox.Select("Todos", BoSearchKey.psk_ByValue);

                BuscarDatos();
            }
            catch (Exception e)
            {
                OutLog("InitForm: " + e.Message + " ** Trace: " + e.StackTrace);
                FSBOApp.MessageBox(e.Message + " ** Trace: " + e.StackTrace, 1, "Ok", "", "");
            }
            finally
            {
                if (oForm != null)
                {
                    oForm.Freeze(false);
                }
            }


            return(Result);
        }//fin InitForm
        public new bool InitForm(string uid, string xmlPath, ref Application application, ref SAPbobsCOM.Company company, ref CSBOFunctions SBOFunctions, ref TGlobalVid _GlobalSettings)
        {
            //SAPbouiCOM.ComboBox oComboBox;
            bool Result = base.InitForm(uid, xmlPath, ref application, ref company, ref SBOFunctions, ref _GlobalSettings);

            try
            {
                oRecordSet = (SAPbobsCOM.Recordset)(FCmpny.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset));

                Lista = new List <string>();

                FSBOf.LoadForm(xmlPath, "VID_FEDIST.srf", uid);
                //EnableCrystal := true;
                oForm = FSBOApp.Forms.Item(uid);
                oForm.Freeze(true);
                oForm.AutoManaged    = true;
                oForm.SupportedModes = -1;             // afm_All

                VID_DelRow   = false;
                VID_DelRowOK = false;

                oForm.DataBrowser.BrowseBy = "DocEntry";
                oDBDSH = oForm.DataSources.DBDataSources.Item("@VID_FEDIST");
                oDBDSD = oForm.DataSources.DBDataSources.Item("@VID_FEDISTD");

                oForm.EnableMenu("1282", false); // boton Crear

                // Ok Ad  Fnd Vw Rq Sec
                Lista.Add("DocEntry  , f,  f,  f,  f, r, 1");
                Lista.Add("Desde     , f,  t,  f,  f, r, 1");
                Lista.Add("Hasta     , f,  t,  f,  f, r, 1");
                Lista.Add("Hasta     , f,  t,  f,  f, r, 1");
                Lista.Add("Sucursal  , f,  t,  f,  f, r, 1");
                Lista.Add("RangoF    , f,  t,  t,  f, r, 1");
                Lista.Add("TipoDoc   , f,  t,  t,  f, r, 1");
                Lista.Add("btnDist   , f,  t,  f,  f, n, 1");
                FSBOf.SetAutoManaged(oForm, Lista);

                //carga tipo documentos
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select distinct U_TipoDoc 'Code', U_TipoDoc 'Name' from [@VID_FECAF]";
                }
                else
                {
                    s = @"select distinct ""U_TipoDoc"" ""Code"", ""U_TipoDoc"" ""Name"" from ""@VID_FECAF"" ";
                }
                oRecordSet.DoQuery(s);
                FSBOf.FillCombo((ComboBox)(oForm.Items.Item("TipoDoc").Specific), ref oRecordSet, true);

                //carga sucursales
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = "select Code, Name from [@VID_FESUC]";
                }
                else
                {
                    s = @"select ""Code"", ""Name"" from ""@VID_FESUC"" ";
                }
                oRecordSet.DoQuery(s);
                FSBOf.FillCombo((ComboBox)(oForm.Items.Item("Sucursal").Specific), ref oRecordSet, true);

                //        AddChooseFromList();
                oMtx = (Matrix)(oForm.Items.Item("mtx").Specific);
                //        oColumn                    := SAPbouiCOM.Column(oMtx.Columns.Item('V_0'));
                //        oColumn.ChooseFromListUID  := 'CFL0';
                //        oColumn.ChooseFromListAlias:= 'Code';

                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select C1.FldValue 'Code', C1.Descr 'Name'
                           from CUFD C0
                           join UFD1 C1 on C1.TableID = C0.TableID
                                       and C1.FieldID = C0.FieldID
                          where C0.TableID = '@VID_FEDISTD'
                            and C0.AliasID = 'Estado'";
                }
                else
                {
                    s = @"select C1.""FldValue"" ""Code"", C1.""Descr"" ""Name""
                           from ""CUFD"" C0
                           join ""UFD1"" C1 on C1.""TableID"" = C0.""TableID""
                                       and C1.""FieldID"" = C0.""FieldID""
                          where C0.""TableID"" = '@VID_FEDISTD'
                            and C0.""AliasID"" = 'Estado' ";
                }
                oRecordSet.DoQuery(s);
                oColumn = (SAPbouiCOM.Column)(oMtx.Columns.Item("Estado"));
                FSBOf.FillComboMtx(oColumn, ref oRecordSet, false);

                oDBDSD.InsertRecord(0);
                oMtx.LoadFromDataSource();
                oMtx.AutoResizeColumns();

                //EditText(oForm.Items.Item('CardCode').Specific).Active := True;
                oForm.Mode = BoFormMode.fm_OK_MODE;
            }
            catch (Exception e)
            {
                OutLog("InitForm: " + e.Message + " ** Trace: " + e.StackTrace);
                FSBOApp.MessageBox(e.Message + " ** Trace: " + e.StackTrace, 1, "Ok", "", "");
            }
            oForm.Freeze(false);

            return(Result);
        }//fin InitForm
Exemple #4
0
        public new bool InitForm(string uid, string xmlPath, ref Application application, ref SAPbobsCOM.Company company, ref CSBOFunctions SBOFunctions, ref TGlobalVid _GlobalSettings)
        {
            //SAPbouiCOM.ComboBox oComboBox;
            //SAPbouiCOM.Column oColumn;

            Param       = new TFunctions();
            Param.SBO_f = FSBOf;

            bool Result = base.InitForm(uid, xmlPath, ref application, ref company, ref SBOFunctions, ref _GlobalSettings);

            try
            {
                oRecordSet = (SAPbobsCOM.Recordset)(FCmpny.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset));

                //Lista    := New list<string>;

                FSBOf.LoadForm(xmlPath, "VID_GELibro.srf", uid);
                //EnableCrystal := true;
                oForm = FSBOApp.Forms.Item(uid);
                oForm.Freeze(true);
                oForm.AutoManaged    = false;
                oForm.SupportedModes = -1;       // afm_All

                oForm.EnableMenu("1281", false); //Actualizar
                oForm.EnableMenu("1282", false); //Crear

                oForm.DataSources.UserDataSources.Add("TipoLibro", BoDataType.dt_SHORT_TEXT);
                oComboBox = (ComboBox)(oForm.Items.Item("TipoLibro").Specific);
                oComboBox.DataBind.SetBound(true, "", "TipoLibro");
                oComboBox.ValidValues.Add("V", "Venta");
                oComboBox.ValidValues.Add("C", "Compra");
                oComboBox.Select("V", BoSearchKey.psk_ByValue);

                oForm.DataSources.UserDataSources.Add("Periodo", BoDataType.dt_SHORT_TEXT);
                oComboBox = (ComboBox)(oForm.Items.Item("Periodo").Specific);
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    oRecordSet.DoQuery("select CAST(AbsEntry AS VARCHAR(20)) Code, Code 'Name'  from OFPR where YEAR(F_RefDate) >= YEAR(GETDATE())-1  AND YEAR(T_RefDate) <= YEAR(GETDATE())");
                }
                else
                {
                    oRecordSet.DoQuery(@"select TO_VARCHAR(""AbsEntry"") ""Code"", ""Code"" ""Name""  from ""OFPR"" where YEAR(""F_RefDate"") >= YEAR(NOW())-1  AND YEAR(""T_RefDate"") <= YEAR(NOW()) ");
                }
                FSBOf.FillCombo((ComboBox)(oForm.Items.Item("Periodo").Specific), ref oRecordSet, false);
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select AbsEntry from OFPR where GETDATE() BETWEEN F_RefDate AND T_RefDate";
                }
                else
                {
                    s = @"select ""AbsEntry"" from ""OFPR"" where NOW() BETWEEN ""F_RefDate"" AND ""T_RefDate"" ";
                }
                oRecordSet.DoQuery(s);
                oComboBox.Select(((System.Int32)oRecordSet.Fields.Item("AbsEntry").Value).ToString(), BoSearchKey.psk_ByValue);


                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select ISNULL(U_MultiSoc,'N') MultiSoc from [@VID_FEPARAM]";
                }
                else
                {
                    s = @"select IFNULL(""U_MultiSoc"",'N') ""MultiSoc"" from ""@VID_FEPARAM"" ";
                }
                oRecordSet.DoQuery(s);
                if (oRecordSet.RecordCount > 0)
                {
                    if (((System.String)oRecordSet.Fields.Item("MultiSoc").Value) == "Y")
                    {
                        bMultiSoc = true;
                    }
                }

                if (bMultiSoc)
                {
                    oForm.Items.Item("LInstituto").Visible = true;
                    oForm.Items.Item("Instituto").Visible  = true;
                    oComboBox = (ComboBox)(oForm.Items.Item("Instituto").Specific);
                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"select DocEntry, U_Sociedad 'Sociedad' from [@VID_FEMULTISOC] where isnull(U_Habilitada,'N') = 'Y'";
                    }
                    else
                    {
                        s = @"select ""DocEntry"", ""U_Sociedad"" ""Sociedad"" from ""@VID_FEMULTISOC"" where IFNULL(""U_Habilitada"",'N') = 'Y' ";
                    }
                    oRecordSet.DoQuery(s);
                    while (!oRecordSet.EoF)
                    {
                        oComboBox.ValidValues.Add(((System.Int32)oRecordSet.Fields.Item("DocEntry").Value).ToString(), ((System.String)oRecordSet.Fields.Item("Sociedad").Value).Trim());
                        oRecordSet.MoveNext();
                    }
                }
                else
                {
                    oForm.Items.Item("LInstituto").Visible = false;
                    oForm.Items.Item("Instituto").Visible  = false;
                }
            }
            catch (Exception e)
            {
                OutLog("InitForm: " + e.Message + " ** Trace: " + e.StackTrace);
                FSBOApp.MessageBox(e.Message + " ** Trace: " + e.StackTrace, 1, "Ok", "", "");
            }
            oForm.Freeze(false);
            return(Result);
        }//fin InitForm
        public new bool InitForm(string uid, string xmlPath, ref Application application, ref SAPbobsCOM.Company company, ref CSBOFunctions SBOFunctions, ref TGlobalVid _GlobalSettings)
        {
            Int32 CantRol;

            bool Result = base.InitForm(uid, xmlPath, ref application, ref company, ref SBOFunctions, ref _GlobalSettings);

            oRecordSet      = (SAPbobsCOM.Recordset)(FCmpny.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset));
            Funciones.SBO_f = FSBOf;
            try
            {
                Lista = new List <string>();

                FSBOf.LoadForm(xmlPath, "VID_FELibrosElect.srf", uid);
                //EnableCrystal := true;
                oForm = FSBOApp.Forms.Item(uid);
                oForm.Freeze(true);
                oForm.AutoManaged    = false;
                oForm.SupportedModes = -1;

                oForm.DataSources.UserDataSources.Add("Periodo", BoDataType.dt_SHORT_TEXT, 10);
                ((ComboBox)oForm.Items.Item("Periodo").Specific).DataBind.SetBound(true, "", "Periodo");

                oForm.DataSources.UserDataSources.Add("PeriodoD", BoDataType.dt_SHORT_TEXT, 10);
                ((ComboBox)oForm.Items.Item("PeriodoD").Specific).DataBind.SetBound(true, "", "PeriodoD");

                oForm.DataSources.UserDataSources.Add("PeriodoH", BoDataType.dt_SHORT_TEXT, 10);
                ((ComboBox)oForm.Items.Item("PeriodoH").Specific).DataBind.SetBound(true, "", "PeriodoH");

                odt            = oForm.DataSources.DataTables.Add("grid");
                grid           = ((Grid)oForm.Items.Item("grid").Specific);
                grid.DataTable = odt;


                if ((TipoLibro == "D") || (TipoLibro == "M")) //Libro Mayor y Diario
                {
                    s = "Periodo";
                    oForm.Items.Item(s).Click(BoCellClickType.ct_Regular);
                    if (TipoLibro == "D")
                    {
                        oForm.Title = "Libro Diario y Mayor";
                    }

                    oForm.PaneLevel = 1;
                    oForm.Items.Item("5").Visible        = false;
                    oForm.Items.Item("PeriodoD").Visible = false;
                    oForm.Items.Item("7").Visible        = false;
                    oForm.Items.Item("PeriodoH").Visible = false;

                    oForm.Items.Item("grid").Height   = 210;
                    oForm.Items.Item("grid2").Visible = true;

                    odt2            = oForm.DataSources.DataTables.Add("grid2");
                    grid2           = ((Grid)oForm.Items.Item("grid2").Specific);
                    grid2.DataTable = odt2;

                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT CAST(AbsEntry AS VARCHAR(20)) 'Code', Code 'Name'
                              FROM OFPR
                             WHERE Category BETWEEN YEAR(GETDATE()) -1 AND YEAR(GETDATE())";
                    }
                    else
                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT TO_VARCHAR(""AbsEntry"") ""Code"", ""Code"" ""Name""
                              FROM ""OFPR""
                             WHERE ""Category"" BETWEEN EXTRACT(YEAR FROM CURRENT_DATE) -1 AND EXTRACT(YEAR FROM CURRENT_DATE)";
                    }
                    oRecordSet.DoQuery(s);

                    oComboBox = ((ComboBox)oForm.Items.Item("Periodo").Specific);
                    FSBOf.FillCombo(oComboBox, ref oRecordSet, false);

                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT CAST(AbsEntry AS VARCHAR(20)) 'Code' FROM OFPR WHERE CONVERT(CHAR(6), F_RefDate, 112) = CONVERT(CHAR(6), GETDATE(), 112)";
                    }
                    else
                    {
                        s = @"SELECT TO_VARCHAR(""AbsEntry"") ""Code"" FROM ""OFPR"" WHERE TO_VARCHAR(""F_RefDate"", 'yyyyMM') = TO_VARCHAR(CURRENT_DATE, 'yyyyMM')";
                    }
                    oRecordSet.DoQuery(s);
                    oComboBox.Select(((System.String)oRecordSet.Fields.Item("Code").Value), BoSearchKey.psk_ByValue);
                }
                else if (TipoLibro == "B")//Balance
                {
                    s = "PeriodoD";
                    oForm.Items.Item(s).Click(BoCellClickType.ct_Regular);
                    oForm.Title     = "Balance";
                    oForm.PaneLevel = 1;
                    oForm.Items.Item("4").Visible       = false;
                    oForm.Items.Item("Periodo").Visible = false;

                    oForm.Items.Item("grid").Height   = 210;
                    oForm.Items.Item("grid2").Visible = true;

                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT CAST(AbsEntry AS VARCHAR(20)) 'Code', Code 'Name'
                              FROM OFPR
                             WHERE Category BETWEEN YEAR(GETDATE()) -1 AND YEAR(GETDATE())";
                    }
                    else
                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT TO_VARCHAR(""AbsEntry"") ""Code"", ""Code"" ""Name""
                              FROM ""OFPR""
                             WHERE ""Category"" BETWEEN EXTRACT(YEAR FROM CURRENT_DATE) -1 AND EXTRACT(YEAR FROM CURRENT_DATE)";
                    }
                    oRecordSet.DoQuery(s);
                    oForm.Items.Item("PeriodoD").DisplayDesc = true;
                    oComboBox = ((ComboBox)oForm.Items.Item("PeriodoD").Specific);
                    FSBOf.FillCombo(oComboBox, ref oRecordSet, false);

                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT CAST(AbsEntry AS VARCHAR(20)) 'Code' FROM OFPR WHERE CONVERT(CHAR(6), F_RefDate, 112) = CONVERT(CHAR(6), GETDATE(), 112)";
                    }
                    else
                    {
                        s = @"SELECT TO_VARCHAR(""AbsEntry"") ""Code"" FROM ""OFPR"" WHERE TO_VARCHAR(""F_RefDate"", 'yyyyMM') = TO_VARCHAR(CURRENT_DATE, 'yyyyMM')";
                    }
                    oRecordSet.DoQuery(s);
                    oComboBox.Select(((System.String)oRecordSet.Fields.Item("Code").Value), BoSearchKey.psk_ByValue);

                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT CAST(AbsEntry AS VARCHAR(20)) 'Code', Code 'Name'
                              FROM OFPR
                             WHERE Category BETWEEN YEAR(GETDATE()) -1 AND YEAR(GETDATE())";
                    }
                    else
                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT TO_VARCHAR(""AbsEntry"") ""Code"", ""Code"" ""Name""
                              FROM ""OFPR""
                             WHERE ""Category"" BETWEEN EXTRACT(YEAR FROM CURRENT_DATE) -1 AND EXTRACT(YEAR FROM CURRENT_DATE)";
                    }
                    oRecordSet.DoQuery(s);
                    oForm.Items.Item("PeriodoH").DisplayDesc = true;
                    oComboBox = ((ComboBox)oForm.Items.Item("PeriodoH").Specific);
                    FSBOf.FillCombo(oComboBox, ref oRecordSet, false);

                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT CAST(AbsEntry AS VARCHAR(20)) 'Code' FROM OFPR WHERE CONVERT(CHAR(6), F_RefDate, 112) = CONVERT(CHAR(6), GETDATE(), 112)";
                    }
                    else
                    {
                        s = @"SELECT TO_VARCHAR(""AbsEntry"") ""Code"" FROM ""OFPR"" WHERE TO_VARCHAR(""F_RefDate"", 'yyyyMM') = TO_VARCHAR(CURRENT_DATE, 'yyyyMM')";
                    }
                    oRecordSet.DoQuery(s);
                    oComboBox.Select(((System.String)oRecordSet.Fields.Item("Code").Value), BoSearchKey.psk_ByValue);

                    odt2            = oForm.DataSources.DataTables.Add("grid2");
                    grid2           = ((Grid)oForm.Items.Item("grid2").Specific);
                    grid2.DataTable = odt2;
                }
                else if (TipoLibro == "C") //para Diccionario de cuentas
                {
                    oForm.Title = "Diccionario";
                    //oForm.PaneLevel = 2;
                    oForm.Items.Item("btnExp").Enabled = true;
                    oForm.PaneLevel = 1;
                    oForm.Items.Item("5").Visible        = false;
                    oForm.Items.Item("PeriodoD").Visible = false;
                    oForm.Items.Item("7").Visible        = false;
                    oForm.Items.Item("PeriodoH").Visible = false;

                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT CAST(AbsEntry AS VARCHAR(20)) 'Code', Code 'Name'
                              FROM OFPR
                             WHERE Category BETWEEN YEAR(GETDATE()) -1 AND YEAR(GETDATE())";
                    }
                    else
                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT TO_VARCHAR(""AbsEntry"") ""Code"", ""Code"" ""Name""
                              FROM ""OFPR""
                             WHERE ""Category"" BETWEEN EXTRACT(YEAR FROM CURRENT_DATE) -1 AND EXTRACT(YEAR FROM CURRENT_DATE)";
                    }
                    oRecordSet.DoQuery(s);

                    oComboBox = ((ComboBox)oForm.Items.Item("Periodo").Specific);
                    FSBOf.FillCombo(oComboBox, ref oRecordSet, false);

                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = @"SELECT CAST(AbsEntry AS VARCHAR(20)) 'Code' FROM OFPR WHERE CONVERT(CHAR(6), F_RefDate, 112) = CONVERT(CHAR(6), GETDATE(), 112)";
                    }
                    else
                    {
                        s = @"SELECT TO_VARCHAR(""AbsEntry"") ""Code"" FROM ""OFPR"" WHERE TO_VARCHAR(""F_RefDate"", 'yyyyMM') = TO_VARCHAR(CURRENT_DATE, 'yyyyMM')";
                    }
                    oRecordSet.DoQuery(s);
                    oComboBox.Select(((System.String)oRecordSet.Fields.Item("Code").Value), BoSearchKey.psk_ByValue);
                }
            }
            catch (Exception e)
            {
                OutLog("InitForm: " + e.Message + " ** Trace: " + e.StackTrace);
                FSBOApp.MessageBox(e.Message + " ** Trace: " + e.StackTrace, 1, "Ok", "", "");
            }
            finally
            {
                oForm.Freeze(false);
            }


            return(Result);
        }//fin InitForm