8 using System.Collections.Generic;
12 using System.Windows.Forms;
23 private List<TipoDocumento> _oDocumentos = null;
28 protected override List<TipoDocumento> _Documentos
46 DataTable loDt =
new DataTable();
48 loDt.Columns.Add(
"sel", typeof(
bool));
49 loDt.Columns.Add(
"tipo", typeof(
string)).Caption =
"Tipo documento";
50 loDt.Columns.Add(
"tabla", typeof(
string));
51 loDt.Columns.Add(
"documento", typeof(
string));
52 loDt.Columns.Add(
"key", typeof(
string)).ExtendedProperties.Add(
"NoVisible",
true);
54 toDocumentos.ForEach(f =>
56 lcTipo = $
"{f.ToString().Substring(0, 1).ToUpper()}{f.ToString().Substring(1)}";
58 f._Data.AsEnumerable().ToList().ForEach(z =>
60 loRow = loDt.NewRow();
61 loRow[
"tipo"] = lcTipo;
62 loRow[
"tabla"] = z[
"TABLA"];
63 loRow[
"documento"] = $
"{z["LETRA
"]}{z["NUMERO
"]}";
64 z[
"KEY"] = loRow[
"key"] = Guid.NewGuid();
77 : base(
TipoCategoriaPruebaDiagnostica.
Ventas,
"Eliminar cabeceras sin líneas y líneas sin cabeceras a nivel de documentos de ventas (pedidos, presupuestos, albarán, depósitos y facturas).")
90 private List<TipoDocumento> _oDocumentos = null;
95 protected override List<TipoDocumento> _Documentos
113 DataTable loDt =
new DataTable();
115 loDt.Columns.Add(
"sel", typeof(
bool));
116 loDt.Columns.Add(
"tipo", typeof(
string)).Caption =
"Tipo documento";
117 loDt.Columns.Add(
"tabla", typeof(
string));
118 loDt.Columns.Add(
"documento", typeof(
string));
119 loDt.Columns.Add(
"proveedor", typeof(
string));
120 loDt.Columns.Add(
"key", typeof(
string)).ExtendedProperties.Add(
"NoVisible",
true);
122 toDocumentos.ForEach(f =>
124 lcTipo = $
"{f.ToString().Substring(0, 1).ToUpper()}{f.ToString().Substring(1)}";
126 f._Data.AsEnumerable().ToList().ForEach(z =>
128 loRow = loDt.NewRow();
130 loRow[
"tipo"] = lcTipo;
131 loRow[
"tabla"] = z[
"TABLA"];
132 loRow[
"documento"] = z[
"NUMERO"];
133 loRow[
"proveedor"] = z[
"PROVEEDOR"];
134 z[
"KEY"] = loRow[
"key"] = Guid.NewGuid();
136 loDt.Rows.Add(loRow);
146 : base(
TipoCategoriaPruebaDiagnostica.
Compras,
"Eliminar cabeceras sin líneas y líneas sin cabeceras a nivel de documentos de compras (pedidos, presupuestos, albarán, depósitos y facturas).")
153 #region TIPO DOCUMENTOS COMPRAS 165 : base(
"C_ALBCOM",
"D_ALBCOM",
EnUso.TiposEnUso.FACTUCOM.ToString(),
"factura")
176 string lcCampo, lcSQL, lcClave;
178 lcCampo =
"c.NUMERO, c.PROVEEDOR";
179 lcClave = $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + {DB.SQLIif("LEN(RTRIM(LTRIM(c.FACTURA))) < 10
", "SUBSTRING(c.FACTURA, LEN(c.FACTURA) - 9, 10)
", "RTRIM(LTRIM(c.FACTURA))
")} + c.PROVEEDOR";
181 lcSQL = $
@"SELECT '{_Tipo}' as TIPO, '{_Tabla}' as TABLA, {lcCampo}, 0 as LINIA, u.CLAVE FROM {DB.SQLDatabase("GESTION
", _Tabla)} c {Environment.NewLine}" +
182 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _TablaLineas)} l ON c.NUMERO = l.NUMERO AND l.PROVEEDOR = c.PROVEEDOR AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
183 $
@"LEFT JOIN {DB.SQLDatabase("COMUNES
", "EN_USO
")} u on u.tipo = '{_Tipo}' AND u.CLAVE = {lcClave} {Environment.NewLine}" +
184 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null AND RTRIM(LTRIM(c.FACTURA)) <> '' AND ( u.CLAVE is null OR u.CREATED < {DB.SQLString(DateTime.Now.AddDays(-2))}) {Environment.NewLine} ";
200 : base(
"C_ALBCOM",
"D_ALBCOM",
EnUso.TiposEnUso.ALBCOM.ToString(),
"albaran")
211 string lcCampo, lcSQL, lcClave;
213 lcCampo =
"c.NUMERO, c.PROVEEDOR";
214 lcClave = $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + {DB.SQLIif("LEN(RTRIM(LTRIM(c.NUMERO))) < 10
", "SUBSTRING(c.NUMERO, LEN(c.NUMERO) - 9, 10)
", "RTRIM(LTRIM(c.NUMERO))
")} + c.PROVEEDOR";
216 lcSQL = $
@"SELECT '{_Tipo}' as TIPO, '{_Tabla}' as TABLA, {lcCampo}, 0 as LINIA, u.CLAVE FROM {DB.SQLDatabase("GESTION
", _Tabla)} c {Environment.NewLine}" +
217 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _TablaLineas)} l ON c.NUMERO = l.NUMERO AND l.PROVEEDOR = c.PROVEEDOR AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
218 $
@"LEFT JOIN {DB.SQLDatabase("COMUNES
", "EN_USO
")} u on u.tipo = '{_Tipo}' AND u.CLAVE = {lcClave} {Environment.NewLine}" +
219 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null AND RTRIM(LTRIM(FACTURA)) = '' AND ( u.CLAVE is null OR u.CREATED < {DB.SQLString(DateTime.Now.AddDays(-2))}) {Environment.NewLine} " +
220 $
@"UNION {Environment.NewLine}" +
221 $
@"SELECT '{_Tipo}' as TIPO, '{_TablaLineas}' as TABLA, {lcCampo}, LINIA, '' as CLAVE FROM {DB.SQLDatabase("GESTION
", _TablaLineas)} c {Environment.NewLine}" +
222 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _Tabla)} l ON c.NUMERO = l.NUMERO AND l.PROVEEDOR = c.PROVEEDOR AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
223 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null ";
239 : base(
"C_PEDICO",
"D_PEDICO",
EnUso.TiposEnUso.PEDICOM.ToString(),
"pedido")
255 : base(
"C_DEPCOM",
"D_DEPCOM",
EnUso.TiposEnUso.DEPOCOM.ToString(),
"depósito")
271 : base(
"C_PRECOM",
"D_PRECOM",
EnUso.TiposEnUso.PRECOM.ToString(),
"propuesta")
277 #endregion TIPO DOCUMENTOS COMPRAS 279 #region TIPO DOCUMENTOS VENTAS 290 protected internal bool _FactSer = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_Factser"));
294 protected internal bool _SerFact = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_Serfact"));
300 : base(
"C_ALBVEN",
"D_ALBVEN",
"C_ALBVEN",
"ticket")
311 string lcCampo, lcSQL, lcClave, lcClaveF, lcAny;
313 lcCampo =
"c.LETRA, c.NUMERO, c.EJERCICIO";
314 lcAny = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_any"));
315 lcClave = $
"'{lcAny}' + c.EMPRESA + c.NUMERO + c.LETRA ";
316 lcClaveF = _FactSer && _SerFact ? $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + SUBSTRING(ISNULL(g.FACTURA, c.NUMERO), 3, 8) + SUBSTRING(ISNULL(g.FACTURA, c.NUMERO), 0, 3) " : $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + ISNULL(g.FACTURA, c.NUMERO) ";
318 lcSQL = $
@"SELECT '{_Tipo}' as TIPO, '{_Tabla}' as TABLA, {lcCampo}, 0 as LINEA, u.CLAVE, c.TIPO_DOC FROM {DB.SQLDatabase("TPV", _Tabla)} c {Environment.NewLine}" +
319 $
@"LEFT JOIN {DB.SQLDatabase("TPV", _TablaLineas)} l ON c.EJERCICIO = l.EJERCICIO AND c.NUMERO = l.NUMERO AND c.LETRA = l.LETRA AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
320 $
@"LEFT JOIN {DB.SQLDatabase("COMUNES
", "EN_USO
")} u on u.tipo = '{_Tipo}' AND u.CLAVE = {lcClave} {Environment.NewLine}" +
321 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND c.TIPO_DOC <> 3 AND l.NUMERO is null AND c.EJERCICIO = {DB.SQLString(lcAny)} AND ( u.CLAVE is null OR u.CREATED < {DB.SQLString(DateTime.Now.AddDays(-2))}) {Environment.NewLine}" +
322 $
@"UNION {Environment.NewLine}" +
323 $
@"SELECT 'FACTUVEN' as TIPO, '{_Tabla}' as TABLA, {lcCampo}, 0 as LINEA, u.CLAVE, c.TIPO_DOC FROM {DB.SQLDatabase("TPV", _Tabla)} c {Environment.NewLine}" +
324 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", "C_ALBVEN
")} g ON c.EJERCICIO = '{lcAny}' AND c.NUMERO = g.NUMERO AND c.LETRA = g.LETRA AND c.EMPRESA = g.EMPRESA AND RTRIM(LTRIM(g.FACTURA)) <> '' {Environment.NewLine}" +
325 $
@"LEFT JOIN {DB.SQLDatabase("TPV", _TablaLineas)} l ON c.EJERCICIO = l.EJERCICIO AND c.NUMERO = l.NUMERO AND c.LETRA = l.LETRA AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
326 $
@"LEFT JOIN {DB.SQLDatabase("COMUNES
", "EN_USO
")} u on u.tipo = 'FACTUVEN' AND u.CLAVE = {lcClaveF} {Environment.NewLine}" +
327 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND c.TIPO_DOC = 3 AND l.NUMERO is null AND c.EJERCICIO = {DB.SQLString(lcAny)} AND ( u.CLAVE is null OR u.CREATED < {DB.SQLString(DateTime.Now.AddDays(-2))}) {Environment.NewLine}" +
328 $
@"UNION {Environment.NewLine}" +
329 $
@"SELECT '{_Tipo}' as TIPO, '{_TablaLineas}' as TABLA, {lcCampo}, LINEA, '' as CLAVE, 0 as TIPO_DOC FROM {DB.SQLDatabase("TPV", _TablaLineas)} c {Environment.NewLine}" +
330 $
@"LEFT JOIN {DB.SQLDatabase("TPV", _Tabla)} l ON c.EJERCICIO = l.EJERCICIO AND c.NUMERO = l.NUMERO AND c.LETRA = l.LETRA AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
331 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null AND c.EJERCICIO = {DB.SQLString(lcAny)} ";
343 List<DataRow> loList;
344 StringBuilder loSQL =
new StringBuilder();
346 loList = GetDataByTabla(_Tabla);
347 loList.ForEach(f => loSQL.AppendLine($
"DELETE FROM {DB.SQLDatabase("TPV", _Tabla)} WHERE EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND NUMERO = {DB.SQLString(f["NUMERO
"])} AND LETRA = {DB.SQLString(f["LETRA
"])} AND EJERCICIO = {DB.SQLString(f["EJERCICIO
"])} AND TIPO_DOC = {DB.SQLString(f["TIPO_DOC
"])}; "));
349 return loSQL.ToString();
358 List<DataRow> loList;
359 StringBuilder loSQL =
new StringBuilder();
361 loList = GetDataByTabla(_TablaLineas);
362 loList.ForEach(f => loSQL.AppendLine($
"DELETE FROM {DB.SQLDatabase("TPV", _TablaLineas)} WHERE EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND NUMERO = {DB.SQLString(f["NUMERO
"])} AND LETRA = {DB.SQLString(f["LETRA
"])} AND EJERCICIO = {DB.SQLString(f["EJERCICIO
"])} AND LINEA = {DB.SQLString(f["LINEA
"])}; "));
364 return loSQL.ToString();
377 protected internal bool _FactSer = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_Factser"));
381 protected internal bool _SerFact = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_Serfact"));
387 : base(
"C_ALBVEN",
"D_ALBVEN",
EnUso.TiposEnUso.FACTUVEN.ToString(),
"factura")
398 string lcCampo, lcSQL, lcClave;
400 lcCampo =
"c.LETRA, c.NUMERO";
401 lcClave = _FactSer && _SerFact ? $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + SUBSTRING(c.FACTURA, 3, 8) + SUBSTRING(c.FACTURA, 0, 3) " : $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + c.FACTURA";
403 lcSQL = $
@"SELECT '{_Tipo}' as TIPO, '{_Tabla}' as TABLA, {lcCampo}, 0 as LINIA, u.CLAVE FROM {DB.SQLDatabase("GESTION
", _Tabla)} c {Environment.NewLine}" +
404 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _TablaLineas)} l ON c.NUMERO = l.NUMERO AND c.LETRA = l.LETRA AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
405 $
@"LEFT JOIN {DB.SQLDatabase("COMUNES
", "EN_USO
")} u on u.tipo = '{_Tipo}' AND u.CLAVE = {lcClave} {Environment.NewLine}" +
406 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null AND RTRIM(LTRIM(FACTURA)) <> '' AND ( u.CLAVE is null OR u.CREATED < {DB.SQLString(DateTime.Now.AddDays(-2))}) {Environment.NewLine}";
431 : base(
"C_ALBVEN",
"D_ALBVEN",
"C_ALBVEN",
"albaran")
442 string lcCampo, lcSQL, lcClave;
444 lcCampo =
"c.LETRA, c.NUMERO";
445 lcClave = $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + c.NUMERO + c.LETRA ";
447 lcSQL = $
@"SELECT '{_Tipo}' as TIPO, '{_Tabla}' as TABLA, {lcCampo}, 0 as LINIA, u.CLAVE FROM {DB.SQLDatabase("GESTION
", _Tabla)} c {Environment.NewLine}" +
448 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _TablaLineas)} l ON c.NUMERO = l.NUMERO AND c.LETRA = l.LETRA AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
449 $
@"LEFT JOIN {DB.SQLDatabase("COMUNES
", "EN_USO
")} u on u.tipo = '{_Tipo}' AND u.CLAVE = {lcClave} {Environment.NewLine}" +
450 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null AND RTRIM(LTRIM(FACTURA)) = '' AND ( u.CLAVE is null OR u.CREATED < {DB.SQLString(DateTime.Now.AddDays(-2))}) {Environment.NewLine}" +
451 $
@"UNION {Environment.NewLine}" +
452 $
@"SELECT '{_Tipo}' as TIPO, '{_TablaLineas}' as TABLA, {lcCampo}, LINIA, '' as CLAVE FROM {DB.SQLDatabase("GESTION
", _TablaLineas)} c {Environment.NewLine}" +
453 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _Tabla)} l ON c.NUMERO = l.NUMERO AND c.LETRA = l.LETRA AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
454 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null ";
470 : base(
"C_PEDIVE",
"D_PEDIVE",
EnUso.TiposEnUso.PEDIVEN.ToString(),
"pedido")
486 : base(
"C_ALBDEP",
"D_ALBDEP",
EnUso.TiposEnUso.DEPOVEN.ToString(),
"depósito")
502 : base(
"C_PRESUV",
"D_PRESUV",
EnUso.TiposEnUso.PRESUVEN.ToString(),
"presupuesto")
508 #endregion TIPO DOCUMENTOS VENTAS 510 #region ABSTRACT CLASS 521 protected abstract List<TipoDocumento> _Documentos {
get; }
528 protected abstract DataTable CreateDataTable(List<TipoDocumento> toDocumentos);
534 public override IEnumerable<IResultadoPruebaDiagnostica>
Ejecutar()
539 List<TipoDocumento> loDocumentos =
new List<TipoDocumento>();
540 List<IResultadoPruebaDiagnostica> loRes =
new List<IResultadoPruebaDiagnostica>();
542 _Documentos.ForEach(f => f.Clear());
544 loResDefecte = GetResultadoPreconfigurado();
546 loDocumentos = _Documentos.Where(f => f._Data.Rows.Count > 0).ToList();
548 if (loDocumentos.Count > 0)
551 loForm.
_DataTable = CreateDataTable(loDocumentos);
557 if (loForm.DialogResult == DialogResult.OK)
559 loKeys = loForm.
_DataTable.AsEnumerable().Where(f => Convert.ToBoolean(f[
"sel"])).Select(f => Convert.ToString(f[
"Key"])).ToList();
561 if (loKeys.Count > 0)
563 loDocumentos.ForEach(f =>
566 loResDefecte = GetResultadoPreconfigurado();
567 loResDefecte = f._GetResultCabeceraByDocument(loResDefecte);
569 loResDefecte = GetResultadoPreconfigurado();
570 loResDefecte = f._GetResultLineasByDocument(loResDefecte);
575 DeleteEnUso(loDocumentos);
580 loResDefecte.
Descripcion =
"No se han seleccionado registros para eliminar.";
581 loRes.Add(loResDefecte);
587 loResDefecte.
Descripcion =
"Eliminación cancelada por el usuario.";
588 loRes.Add(loResDefecte);
594 loResDefecte.
Descripcion =
"No se han encontrado documentos sin líneas o líneas sin cabeceras. ";
595 loRes.Add(loResDefecte);
598 _Documentos.ForEach(f => f.Clear());
603 private void DeleteEnUso(List<TipoDocumento> toDocumentos)
605 StringBuilder loSQL =
new StringBuilder();
607 toDocumentos.ForEach(f => f._Data.AsEnumerable().ToList().Where(z => !
string.IsNullOrEmpty(Convert.ToString(z[
"CLAVE"]).Trim())).ToList().ForEach(z => loSQL.AppendLine($
"DELETE FROM {DB.SQLDatabase("COMUNES
", "EN_USO
")} WHERE TIPO = {DB.SQLString(z["TIPO
"])} AND CLAVE = {DB.SQLString(z["CLAVE
"])};")));
609 if (loSQL.Length > 0) DB.SQLExec(loSQL.ToString());
618 : base(teCategoria, $
"Eliminación de cabeceras y líneas incompletas", tcDescripcion)
638 : base(tcTabla, tcTablaLin, tcTipo, tcNombre)
648 string lcCampo, lcSQL, lcClave;
650 lcCampo =
"c.LETRA, c.NUMERO";
651 lcClave = $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + c.NUMERO + c.LETRA ";
653 lcSQL = $
@"SELECT '{_Tipo}' as TIPO, '{_Tabla}' as TABLA, {lcCampo}, 0 as LINIA, u.CLAVE FROM {DB.SQLDatabase("GESTION
", _Tabla)} c {Environment.NewLine}" +
654 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _TablaLineas)} l ON c.NUMERO = l.NUMERO AND c.LETRA = l.LETRA AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
655 $
@"LEFT JOIN {DB.SQLDatabase("COMUNES
", "EN_USO
")} u on u.tipo = '{_Tipo}' AND u.CLAVE = {lcClave} {Environment.NewLine}" +
656 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null AND ( u.CLAVE is null OR u.CREATED < {DB.SQLString(DateTime.Now.AddDays(-2))}) {Environment.NewLine}" +
657 $
@"UNION {Environment.NewLine}" +
658 $
@"SELECT '{_Tipo}' as TIPO, '{_TablaLineas}' as TABLA, {lcCampo}, LINIA, '' as CLAVE FROM {DB.SQLDatabase("GESTION
", _TablaLineas)} c {Environment.NewLine}" +
659 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _Tabla)} l ON c.NUMERO = l.NUMERO AND c.LETRA = l.LETRA AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
660 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null ";
671 List<DataRow> loList;
672 StringBuilder loSQL =
new StringBuilder();
674 loList = GetDataByTabla(_Tabla);
675 loList.ForEach(f => loSQL.AppendLine($
"DELETE FROM {DB.SQLDatabase("GESTION
", _Tabla)} WHERE EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND NUMERO = {DB.SQLString(f["NUMERO
"])} AND LETRA = {DB.SQLString(f["LETRA
"])}; "));
677 return loSQL.ToString();
686 List<DataRow> loList;
687 StringBuilder loSQL =
new StringBuilder();
689 loList = GetDataByTabla(_TablaLineas);
690 loList.ForEach(f => loSQL.AppendLine($
"DELETE FROM {DB.SQLDatabase("GESTION
", _TablaLineas)} WHERE EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND NUMERO = {DB.SQLString(f["NUMERO
"])} AND LETRA = {DB.SQLString(f["LETRA
"])} AND LINIA = {DB.SQLString(f["LINIA
"])} ; "));
692 return loSQL.ToString();
710 : base(tcTabla, tcTablaLin, tcTipo, tcNombre)
720 List<DataRow> loList;
721 StringBuilder loSQL =
new StringBuilder();
723 loList = GetDataByTabla(_Tabla);
724 loList.ForEach(f => loSQL.AppendLine($
"DELETE FROM {DB.SQLDatabase("GESTION
", _Tabla)} WHERE EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND NUMERO = {DB.SQLString(f["NUMERO
"])} AND PROVEEDOR = {DB.SQLString(f["PROVEEDOR
"])}; "));
726 return loSQL.ToString();
735 List<DataRow> loList;
736 StringBuilder loSQL =
new StringBuilder();
738 loList = GetDataByTabla(_TablaLineas);
739 loList.ForEach(f => loSQL.AppendLine($
"DELETE FROM {DB.SQLDatabase("GESTION
", _TablaLineas)} WHERE EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND NUMERO = {DB.SQLString(f["NUMERO
"])};"));
741 return loSQL.ToString();
750 string lcCampo, lcSQL, lcClave;
752 lcCampo =
"c.NUMERO, c.PROVEEDOR";
753 lcClave = $
"'{Convert.ToString(EW_GLOBAL._GetVariable("wc_any
"))}' + c.EMPRESA + {DB.SQLIif("LEN(RTRIM(LTRIM(c.NUMERO))) < 10
", "SUBSTRING(c.NUMERO, LEN(c.NUMERO) - 9, 10)
", "RTRIM(LTRIM(c.NUMERO))
")}";
755 lcSQL = $
@"SELECT '{_Tipo}' as TIPO, '{_Tabla}' as TABLA, {lcCampo}, 0 as LINIA, u.CLAVE FROM {DB.SQLDatabase("GESTION
", _Tabla)} c {Environment.NewLine}" +
756 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _TablaLineas)} l ON c.NUMERO = l.NUMERO AND l.PROVEEDOR = c.PROVEEDOR AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
757 $
@"LEFT JOIN {DB.SQLDatabase("COMUNES
", "EN_USO
")} u on u.tipo = '{_Tipo}' AND u.CLAVE = {lcClave} {Environment.NewLine}" +
758 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null AND ( u.CLAVE is null OR u.CREATED < {DB.SQLString(DateTime.Now.AddDays(-2))}) {Environment.NewLine}" +
759 $
@"UNION {Environment.NewLine}" +
760 $
@"SELECT '{_Tipo}' as TIPO, '{_TablaLineas}' as TABLA, {lcCampo}, LINIA, '' as CLAVE FROM {DB.SQLDatabase("GESTION
", _TablaLineas)} c {Environment.NewLine}" +
761 $
@"LEFT JOIN {DB.SQLDatabase("GESTION
", _Tabla)} l ON c.NUMERO = l.NUMERO AND l.PROVEEDOR = c.PROVEEDOR AND c.EMPRESA = l.EMPRESA {Environment.NewLine}" +
762 $
@"WHERE c.EMPRESA = {DB.SQLString(EW_GLOBAL._Empresa._Codigo)} AND l.NUMERO is null ";
774 private DataTable _oData = null;
779 public List<string> _Keys {
get;
set; }
784 protected string _Tabla {
get;
private set; }
789 protected string _TablaLineas {
get;
private set; }
794 protected string _Tipo {
get;
private set; }
799 protected string _Nombre {
get;
private set; }
804 public DataTable _Data
808 if (_oData == null) _oData = _GetData();
820 return _Data.AsEnumerable().Where(f => Convert.ToString(f[
"TABLA"]) == tcTabla && _Keys.Contains(Convert.ToString(f[
"KEY"]))).ToList();
826 private DataTable _GetData()
828 DataTable loDt =
new DataTable();
829 DB.SQLExec(_GetSQLByDocument(), ref loDt);
831 loDt.Columns.Add(
"Key", typeof(
string));
840 protected abstract string _GetSQLByDocument();
846 protected abstract string _GetSQLDeleteCabeceraByDocument();
852 protected abstract string _GetSQLDeleteLineasByDocument();
863 lnCount = GetDataByTabla(tbCabecera ? _Tabla : _TablaLineas).Count();
865 return $
"Se ha{(lnCount > 1 ? "n
" : "")} eliminado {lnCount} {(tbCabecera ? $"cabecera{(lnCount > 1 ?
"s" :
"")} sin líneas
" : $"línea{(lnCount > 1 ?
"s" :
"")} sin cabecera
")} de {_Nombre}";
877 lnCount = GetDataByTabla(tbCabecera ? _Tabla : _TablaLineas).Count();
879 return $
"No se ha{(lnCount > 1 ? "n
" : "")} podido eliminar {lnCount} {(tbCabecera ? $"cabecera{(lnCount > 1 ?
"s" :
"")}
" : $"línea{(lnCount > 1 ?
"s" :
"")}
")} de {_Nombre}";
889 return _GetResultByDocument(_GetSQLDeleteCabeceraByDocument(), toResDefecte,
true);
899 return _GetResultByDocument(_GetSQLDeleteLineasByDocument(), toResDefecte,
false);
906 if (!
string.IsNullOrEmpty(tcSQL))
908 if (DB.SQLExec(tcSQL))
911 toResDefecte.
Descripcion = GetDescripcionOK(tbCabecera);
951 public TipoDocumento(
string tcTabla,
string tcTablaLin,
string tcTipo,
string tcNombre)
954 _TablaLineas = tcTablaLin;
960 #endregion ABSTRACT CLASS virtual string GetDescripcionOK(bool tbCabecera)
Retorna la cadena descriptiva del proceso realizado
Definición documento de ventas
TipoDocumentoPedidoCompra()
Constructor
Clase abstracta para pruebas diagnósticas
override string _GetSQLDeleteLineasByDocument()
Obtener la SQL para eliminar las lineas por documento
Clase para la definición del tipo de documento depósito de venta
override string _GetSQLDeleteLineasByDocument()
Obtener la SQL para eliminar las lineas por documento
override DataTable CreateDataTable(List< TipoDocumento > toDocumentos)
Crear la tabla para mostrar los resistros de ventas para su eliminación
TipoDocumentoPresupuestoVenta()
Constructor
TipoDocumentoFacturaVenta()
Constructor
override IEnumerable< IResultadoPruebaDiagnostica > Ejecutar()
Comprobación para ver los asientos con cuentas de diferencias de cambio y moneda diferente a la de em...
void Clear()
Inicializa los datos
Clase para la definición del tipo de documento factura de compra
Clase para la definición del tipo de documento depósito de compra
override string _GetSQLDeleteCabeceraByDocument()
Obtener la SQL para eliminar por documento
TipoDocumentoPropuestaCompra()
Constructor
Clase para la definición del tipo de documento albaran de venta
TipoDocumentoDepositoCompra()
Constructor
override string _GetSQLDeleteLineasByDocument()
Obtener la SQL para eliminar las lineas por documento
override DataTable CreateDataTable(List< TipoDocumento > toDocumentos)
Crear la tabla para mostrar los registros de compras para su eliminación
string Descripcion
Descripción de la prueba
TipoCategoriaPruebaDiagnostica
Enumerado de categorias de pruebas diagnósticas
Clase para la definición del tipo de documento pedido de compra
Clase de prueba diagnostico para eliminar cabeceras sin líneas y líneas sin cabeceras (Compras) ...
override string _GetSQLByDocument()
Obtener SQL para comporbar documentos sin lineas y lineas sin cabecera
override string _GetSQLByDocument()
Obtener SQL para comporbar documentos sin lineas y lineas sin cabecera
override string _GetSQLDeleteLineasByDocument()
Obtener la SQL para eliminar las líneas por documento
TipoResultadoPruebaDiagnostica
Tipos de resultado que pueden tener las pruebas diagnósticas
virtual IResultadoPruebaDiagnostica _GetResultLineasByDocument(IResultadoPruebaDiagnostica toResDefecte)
Comprueba los registros, eliminado las cabeceras y lineas sin documentos
EliminarDocumentosIncompletosCompras()
Constructor
virtual IResultadoPruebaDiagnostica _GetResultCabeceraByDocument(IResultadoPruebaDiagnostica toResDefecte)
Comprueba los registros, eliminado las cabeceras y lineas sin documentos
override string _GetSQLByDocument()
Obtener SQL para comporbar documentos sin lineas y lineas sin cabecera
override string _GetSQLByDocument()
Obtener SQL para comporbar documentos sin lineas y lineas sin cabecera
override string _GetSQLByDocument()
Obtener SQL para comporbar documentos sin lineas y lineas sin cabecera
virtual string GetError(bool tbCabecera)
Retorna el error
Clase de prueba diagnostico para eliminar cabeceras sin líneas y líneas sin cabeceras (Ventas) ...
override string _GetSQLByDocument()
Obtener SQL para comporbar documentos sin lineas y lineas sin cabecera
override string _GetSQLDeleteCabeceraByDocument()
Obtener la SQL para eliminar las cabeceras por documento
Clase para la definición del tipo de documento propuesta de compra
override string ToString()
Tipo de documento
override string _GetSQLByDocument()
Obtener SQL para comporbar documentos sin lineas y lineas sin cabecera
TipoDocumentoFacturaCompra()
Constructor
TipoDocumentoAlbaranCompra()
Constructor
override string _GetSQLDeleteCabeceraByDocument()
Obtener la SQL para eliminar las cabeceras por documento
Definición documento de compras
Clase interna para el diagnóstico automático de la instalación Esta clase actua como contenedor de pr...
Clase para la definición del tipo de documento albaran de venta
EliminarDocumentosIncompletos(TipoCategoriaPruebaDiagnostica teCategoria, string tcDescripcion)
Constructor
TipoDocumentoCompra(string tcTabla, string tcTablaLin, string tcTipo, string tcNombre)
Contructor
TipoDocumentoDepositoVenta()
Constructor
Clase para la definición del tipo de documento
List< DataRow > GetDataByTabla(string tcTabla)
Obtener los registros por tabla
TipoDocumentoPedidoVenta()
Constructor
Clase para la definición del tipo de documento albaran de venta
Clase para la definición del tipo de documento presupuesto de venta
TipoDocumentoTicketVenta()
Constructor
Clase para la definición del tipo de documento albaran de compra
TipoDocumentoVenta(string tcTabla, string tcTablaLin, string tcTipo, string tcNombre)
Contructor
TipoDocumentoAlbaranVenta()
Constructor
Clase base de prueba diagnostico para eliminar cabeceras sin lineas y lineas sin cabeceras ...
TipoDocumento(string tcTabla, string tcTablaLin, string tcTipo, string tcNombre)
Constructor
EliminarDocumentosIncompletosVentas()
Constructor
Clase para la definición del tipo de documento pedido de venta
Interfície para el resultado de pruebas de diagnóstico
TipoResultadoPruebaDiagnostica Resultado
Resultado
Clase EnUso. PE-103176 Centralización de código para la gestión del KeyCopy de las clases que lo requ...