}//fin MenuEvent private void BuscarDatos() { String FechaD; String FechaH; String TipoDTE; try { oForm.Freeze(true); FechaD = ((System.String)((EditText)oForm.Items.Item("FechaD").Specific).Value); FechaH = ((System.String)((EditText)oForm.Items.Item("FechaH").Specific).Value); TipoDTE = ((System.String)((ComboBox)oForm.Items.Item("TipoDTE").Specific).Selected.Value).Trim(); if (GlobalSettings.RunningUnderSQLServer) { s = @"SELECT T0.DocEntry ,T0.U_TipoDoc TipoDoc ,T0.U_Folio Folio ,T0.U_RUT RUT ,T0.U_Razon Razon ,T0.U_FechaEmi FechaEmi ,CAST(REPLACE(CONVERT(CHAR(10), T0.U_FechaRecep, 102),'.','-') +' '+ CASE WHEN LEN(T0.U_HoraRecep) = 4 THEN LEFT(CAST(T0.U_HoraRecep AS VARCHAR(10)),2) + ':' + RIGHT(CAST(T0.U_HoraRecep AS VARCHAR(10)),2) + ':00' WHEN LEN(T0.U_HoraRecep) = 3 THEN '0' + LEFT(CAST(T0.U_HoraRecep AS VARCHAR(10)),1) + ':' + RIGHT(CAST(T0.U_HoraRecep AS VARCHAR(10)),2) + ':00' WHEN LEN(T0.U_HoraRecep) = 2 THEN '00:'+ CAST(T0.U_HoraRecep AS VARCHAR(10)) + ':00' WHEN LEN(T0.U_HoraRecep) = 1 THEN '00:0' + CAST(T0.U_HoraRecep AS VARCHAR(10)) + ':00' ELSE '00:00:00' END AS VARCHAR(50)) FechaRecep ,T0.U_Monto Monto ,T0.U_IVA IVA ,T0.U_EstadoC EstadoC ,T0.U_EstadoSII EstadoSII ,T0.U_EstadoLey EstadoLey ,CAST(T0.U_DocEntry AS INT) DocEntryDoc ,{4} 'xml' FROM [{2}] T0 WHERE 1 = 1 AND T0.{3} BETWEEN '{0}' AND '{1}'"; } else { s = @"SELECT T0.""DocEntry"" ,T0.""U_TipoDoc"" ""TipoDoc"" ,T0.""U_Folio"" ""Folio"" ,T0.""U_RUT"" ""RUT"" ,T0.""U_Razon"" ""Razon"" ,T0.""U_FechaEmi"" ""FechaEmi"" ,CAST(TO_VARCHAR(T0.""U_FechaRecep"", 'yyyy-MM-dd') ||' '|| CASE WHEN LENGTH(T0.""U_HoraRecep"") = 4 THEN LEFT(CAST(T0.""U_HoraRecep"" AS VARCHAR(10)),2) || ':' || RIGHT(CAST(T0.""U_HoraRecep"" AS VARCHAR(10)),2) || ':00' WHEN LENGTH(T0.""U_HoraRecep"") = 3 THEN '0' || LEFT(CAST(T0.""U_HoraRecep"" AS VARCHAR(10)),1) || ':' || RIGHT(CAST(T0.""U_HoraRecep"" AS VARCHAR(10)),2) || ':00' WHEN LENGTH(T0.""U_HoraRecep"") = 2 THEN '00:' || CAST(T0.""U_HoraRecep"" AS VARCHAR(10)) || ':00' WHEN LENGTH(T0.""U_HoraRecep"") = 1 THEN '00:0' || CAST(T0.""U_HoraRecep"" AS VARCHAR(10)) || ':00' ELSE '00:00:00' END AS VARCHAR(50)) ""FechaRecep"" ,T0.""U_Monto"" ""Monto"" ,T0.""U_IVA"" ""IVA"" ,T0.""U_EstadoC"" ""EstadoC"" ,T0.""U_EstadoSII"" ""EstadoSII"" ,T0.""U_EstadoLey"" ""EstadoLey"" ,TO_INT(T0.""U_DocEntry"") ""DocEntryDoc"" ,{4} ""xml"" FROM ""{2}"" T0 WHERE 1 = 1 AND T0.""{3}"" BETWEEN '{0}' AND '{1}'"; } s = String.Format(s, FechaD, FechaH, (TipoDTE == "V" ? "@VID_FEDTEVTA" : "@VID_FEDTECPRA"), (DSOpFec.Value == "1" ? "U_FechaEmi" : "U_FechaRecep"), (TipoDTE == "C" ? (GlobalSettings.RunningUnderSQLServer ? @"T0.U_Xml" : @"T0.""U_Xml"" ") : "''")); if (((System.String)((ComboBox)oForm.Items.Item("Cliente").Specific).Selected.Value).Trim() != "Todos") { if (GlobalSettings.RunningUnderSQLServer) { s = s + @" AND T0.U_EstadoC = '{0}'"; } else { s = s + @" AND T0.""U_EstadoC"" = '{0}'"; } s = String.Format(s, ((System.String)((ComboBox)oForm.Items.Item("Cliente").Specific).Selected.Value).Trim()); } if (((System.String)((ComboBox)oForm.Items.Item("SII").Specific).Selected.Value).Trim() != "Todos") { if (GlobalSettings.RunningUnderSQLServer) { s = s + @" AND T0.U_EstadoSII = '{0}'"; } else { s = s + @" AND T0.""U_EstadoSII"" = '{0}'"; } s = String.Format(s, ((System.String)((ComboBox)oForm.Items.Item("SII").Specific).Selected.Value).Trim()); } if (((System.String)((ComboBox)oForm.Items.Item("Ley").Specific).Selected.Value).Trim() != "Todos") { if (GlobalSettings.RunningUnderSQLServer) { s = s + @" AND T0.U_EstadoLey = '{0}'"; } else { s = s + @" AND T0.""U_EstadoLey"" = '{0}'"; } s = String.Format(s, ((System.String)((ComboBox)oForm.Items.Item("Ley").Specific).Selected.Value).Trim()); } oDataTable.ExecuteQuery(s); oGrid.Columns.Item("DocEntry").Type = BoGridColumnType.gct_EditText; var col = (EditTextColumn)(oGrid.Columns.Item("DocEntry")); col.Visible = false; oGrid.Columns.Item("TipoDoc").Type = BoGridColumnType.gct_EditText; col = (EditTextColumn)(oGrid.Columns.Item("TipoDoc")); col.Editable = false; col.TitleObject.Caption = "Tipo DTE"; col.TitleObject.Sortable = true; oGrid.Columns.Item("Folio").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("Folio")); col.Editable = false; col.RightJustified = true; col.TitleObject.Sortable = true; col.TitleObject.Caption = "Nro Folio"; oGrid.Columns.Item("RUT").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("RUT")); col.Editable = false; col.TitleObject.Sortable = true; col.TitleObject.Caption = "RUT"; if (TipoDTE == "C") { col.Visible = true; } else { col.Visible = false; } oGrid.Columns.Item("Razon").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("Razon")); col.Editable = false; col.TitleObject.Sortable = true; col.TitleObject.Caption = "Razon Social"; oGrid.Columns.Item("FechaEmi").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("FechaEmi")); col.Editable = false; col.TitleObject.Sortable = true; col.TitleObject.Caption = "Fecha Emisión"; oGrid.Columns.Item("FechaRecep").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("FechaRecep")); col.Editable = false; col.TitleObject.Sortable = true; col.TitleObject.Caption = "Fecha Recepción"; oGrid.Columns.Item("Monto").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("Monto")); col.Editable = false; col.RightJustified = true; col.TitleObject.Sortable = true; col.TitleObject.Caption = "Monto"; oGrid.Columns.Item("IVA").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("IVA")); col.Editable = false; col.RightJustified = true; col.TitleObject.Sortable = true; col.TitleObject.Caption = "IVA"; oGrid.Columns.Item("EstadoC").Type = BoGridColumnType.gct_ComboBox; var colCombo = ((ComboBoxColumn)oGrid.Columns.Item("EstadoC")); colCombo.Editable = false; colCombo.DisplayType = BoComboDisplayType.cdt_both; colCombo.TitleObject.Sortable = true; colCombo.TitleObject.Caption = "Estado Cliente"; if (GlobalSettings.RunningUnderSQLServer) { s = @"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 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, (TipoDTE == "V" ? "@VID_FEDTEVTA" : "@VID_FEDTECPRA")); oRecordSet.DoQuery(s); FSBOf.FillComboGrid(((GridColumn)oGrid.Columns.Item("EstadoC")), ref oRecordSet, false); oGrid.Columns.Item("EstadoSII").Type = BoGridColumnType.gct_ComboBox; colCombo = ((ComboBoxColumn)oGrid.Columns.Item("EstadoSII")); colCombo.Editable = false; colCombo.DisplayType = BoComboDisplayType.cdt_both; colCombo.TitleObject.Sortable = true; colCombo.TitleObject.Caption = "Estado SII"; if (GlobalSettings.RunningUnderSQLServer) { s = @"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 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, (TipoDTE == "V" ? "@VID_FEDTEVTA" : "@VID_FEDTECPRA")); oRecordSet.DoQuery(s); FSBOf.FillComboGrid(((GridColumn)oGrid.Columns.Item("EstadoSII")), ref oRecordSet, false); oGrid.Columns.Item("EstadoLey").Type = BoGridColumnType.gct_ComboBox; colCombo = ((ComboBoxColumn)oGrid.Columns.Item("EstadoLey")); colCombo.Editable = false; colCombo.DisplayType = BoComboDisplayType.cdt_both; colCombo.TitleObject.Sortable = true; colCombo.TitleObject.Caption = "Estado Ley 20.956"; if (GlobalSettings.RunningUnderSQLServer) { s = @"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 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, (TipoDTE == "V" ? "@VID_FEDTEVTA" : "@VID_FEDTECPRA")); oRecordSet.DoQuery(s); FSBOf.FillComboGrid(((GridColumn)oGrid.Columns.Item("EstadoLey")), ref oRecordSet, false); oGrid.Columns.Item("DocEntryDoc").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("DocEntryDoc")); col.Editable = false; col.RightJustified = true; if (TipoDTE == "V") { col.Visible = false; } else { col.Visible = true; } col.TitleObject.Sortable = false; col.TitleObject.Caption = "Factura en SAP"; col.LinkedObjectType = "18"; oGrid.Columns.Item("xml").Type = BoGridColumnType.gct_EditText; col = ((EditTextColumn)oGrid.Columns.Item("xml")); col.Editable = false; col.Visible = false; oGrid.AutoResizeColumns(); } catch (Exception x) { FSBOApp.StatusBar.SetText(x.Message + " ** Trace: " + x.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); OutLog("BuscarDatos: " + x.Message + " ** Trace: " + x.StackTrace); } finally { oForm.Freeze(false); } }
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