solucion.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Data;
6 using System.ComponentModel;
7 
8 using sage.ew.global;
9 using sage.ew.db;
10 using sage.ew.ewbase;
11 using System.Windows.Forms;
12 using sage.ew.ewbase.Attributes;
13 using System.ComponentModel.DataAnnotations;
14 
15 namespace sage.addons.services.Negocio.Mantes
16 {
17  public partial class Solucion : ewMante
18  {
22  public bool _EnUso = false;
23 
27  [FieldName("Codigo")]
28  [DisplayName("CODIGO")]
29  public override string _Codigo
30  {
31  get
32  {
33  return base._Codigo;
34  }
35  set
36  {
37 
38  base._Codigo = (! String.IsNullOrEmpty(value) ? value.ToString().PadLeft(3, '0') : value);
39  }
40  }
41 
45  [FieldName("Solucion")]
46  [DisplayName("SOLUCION")]
47  [DefaultValue("")]
48  [DataType(DataType.Text)]
49  public string _Solucion
50  {
51  get
52  {
53  return Convert.ToString(_Campo(GetFieldName(nameof(_Solucion))));
54  }
55  set
56  {
57 
58 
59  // Descomantar para _Numero de documento
60  // value = value.PadLeft(10);
61 
62  _Campo(GetFieldName(nameof(_Solucion)), value);
63  }
64  }
65 
66 
67 
68 
72  public Solucion()
73  {
74  Inicializar();
75  }
76 
81  public Solucion(string tcCodigo)
82  {
83  Inicializar();
84 
85  this._Codigo = tcCodigo;
86  this._Load();
87  }
88 
89  private void Inicializar()
90  {
91  // Asignamos las propiedades para el mantenimiento
92  this._Clave = "Codigo";
93  this._DataBase = "SERVICES";
94  this._Tabla = "solucion";
95  this._TituloMantenimiento = "Mantenimiento de definiciones de soluciones";
96 
97  this._Pantalla = "solucion_net";
98  this._FormManteBaseType = typeof(Visual.Forms.frmSolucion);
99 
100  this._Codigo = string.Empty;
101  }
102 
107  public override bool _Delete()
108 
109  {
110  bool llOk = false;
111  DataTable ldtInf = new DataTable();
112  string lcMensaje = string.Empty;
113  string lcSql;
114 
115  lcSql = String.Format("SELECT COUNT(*) AS registros, Max(NUMERO) FROM {0} WHERE COD_SOLUC = '" + _Codigo + "'", DB.SQLDatabase("SERVICES", "C_SERVICIOS"));
116 
117  DB.SQLExec(lcSql, ref ldtInf);
118 
119  if (ldtInf == null || ldtInf.Rows.Count == 0) // Verificamos que realmente se pueda eliminar
120  llOk = true;
121  else
122  {
123  var loInf = ldtInf.AsEnumerable().Where(y => y.Field<Int32>("registros") != 0).ToList();
124  if (loInf.Count() == 0)
125  llOk = true;
126  else
127  {
128  for (int lnInd = 0; lnInd < loInf.Count(); lnInd++)
129  {
130  if (!string.IsNullOrWhiteSpace(lcMensaje))
131  lcMensaje = lcMensaje + " y ";
132 
133  lcMensaje = lcMensaje + Convert.ToString(loInf[lnInd][1]);
134  }
135  }
136  }
137 
138  if (llOk)
139  return base._Delete();
140  else
141  _Error_Message = "Este código de solución está asignado al servicio número " + lcMensaje.Trim() + ". No se puede borrar la solución.";
142 
143  return llOk;
144  }
145  }
146 
147 
148 }
Clase de negocio base para mantenimientos
Definition: clsEwBase.cs:1643
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...
override bool _Delete()
Elimina el registro actual
Definition: solucion.cs:107
Solucion(string tcCodigo)
Constructor con código
Definition: solucion.cs:81