Nivel4.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using sage.ew.ewbase;
6 using sage.ew.db;
7 using System.Data;
8 using sage.ew.formul;
9 using System.Windows.Forms;
10 using sage.ew.formul.Forms;
11 
12 namespace sage.ew.contabilidad
13 {
17  public class Nivel4 : ewMante
18  {
22  public Nivel4()
23  {
24  _CargaPropiedades();
25  }
26 
30  public String _CtaSituacion
31  {
32  get
33  {
34  return _lisCampos.ContainsKey("CTASITUA") ? Convert.ToString(_lisCampos["CTASITUA"]._NewVal) : String.Empty;
35  }
36  set
37  {
38  if (_lisCampos.ContainsKey("CTASITUA"))
39  {
40  _lisCampos["CTASITUA"]._NewVal = value;
41 
42  if (string.IsNullOrEmpty(value))
43  {
44  _CtaSituacionDoble = string.Empty;
45  }
46  }
47  }
48  }
49 
53  public String _CtaSituacionDoble
54  {
55  get
56  {
57  return _lisCampos.ContainsKey("CTASITUA2") ? Convert.ToString(_lisCampos["CTASITUA2"]._NewVal) : String.Empty;
58  }
59  set
60  {
61  if (_lisCampos.ContainsKey("CTASITUA2")) _lisCampos["CTASITUA2"]._NewVal = value;
62  }
63  }
64 
69  public String _Descripcion
70  {
71  get
72  {
73  return _lisCampos.ContainsKey("DESCRIP") ? Convert.ToString(_lisCampos["DESCRIP"]._NewVal) : String.Empty;
74  }
75  set
76  {
77  if (_lisCampos.ContainsKey("DESCRIP")) _lisCampos["DESCRIP"]._NewVal = value;
78  }
79  }
80 
85  public String _ConceptoGastoIngreso
86  {
87  get
88  {
89  if (string.IsNullOrWhiteSpace(_Codigo) || _Codigo.Length < 3)
90  return "";
91  else
92  {
93  Nivel3 loNivel3 = new Nivel3(_Codigo.Substring(0, 3));
94  return loNivel3._ConceptoGastoIngreso;
95  }
96  }
97  }
98 
103  public String _ConceptoIRPF
104  {
105  get
106  {
107  if (string.IsNullOrWhiteSpace(_Codigo) || _Codigo.Length < 3)
108  return "";
109  else
110  {
111  Nivel3 loNivel3 = new Nivel3(_Codigo.Substring(0, 3));
112  return loNivel3._ConceptoIRPF;
113  }
114  }
115  }
116 
121  public Nivel4(String tcCodigo)
122  {
123  _CargaPropiedades();
124  _Codigo = tcCodigo;
125  }
126 
132  public String _ValidaCtaSituacionDuplicada(String tcCodigo)
133  {
134  String lcSql;
135  String lcReturn = String.Empty;
136  DataTable ldtNivel4 = new DataTable();
137 
138  if(!String.IsNullOrEmpty(tcCodigo))
139  {
140  // Busca si hi ha algún altre compte associat a aquest codi
141  lcSql = String.Format("SELECT codigo, nombre FROM {0} WHERE ctasitua ='{1}' AND codigo <>' {2}' ", DB.SQLDatabase("GESTION", "NIVEL4") ,tcCodigo, _Codigo);
142  DB.SQLExec(lcSql, ref ldtNivel4);
143 
144  if(ldtNivel4.Rows.Count > 0)
145  {
146  lcReturn = String.Format("Esta cta. de situación ya está asociada a otro código ({0} - {1})", ldtNivel4.Rows[0]["CODIGO"], ldtNivel4.Rows[0]["NOMBRE"].ToString().TrimEnd());
147  }
148  }
149  return lcReturn;
150  }
151 
157  public string _ValidaCtaSituacionDoble(string tcCodigo)
158  {
159  string lcReturn = string.Empty;
160 
161  if (!string.IsNullOrEmpty(tcCodigo))
162  {
163  if (DB.SQLValor("INVENTAR","CODIGO",_CtaSituacion,"ACPAS","GESTION").ToString() != "P")
164  {
165  lcReturn = "Para configurar la cuenta como doble naturaleza tendrá que introducir una cuenta de situación de tipo pasivo en el campo: Cuenta de situación del apartado General.";
166  }
167  else
168  {
169  if (DB.SQLValor("INVENTAR", "CODIGO", tcCodigo, "ACPAS", "GESTION").ToString() == "P")
170  {
171  lcReturn = "Para configurar la cuenta como doble naturaleza tendrá que introducir una cuenta de situación de tipo activo en el campo: Cuenta de situación del apartado Cuentas de doble naturaleza.";
172  }
173  }
174  }
175 
176  return lcReturn;
177  }
178 
182  private void _CargaPropiedades()
183  {
184  // Asignamos las propiedades para nivel 4
185  _lTodos = true;
186  _Clave = "CODIGO";
187  _DataBase = "GESTION";
188  _Tabla = "NIVEL4";
189  _TituloMantenimiento = "Mantenimiento de nivel 4 ";
190  _TituloCabecera = "Nivel 4";
191  _TituloMenu = "Nivel 4";
192 
193  _FormManteBaseType = typeof(Forms.frmNivel4);
194  _Pantalla = "NIVEL4";
195  }
196 
201  public override bool _Delete()
202  {
203 
204  bool llOk = true;
205  string lcClientes = string.Empty;
206  DataTable ldtCheck = new DataTable();
207 
208  String lcSql = string.Empty;
209  lcSql = String.Format("SELECT COUNT(*) FROM {0} WHERE CODIGO LIKE '{1}%' ", DB.SQLDatabase("GESTION", "CUENTAS"), _Codigo);
210  DB.SQLExec(lcSql, ref ldtCheck);
211 
212  // Verificamos que realmente se pueda eliminar la talla
213  if (ldtCheck != null && ldtCheck.Rows.Count > 0 && System.Convert.ToInt32(ldtCheck.Rows[0][0]) > 0)
214  {
215  llOk = false;
216  _Error_Message = "Los dígitos del código son utilizados en cuentas contables y no se podrá borrar.";
217  }
218 
219  if(llOk) base._Delete();
220 
221  return llOk;
222 
223  }
224 
230  public DataTable _LoadAll()
231  {
232  if (!string.IsNullOrWhiteSpace(_Codigo))
233  {
234  return _LoadAll(_Codigo);
235  }
236  else
237  {
238  return null;
239  }
240  }
241 
247  public DataTable _LoadAll(Nivel3 nivel3)
248  {
249  if (nivel3 != null && !string.IsNullOrWhiteSpace(nivel3._Codigo))
250  {
251  return _LoadAll(nivel3._Codigo);
252  }
253  else
254  {
255  return null;
256  }
257  }
258 
264  public static DataTable _LoadAll(string codigoNivel3)
265  {
266  if (!string.IsNullOrWhiteSpace(codigoNivel3) && (codigoNivel3.Trim().Length == 3))
267  {
268  int n;
269  if (int.TryParse(codigoNivel3.Trim(), out n))
270  {
271  DataTable ldtTemp = new DataTable();
272  string lcSql = "SELECT CODIGO, NOMBRE, DESCRIP" +
273  string.Format(" FROM {0}", DB.SQLDatabase("gestion", "nivel4")) +
274  string.Format(" WHERE ( LOWER ( CODIGO ) LIKE {0} )", DB.SQLString(codigoNivel3.Trim() + "%")) +
275  " ORDER BY 1";
276 
277  DB.SQLExec(lcSql, ref ldtTemp);
278  return ldtTemp;
279  }
280  }
281 
282  return null;
283  }
284 
285  }
286 }
String _ValidaCtaSituacionDuplicada(String tcCodigo)
Valida si la cuenta esta asociado a un código
Definition: Nivel4.cs:132
Clase de negocio base para mantenimientos
Definition: clsEwBase.cs:1643
String _ConceptoGastoIngreso
Task 152322 Propiedad para indicar el código de concepto de gasto o ingreso en niveles 2...
Definition: Nivel3.cs:126
DataTable _LoadAll(Nivel3 nivel3)
Método para cargar todo el Nivel 4 del nivel 3 indicado como parámetro y en su propiedad _Codigo...
Definition: Nivel4.cs:247
PE-96309 Clase utilizada para consultar los datos de nivel 4
Definition: Nivel4.cs:17
override bool _Delete()
Borra el nivel 4
Definition: Nivel4.cs:201
DataTable _LoadAll()
Método para cargar todo el Nivel 4 del nivel 3 indicado en la propiedad _Codigo. Se suele usar para e...
Definition: Nivel4.cs:230
string _ValidaCtaSituacionDoble(string tcCodigo)
Valida si la cuenta está indicada como cuenta de activo
Definition: Nivel4.cs:157
virtual string _Codigo
Valor del campo clave que
Definition: clsEwBase.cs:2513
Nivel4(String tcCodigo)
Constructor
Definition: Nivel4.cs:121
PE-96308 Clase utilizada para consultar los datos de nivel 3
Definition: Nivel3.cs:19
static DataTable _LoadAll(string codigoNivel3)
Método para cargar todo el Nivel 4 del codigo de nivel 3 indicado como parámetro. Se suele usar para ...
Definition: Nivel4.cs:264
String _ConceptoIRPF
Task 141344 Propiedad para indicar el código de concepto de libros IRPF
Definition: Nivel3.cs:142