예제 #1
0
        public new bool InitForm(string uid, string xmlPath, ref Application application, ref SAPbobsCOM.Company company, ref CSBOFunctions SBOFunctions, ref TGlobalVid _GlobalSettings)
        {
            bool Result = base.InitForm(uid, xmlPath, ref application, ref company, ref SBOFunctions, ref _GlobalSettings);

            try
            {
                oRecordSet = (SAPbobsCOM.Recordset)(FCmpny.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset));
                FSBOf.LoadForm(xmlPath, "VID_FEIMPADIC.srf", uid);
                oForm                = FSBOApp.Forms.Item(uid);
                oForm.AutoManaged    = false;
                oForm.SupportedModes = -1;             // afm_All
                Flag = false;
                oForm.Freeze(true);

                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select count(*) Cont from [@VID_FEIMPADIC]";
                }
                else
                {
                    s = @"select count(*) ""Cont"" from ""@VID_FEIMPADIC"" ";
                }
                oRecordSet.DoQuery(s);
                if ((System.Int32)(oRecordSet.Fields.Item("Cont").Value) > 0)
                {
                    oForm.Mode = BoFormMode.fm_UPDATE_MODE;
                }
                else
                {
                    oForm.Mode = BoFormMode.fm_ADD_MODE;
                }


                oGrid       = (Grid)(oForm.Items.Item("3").Specific);
                oDBDSHeader = oForm.DataSources.DBDataSources.Add("@VID_FEIMPADIC");

                oDataTable = oForm.DataSources.DataTables.Add("Tax");
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select Code, U_CodImpto, U_Desc, U_Porc from [@VID_FEIMPADIC]
                          UNION ALL 
                          select CAST('' as varchar(20)), CAST('' as varchar(20)), CAST('' as varchar(50)), 0";
                }
                else
                {
                    s = @"select ""Code"", ""U_CodImpto"", ""U_Desc"", ""U_Porc"" from ""@VID_FEIMPADIC""
                          UNION ALL
                          select CAST('' as varchar(20)), CAST('' as varchar(20)), CAST('' as varchar(50)), 0 FROM DUMMY ";
                }

                oDataTable.ExecuteQuery(s);
                oGrid.DataTable = oDataTable;

                oGrid.Columns.Item("Code").Type = BoGridColumnType.gct_ComboBox;
                oColumn = (GridColumn)(oGrid.Columns.Item("Code"));
                var oComboCol = (ComboBoxColumn)(oColumn);
                oComboCol.Editable            = true;
                oComboCol.TitleObject.Caption = "Impuesto SAP";

                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select Code, Name from OSTA
                          UNION ALL
                          select WTCode 'Code', WTName 'Name' from OWHT where Inactive = 'N'";
                }
                else
                {
                    s = @"select ""Code"", ""Name"" from ""OSTA""
                          UNION ALL
                          select ""WTCode"" ""Code"", ""WTName"" ""Name"" from ""OWHT"" where ""Inactive"" = 'N' ";
                }

                oRecordSet.DoQuery(s);
                FSBOf.FillComboGrid((GridColumn)(oGrid.Columns.Item("Code")), ref oRecordSet, true);

                oGrid.Columns.Item("U_CodImpto").Type = BoGridColumnType.gct_EditText;
                oColumn = (GridColumn)(oGrid.Columns.Item("U_CodImpto"));
                var oEditCol = (EditTextColumn)(oColumn);
                oEditCol.Editable            = true;
                oEditCol.TitleObject.Caption = "Código Impto. SII";


                oGrid.Columns.Item("U_Desc").Type = BoGridColumnType.gct_EditText;
                oColumn                      = (GridColumn)(oGrid.Columns.Item("U_Desc"));
                oEditCol                     = (EditTextColumn)(oColumn);
                oEditCol.Editable            = true;
                oEditCol.TitleObject.Caption = "Descripción Impuesto";

                oGrid.Columns.Item("U_Porc").Type = BoGridColumnType.gct_EditText;
                oColumn                      = (GridColumn)(oGrid.Columns.Item("U_Porc"));
                oEditCol                     = (EditTextColumn)(oColumn);
                oEditCol.Editable            = true;
                oEditCol.TitleObject.Caption = "Porcentaje Retencion";
                oEditCol.RightJustified      = true;

                oGrid.AutoResizeColumns();
            }
            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
        }//fin MenuEvent

        private void Grilla()
        {
            try
            {
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"SELECT T0.U_Sucursal
                              ,T0.U_TipoDoc
	                          ,COUNT(*) 'Asignados'
	                          ,SUM(CASE WHEN T1.U_Estado = 'D' THEN 1 ELSE 0 END) 'Disponibles'
	                          ,SUM(CASE WHEN T1.U_Estado = 'U' THEN 1 ELSE 0 END) 'Utilizados'
                          FROM [@VID_FEDIST] T0 WITH(nolock)
                          JOIN [@VID_FEDISTD] T1 WITH(nolock) ON T1.DocEntry = T0.DocEntry
                          GROUP BY
                               T0.U_Sucursal
                              ,T0.U_TipoDoc
                         ORDER BY T0.U_Sucursal, T0.U_TipoDoc";
                }
                else
                {
                    s = @"SELECT T0.""U_Sucursal""
                              ,T0.""U_TipoDoc""
	                          ,COUNT(*) ""Asignados""
	                          ,SUM(CASE WHEN T1.""U_Estado"" = 'D' THEN 1 ELSE 0 END) ""Disponibles""
	                          ,SUM(CASE WHEN T1.""U_Estado"" = 'U' THEN 1 ELSE 0 END) ""Utilizados""
                          FROM ""@VID_FEDIST"" T0 
                          JOIN ""@VID_FEDISTD"" T1 ON T1.""DocEntry"" = T0.""DocEntry""
                          GROUP BY
                               T0.""U_Sucursal""
                              ,T0.""U_TipoDoc""
                         ORDER BY T0.""U_Sucursal"", T0.""U_TipoDoc"" ";
                }
                oDataTable.ExecuteQuery(s);

                ogrid.Columns.Item("U_Sucursal").Type = BoGridColumnType.gct_EditText;
                oColumn = (GridColumn)(ogrid.Columns.Item("U_Sucursal"));
                //EditTextColumn(oColumn).LinkedObjectType := '86';
                oColumn.Editable            = false;
                oColumn.Visible             = false;
                oColumn.TitleObject.Caption = "Código";

                ogrid.Columns.Item("U_TipoDoc").Type = BoGridColumnType.gct_EditText;
                oColumn = (GridColumn)(ogrid.Columns.Item("U_TipoDoc"));
                //EditTextColumn(oColumn).LinkedObjectType := '86';
                oColumn.Editable            = false;
                oColumn.RightJustified      = true;
                oColumn.TitleObject.Caption = "Tipo Documento";

                ogrid.Columns.Item("Asignados").Type = BoGridColumnType.gct_EditText;
                oColumn = (GridColumn)(ogrid.Columns.Item("Asignados"));
                //EditTextColumn(oColumn).LinkedObjectType := '86';
                oColumn.Editable            = false;
                oColumn.RightJustified      = true;
                oColumn.TitleObject.Caption = "Total Asignados";

                ogrid.Columns.Item("Disponibles").Type = BoGridColumnType.gct_EditText;
                oColumn = (GridColumn)(ogrid.Columns.Item("Disponibles"));
                //EditTextColumn(oColumn).LinkedObjectType := '86';
                oColumn.Editable            = false;
                oColumn.RightJustified      = true;
                oColumn.TitleObject.Caption = "Total Disponibles";

                ogrid.Columns.Item("Utilizados").Type = BoGridColumnType.gct_EditText;
                oColumn = (GridColumn)(ogrid.Columns.Item("Utilizados"));
                //EditTextColumn(oColumn).LinkedObjectType := '86';
                oColumn.Editable            = false;
                oColumn.RightJustified      = true;
                oColumn.TitleObject.Caption = "Total Utilizados";

                ogrid.AutoResizeColumns();
            }
            catch (Exception e)
            {
                FSBOApp.MessageBox(e.Message + " ** Trace: " + e.StackTrace, 1, "Ok", "", "");
                OutLog("Grilla: " + e.Message + " ** Trace: " + e.StackTrace);
            }
        }//fin Grilla
        }//fin FormEvent

        private void CargarDatosPE()
        {
            SAPbouiCOM.EditTextColumn oEditColumn;
            SAPbouiCOM.CheckBox       oChkRechazados;
            SAPbouiCOM.CheckBox       oChkPendientes;
            SAPbouiCOM.CheckBox       oChkAceptados;
            SAPbouiCOM.CheckBox       oChkDadoBaja;
            SAPbouiCOM.CheckBox       oChkErrores;
            String FechaD, FechaH, Status;

            try
            {
                oForm.Freeze(true);
                oChkRechazados = (CheckBox)(oForm.Items.Item("Rechazados").Specific);
                oChkPendientes = (CheckBox)(oForm.Items.Item("Pendientes").Specific);
                oChkAceptados  = (CheckBox)(oForm.Items.Item("Aceptados").Specific);
                oChkDadoBaja   = (CheckBox)(oForm.Items.Item("DadoBaja").Specific);
                oChkErrores    = (CheckBox)(oForm.Items.Item("Errores").Specific);

                if ((oChkRechazados.Checked) || (oChkPendientes.Checked) || (oChkAceptados.Checked) || (oChkErrores.Checked))
                {
                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        Status = "and T0.U_Status in (";
                        Status = Status + (oChkRechazados.Checked ? "'RZ'," : "");
                        Status = Status + (oChkPendientes.Checked ? "'EC'," : "");
                        Status = Status + (oChkAceptados.Checked ? "'RR'," : "");
                        Status = Status + (oChkDadoBaja.Checked ? "'DB'," : "");
                        Status = Status + (oChkErrores.Checked ? "'EE'," : "");
                        Status = Status.Substring(0, Status.Length - 1);
                        Status = Status + ")";
                    }
                    else
                    {
                        Status = @"and T0.""U_Status"" in (";
                        Status = Status + (oChkRechazados.Checked ? "'RZ'," : "");
                        Status = Status + (oChkPendientes.Checked ? "'EC'," : "");
                        Status = Status + (oChkAceptados.Checked ? "'RR'," : "");
                        Status = Status + (oChkDadoBaja.Checked ? "'DB'," : "");
                        Status = Status + (oChkErrores.Checked ? "'EE'," : "");
                        Status = Status.Substring(0, Status.Length - 1);
                        Status = Status + ")";
                    }
                }
                else if ((!oChkRechazados.Checked) && (!oChkPendientes.Checked) && (!oChkAceptados.Checked) && (!oChkDadoBaja.Checked) && (!oChkErrores.Checked))
                {
                    //en caso de no encontrar ninguno marcado sale de la funcion
                    oForm.Freeze(false);
                    return;
                }
                else
                {
                    Status = "";
                }



                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"SELECT 
                               LTRIM(STR(T0.U_DocEntry,18,0))	'DocEntry'
	                          ,CASE U_ObjType
		                        WHEN '13' THEN (SELECT DocNum FROM OINV WHERE DocEntry = T0.U_DocEntry)
		                        WHEN '14' THEN (SELECT DocNum FROM ORIN WHERE DocEntry = T0.U_DocEntry)
		                        WHEN '15' THEN (SELECT DocNum FROM ODLN WHERE DocEntry = T0.U_DocEntry)
		                        WHEN '67' THEN (SELECT DocNum FROM OWTR WHERE DocEntry = T0.U_DocEntry)
                                WHEN '21' THEN (SELECT DocNum FROM ORPD WHERE DocEntry = T0.U_DocEntry)
	                           END				'DocNum'
                              ,T0.U_TipoDoc		'TipoDoc'
                              ,ISNULL(T0.U_SeriePE,'')  'SeriePE'
                              ,LTRIM(STR(T0.U_FolioNum,18,0))	'Folio'
                              ,(SELECT C1.Descr FROM CUFD C0 JOIN UFD1 C1 ON C1.TableID=C0.TableID AND C1.FieldID=C0.FieldID WHERE C0.TableID = '@VID_FELOG' AND C0.AliasID='Status' AND C1.FldValue= T0.U_Status)	'Estado'
                              ,T0.U_Status
                              ,T0.U_Message		'Mensaje'
                              ,T0.U_ObjType     'ObjType'
                              ,T0.U_Path		'Path'
                              ,T0.U_ExtFolio	'ExtFolio'
                              ,T0.DocEntry		'Key'
                              ,ISNULL(T0.U_Id,'0') 'Id'
                              ,ISNULL(T0.U_Validation,'') 'Validation'
                          FROM [@vid_felog] T0 WITH (NOLOCK)
                          JOIN OUSR T2 ON T2.USER_CODE = T0.U_UserCode
                         WHERE {0}
                           {3}
                           AND ISNULL(T0.U_DocDate, T0.CreateDate) BETWEEN '{1}' AND '{2}'
                           
                         ORDER BY T0.DocEntry DESC";
                }
                else
                {
                    s = @"SELECT  
                               LTRIM(TO_ALPHANUM(T0.""U_DocEntry""))	""DocEntry""
	                          ,CASE ""U_ObjType""
		                        WHEN '13' THEN (SELECT ""DocNum"" FROM ""OINV"" WHERE ""DocEntry"" = T0.""U_DocEntry"")
		                        WHEN '14' THEN (SELECT ""DocNum"" FROM ""ORIN"" WHERE ""DocEntry"" = T0.""U_DocEntry"")
		                        WHEN '15' THEN (SELECT ""DocNum"" FROM ""ODLN"" WHERE ""DocEntry"" = T0.""U_DocEntry"")
		                        WHEN '67' THEN (SELECT ""DocNum"" FROM ""OWTR"" WHERE ""DocEntry"" = T0.""U_DocEntry"")
                                WHEN '21' THEN (SELECT ""DocNum"" FROM ""ORPD"" WHERE ""DocEntry"" = T0.""U_DocEntry"")
	                           END				""DocNum""
                              ,T0.""U_TipoDoc""		""TipoDoc""
                              ,IFNULL(T0.""U_SeriePE"",'')  ""SeriePE""
                              ,LTRIM(TO_ALPHANUM(T0.""U_FolioNum""))	""Folio""
                              ,(SELECT C1.""Descr"" FROM ""CUFD"" C0 JOIN ""UFD1"" C1 ON C1.""TableID""=C0.""TableID"" AND C1.""FieldID""=C0.""FieldID"" WHERE C0.""TableID"" = '@VID_FELOG' AND C0.""AliasID""='Status' AND C1.""FldValue""= T0.""U_Status"")	""Estado""
                              ,T0.""U_Status""
                              ,T0.""U_Message""		""Mensaje"" 
                              ,T0.""U_ObjType""     ""ObjType""
                              ,T0.""U_Path""		""Path""
                              ,T0.""U_ExtFolio""	""ExtFolio""
                              ,T0.""DocEntry""		""Key""
                              ,IFNULL(T0.""U_Id"",'0') ""Id""
                              ,IFNULL(T0.""U_Validation"",'') ""Validation""
                          FROM ""@VID_FELOG"" T0 
                          JOIN ""OUSR"" T2 on T2.""USER_CODE"" = T0.""U_UserCode""
                         WHERE {0}
                           {3}
                           AND IFNULL(T0.""U_DocDate"", T0.""CreateDate"") BETWEEN '{1}' AND '{2}'
                         ORDER BY T0.""DocEntry"" DESC ";
                }

                oCheckBox = (CheckBox)(oForm.Items.Item("chk_Todo").Specific);
                oEditText = (EditText)(oForm.Items.Item("FechaD").Specific);
                FechaD    = (System.String)(oEditText.Value).Trim();

                oEditText = (EditText)(oForm.Items.Item("FechaH").Specific);
                FechaH    = (System.String)(oEditText.Value).Trim();

                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = String.Format(s, !oCheckBox.Checked ? "T0.U_UserCode = '" + FSBOApp.Company.UserName + "'" : "1=1", FechaD, FechaH, Status);
                }
                else
                {
                    s = String.Format(s, !oCheckBox.Checked ? @"T0.""U_UserCode"" = '" + FSBOApp.Company.UserName + "'" : "1=1", FechaD, FechaH, Status);
                }
                oDataTable.ExecuteQuery(s);

                oGrid.Columns.Item("TipoDoc").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("TipoDoc"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Tipo Documento";

                oGrid.Columns.Item("DocEntry").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("DocEntry"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Llave SAP";
                oEditColumn.LinkedObjectType    = "13";
                oEditColumn.RightJustified      = true;

                oGrid.Columns.Item("DocNum").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("DocNum"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Número SAP";
                oEditColumn.RightJustified      = true;

                oGrid.Columns.Item("SeriePE").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("SeriePE"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Número Serie";
                oEditColumn.RightJustified      = true;

                oGrid.Columns.Item("Folio").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("Folio"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Número Correlativo";
                oEditColumn.RightJustified      = true;

                oGrid.Columns.Item("Estado").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("Estado"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Estado";

                oGrid.Columns.Item("U_Status").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("U_Status"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "U_Status";
                oEditColumn.Visible             = false;

                oGrid.Columns.Item("Mensaje").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("Mensaje"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Comentario";

                oGrid.Columns.Item("ObjType").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("ObjType"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "ObjType";
                oEditColumn.Visible             = false;

                oGrid.Columns.Item("Path").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("Path"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Documento";
                oEditColumn.Visible             = false;

                oGrid.Columns.Item("ExtFolio").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("ExtFolio"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "IdDocumento";
                oEditColumn.Visible             = true;

                oGrid.Columns.Item("Key").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("Key"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Key";
                oEditColumn.Visible             = false;

                oGrid.Columns.Item("Id").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("Id"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Id";
                oEditColumn.Visible             = false;

                oGrid.Columns.Item("Validation").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(oGrid.Columns.Item("Validation"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Validation";
                oEditColumn.Visible             = false;

                oGrid.AutoResizeColumns();
            }
            catch (Exception e)
            {
                OutLog("CargarDatosPE : " + e.Message + " ** Trace: " + e.StackTrace);
                FSBOApp.StatusBar.SetText("CargarDatosPE : " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
            }
            oForm.Freeze(false);
        } //fin CargarDatosPE
        }//fin InitForm

        public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent)
        {
            IvkFormInterface oFormVk;
            String           oUid;
            String           prmKey;

            SAPbouiCOM.EditTextColumn oEditColumn;

            base.FormEvent(FormUID, ref pVal, ref BubbleEvent);
            try
            {
                if ((pVal.EventType == BoEventTypes.et_MATRIX_LINK_PRESSED) && (pVal.BeforeAction) && (pVal.ItemUID == "grid"))
                {
                    s           = (System.String)(oDataTable.GetValue("ObjType", pVal.Row));
                    oColumn     = (GridColumn)(oGrid.Columns.Item("DocEntry"));
                    oEditColumn = (EditTextColumn)(oColumn);
                    oEditColumn.LinkedObjectType = s;
                }

                if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (!pVal.BeforeAction))
                {
                    if (pVal.ItemUID == "ActGrilla")
                    {
                        CargarDatosPE();
                    }

                    if (pVal.ItemUID == "chk_Todo")
                    {
                        CargarDatosPE();
                    }

                    if (pVal.ItemUID == "Rechazados")
                    {
                        CargarDatosPE();
                    }

                    if (pVal.ItemUID == "Pendientes")
                    {
                        CargarDatosPE();
                    }

                    if (pVal.ItemUID == "Aceptados")
                    {
                        CargarDatosPE();
                    }

                    if (pVal.ItemUID == "DadoBaja")
                    {
                        CargarDatosPE();
                    }

                    if (pVal.ItemUID == "Errores")
                    {
                        CargarDatosPE();
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_VALIDATE) && (pVal.BeforeAction) && (pVal.ItemUID == "FechaD"))
                {
                    oEditText = (EditText)(oForm.Items.Item("FechaD").Specific);
                    if ((System.String)(oEditText.Value) == "")
                    {
                        FSBOApp.StatusBar.SetText("Debe ingresar una fecha desde", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning);
                        BubbleEvent = false;
                    }
                }

                if ((pVal.EventType == BoEventTypes.et_VALIDATE) && (pVal.BeforeAction) && (pVal.ItemUID == "FechaH"))
                {
                    oEditText = (EditText)(oForm.Items.Item("FechaH").Specific);
                    if ((System.String)(oEditText.Value) == "")
                    {
                        FSBOApp.StatusBar.SetText("Debe ingresar una fecha hasta", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning);
                        BubbleEvent = false;
                    }
                }
            }
            catch (Exception e)
            {
                if (FCmpny.InTransaction)
                {
                    FCmpny.EndTransaction(BoWfTransOpt.wf_RollBack);
                }

                FSBOApp.StatusBar.SetText(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 Application application, ref SAPbobsCOM.Company company, ref CSBOFunctions SBOFunctions, ref TGlobalVid _GlobalSettings)
        {
            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_FEDetalleLog.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

                //oForm.DataBrowser.BrowseBy := "DocNum";

                // 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);

                //s := '1';
                //oCombo.Select(s, BoSearchKey.psk_ByValue);

                oForm.Items.Item("grid").Enabled = false;
                ogrid           = (Grid)(oForm.Items.Item("grid").Specific);
                dt              = oForm.DataSources.DataTables.Add("dt");
                ogrid.DataTable = dt;

                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select U_TipoDoc
                              ,LTRIM(STR(U_FolioNum,18,0)) 'U_FolioNum'
                              ,U_ID_Log
                              ,U_Glosa
                              ,U_FechaIn
                          from [@VID_FELOG] T0
                          join [@VID_FELOGD] T1 ON T1.DocEntry = T0.DocEntry
                         where T0.DocEntry = {0}
                         order by T1.LineId DESC";
                }
                else
                {
                    s = @"select ""U_TipoDoc""
                              ,LTRIM(ROUND(""U_FolioNum"",0)) ""U_FolioNum""
                              ,""U_ID_Log""
                              ,""U_Glosa""
                              ,""U_FechaIn""
                          from ""@VID_FELOG"" T0 
                          join ""@VID_FELOGD"" T1 ON T1.""DocEntry"" = T0.""DocEntry""
                         where T0.""DocEntry"" = {0}
                         order by T1.""LineId"" DESC ";
                }

                s = String.Format(s, prmKey);
                dt.ExecuteQuery(s);
                ogrid.AutoResizeColumns();

                ogrid.Columns.Item("U_TipoDoc").Type = BoGridColumnType.gct_EditText;
                oColumn = (GridColumn)(ogrid.Columns.Item("U_TipoDoc"));
                var oEditColumn = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Tipo Documento";
                oEditColumn.RightJustified      = true;

                ogrid.Columns.Item("U_FolioNum").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(ogrid.Columns.Item("U_FolioNum"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Número Folio";
                oEditColumn.RightJustified      = true;

                ogrid.Columns.Item("U_ID_Log").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(ogrid.Columns.Item("U_ID_Log"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "ID Log Portal";
                oEditColumn.RightJustified      = true;

                ogrid.Columns.Item("U_Glosa").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(ogrid.Columns.Item("U_Glosa"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Glosa";
                oEditColumn.RightJustified      = false;

                ogrid.Columns.Item("U_FechaIn").Type = BoGridColumnType.gct_EditText;
                oColumn                         = (GridColumn)(ogrid.Columns.Item("U_FechaIn"));
                oEditColumn                     = (EditTextColumn)(oColumn);
                oEditColumn.Editable            = false;
                oEditColumn.TitleObject.Caption = "Fecha Movimiento";
                oEditColumn.RightJustified      = false;

                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
예제 #6
0
        public new bool InitForm(string uid, string xmlPath, ref Application application, ref SAPbobsCOM.Company company, ref CSBOFunctions SBOFunctions, ref TGlobalVid _GlobalSettings)
        {
            bool Result = base.InitForm(uid, xmlPath, ref application, ref company, ref SBOFunctions, ref _GlobalSettings);

            try
            {
                oRecordSet = (SAPbobsCOM.Recordset)(FCmpny.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset));
                FSBOf.LoadForm(xmlPath, "FM_NOTES.srf", uid);
                oForm                = FSBOApp.Forms.Item(uid);
                oForm.AutoManaged    = false;
                oForm.SupportedModes = -1;             // afm_All
                Flag = false;
                oForm.Freeze(true);

                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select count(*) Cont from [@FM_NOTES]";
                }
                else
                {
                    s = @"select count(*) ""Cont"" from ""@FM_NOTES"" ";
                }
                oRecordSet.DoQuery(s);
                if ((System.Int32)(oRecordSet.Fields.Item("Cont").Value) > 0)
                {
                    oForm.Mode = BoFormMode.fm_UPDATE_MODE;
                }
                else
                {
                    oForm.Mode = BoFormMode.fm_ADD_MODE;
                }


                oGrid       = (Grid)(oForm.Items.Item("3").Specific);
                oDBDSHeader = oForm.DataSources.DBDataSources.Add("@FM_NOTES");

                oDataTable = oForm.DataSources.DataTables.Add("Notes");
                if (GlobalSettings.RunningUnderSQLServer)
                {
                    s = @"select Code, Name, U_TypeCode from [@FM_NOTES]
                          UNION ALL 
                          select CAST('' as varchar(20)), CAST('' as varchar(20)), CAST('' as varchar(50))";
                }
                else
                {
                    s = @"select ""Code"", ""Name"", ""U_TypeCode"" from ""@FM_NOTES""
                          UNION ALL
                          select CAST('' as varchar(20)), CAST('' as varchar(20)), CAST('' as varchar(50)) FROM DUMMY ";
                }
                oDataTable.ExecuteQuery(s);
                oGrid.DataTable = oDataTable;

                oGrid.Columns.Item("Code").Type = BoGridColumnType.gct_EditText;
                oColumn = (GridColumn)(oGrid.Columns.Item("Code"));
                var oEditCol = (EditTextColumn)(oColumn);
                oEditCol.Editable            = true;
                oEditCol.TitleObject.Caption = "Codigo";

                oGrid.Columns.Item("Name").Type = BoGridColumnType.gct_EditText;
                oColumn                      = (GridColumn)(oGrid.Columns.Item("Name"));
                oEditCol                     = (EditTextColumn)(oColumn);
                oEditCol.Editable            = true;
                oEditCol.TitleObject.Caption = "Descripción";


                oGrid.Columns.Item("U_TypeCode").Type = BoGridColumnType.gct_EditText;
                oColumn                      = (GridColumn)(oGrid.Columns.Item("U_TypeCode"));
                oEditCol                     = (EditTextColumn)(oColumn);
                oEditCol.Editable            = true;
                oEditCol.TitleObject.Caption = "Codigo SUNAT";

                oGrid.AutoResizeColumns();
            }
            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