UpdateNombreCommand.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 UpdateNombreCommand : Command
12  {
13  public UpdateNombreCommand(IAddonsManager addons) : base(addons)
14  {
15  Name = "UpdateNombreCommand";
16  }
17 
18  protected override void CommandModulo(IModulo modulo, params object[] parameters)
19  {
20  if (modulo._Tipo == 3 && //Solo los que son tipo 3 (addons propios)
21  DB._SQLExisteTablaBBDD(modulo._NombreConexion, "MENU50")) //Miramos que exista la tabla en el addon
22  {
23  string lcAliasDb = modulo._AliasDB;
24 
25  string tcPantalla = parameters[0].ToString();
26  string tcNombreViejo = parameters[1].ToString();
27  string tcNombreNuevo = parameters[2].ToString();
28 
29  DataTable ldtTemp = new DataTable();
30  string lcSql = $@"SELECT * from {DB.SQLDatabase(lcAliasDb, "MENU50")}
31  WHERE pantalla = {DB.SQLString(tcPantalla)}";
32  if (!string.IsNullOrWhiteSpace(tcNombreViejo))
33  lcSql += $@"
34  AND nombre = {DB.SQLString(tcNombreViejo)}";
35 
36  if (DB.SQLExec(lcSql, ref ldtTemp) && ldtTemp.Rows.Count > 0)
37  {
38  lcSql = $@"UPDATE {DB.SQLDatabase(lcAliasDb, "MENU50")}
39  SET nombre = {DB.SQLString(tcNombreNuevo)}
40  WHERE pantalla = {DB.SQLString(tcPantalla)}";
41 
42  if (!string.IsNullOrWhiteSpace(tcNombreViejo))
43  lcSql += $@"
44  AND nombre = {DB.SQLString(tcNombreViejo)}";
45  DB.SQLExec(lcSql);
46  }
47  }
48  }
49 
50  protected override ExpectedParameters GetExpectedParameters()
51  {
52  return new ExpectedParameters(
53  new Type[] {
54  typeof(string),
55  typeof(string),
56  typeof(string) });
57  }
58  }
59 }
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
int _Tipo
Tipo de addon
Definition: IModulo.cs:64