GetInfoFromPantallaListadosCommand.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Data;
4 using System.Linq;
5 using System.Text;
6 using sage.ew.db;
7 using sage.ew.interficies;
8 
9 namespace Sage.ES.S50.Addons
10 {
11  internal class GetInfoFromPantallaListadosCommand : Command
12  {
13  DataRow ret;
14  public GetInfoFromPantallaListadosCommand(IAddonsManager addons) : base(addons)
15  {
16  Name = "GetInfoFromPantallaListados";
17  }
18 
19  protected override void CommandModulo(IModulo modulo, params object[] parameters)
20  {
21  string tcPantalla = parameters[0].ToString();
22  Func<string, string> _FormatearStringEspecial = parameters[1] as Func<string, string>;
23  Func<string, string> _Revisar_Descripcio = parameters[2] as Func<string, string>;
24  DataTable ldtResult = new DataTable();
25  if (DB._SQLExisteTablaBBDD(modulo._NombreConexion, "LISTADOS"))
26  {
27  string lcAliasDb = modulo._AliasDB;
28  string lcCampoUpdate = DB.SQLExisteCampo(lcAliasDb, "LISTADOS", "UPDATE") ? "CAST([UPDATE] AS varchar(max)) " : "''";
29  string lcGroupUpdate = lcCampoUpdate.StartsWith("C") ? "," + lcCampoUpdate : "";
30 
31  string lcSql = $@"select top 1 ID,PANTALLA,NOMBRE,NOMBRE as NOMBRE_REAL,CLASE,CLASEPADRE,ADICIONAL,CAST(FORM AS varchar(max)) as FORM
32  , max(TIPO) as TIPO,SELIVA,PERS,PERSMODULO,FIRMA,TAREA,MULTIEJER, {lcCampoUpdate} AS [UPDATE]
33  from {DB.SQLDatabase(lcAliasDb, "listados")}
34  where PANTALLA = {DB.SQLString(tcPantalla)}
35  group by ID,PANTALLA,NOMBRE,CLASE,CLASEPADRE,ADICIONAL,SELIVA,CAST(FORM AS varchar(max)),SELIVA,PERS,PERSMODULO,FIRMA,TAREA,MULTIEJER {lcGroupUpdate}
36  order by ID desc";
37 
38  DB.SQLExec(lcSql, ref ldtResult);
39 
40 
41  if (ldtResult != null && ldtResult.Rows.Count > 0)
42  {
43  // Revisar el nom en funció de les variables
44  ldtResult.Rows[0]["NOMBRE"] = _FormatearStringEspecial(_Revisar_Descripcio(ldtResult.Rows[0]["NOMBRE"].ToString())); // 91752
45  ret = ldtResult.Rows[0];
46  }
47  }
48  }
49  protected override ExpectedParameters GetExpectedParameters()
50  {
51  return new ExpectedParameters(new Type[] { typeof(string), typeof(Func<string, string>), typeof(Func<string, string>) });
52  }
53  protected override object Return(params object[] parameters)
54  {
55  return ret; ;
56  }
57  protected override bool Exit()
58  {
59  return ret != null;
60  }
61  }
62 }
PE-93426 Interficie para los módulos de la aplicación
Definition: IModulo.cs:22
string _NombreConexion
Nombre real de la base de datos
Definition: IModulo.cs:59
string _AliasDB
Alias de la Base de datos
Definition: IModulo.cs:29