6 using System.Collections.Generic;
10 using System.Threading.Tasks;
39 #endregion Constructor 44 public decimal _Previstas {
get;
set; } = 0;
51 _ReadOnly = _ReadOnly || _oDocLin._Solo_Lectura;
69 string lcSql =
string.Empty;
72 lcSql =
"SELECT EMPRESA,space(2) as LETRA,NUMERO,FECHA,ARTICULO, 0 AS LINIA,LOTE,UNIDADES, " +
73 " PERIODO,ALMACEN,CADUCIDAD,UBICA,FECHA2,PESO, " +
74 " TALLA,COLOR,ASI, " +
75 " UNIDADES AS UNIASIG, 0.00000000000 AS UNI2, PESO AS PESASIG, 0.00000000000 AS PES2, " +
76 " cast(1 as bit) as SEL, cast(0 as bit) as AJENO, cast(0 as bit) as REGULA, space(80) as ORIGEN, 0.00000000000 AS COSTE " +
77 "FROM " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" " +
78 " WHERE PERIODO = " + DB.SQLString(_cPeriodo) +
" " +
79 " AND EMPRESA = " + DB.SQLString(_oDocLin._Empresa) +
80 " AND NUMERO = " + DB.SQLString(_oDocLin._Numero);
82 DB.SQLExec(lcSql, ref _oDataTable);
91 string lcSql =
string.Empty;
93 string lcOn = EW_GLOBAL._Consolida(
"a.EMPRESA",
true,
false);
96 lcSql =
"SELECT a.LOTE, a.CADUCIDAD, a.UNIDADES, a.PESO, a.UBICA, a.TALLA, a.COLOR, " +
97 " 0.00000000000 AS UNIASIG,0.00000000000 AS PESASIG, 0.00000000000 AS UNI2, 0.00000000000 AS PES2, space(20) as ASI, " +
98 " cast(0 as bit) as SEL, cast(0 as bit) as AJENO, cast(0 as bit) as REGULA, space(80) as ORIGEN, 0.00000000000 AS COSTE " +
99 "FROM " + DB.SQLDatabase(
"LOTES",
"STOCKLOTES") +
" a " +
100 " LEFT JOIN " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" b " +
102 " AND a.ALMACEN = b.ALMACEN " +
103 " AND a.ARTICULO = b.ARTICULO " +
104 " AND a.LOTE = b.LOTE " +
105 " AND a.UBICA = b.UBICA " +
106 " AND a.TALLA = b.TALLA " +
107 " AND a.COLOR = b.COLOR " +
108 " AND b.NUMERO = " + DB.SQLString(_oDocLin._Numero) +
110 " AND a.TALLA = " + DB.SQLString(_oDocLin._Talla) +
111 " AND a.COLOR = " + DB.SQLString(_oDocLin._Color) +
112 " AND a.ARTICULO = " + DB.SQLString(_oDocLin._Articulo) +
113 " AND a.ALMACEN = " + DB.SQLString(_oDocLin._Almacen) +
114 " AND a.FECHA <= " + DB.SQLString(_oDocLin._Fecha) +
115 " AND b.LOTE = null " +
116 " AND b.UBICA = null ";
118 DB.SQLExec(lcSql, ref tdtStockLote);
127 return _oLotesConfig._SinMov_Ltctran;
135 if (_oLotesConfig._Mostrar_Rendimiento)
137 DataTable table =
new DataTable();
139 string lcSqlPrevistas =
"SELECT PREVISTAS FROM " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" " +
140 " WHERE PERIODO = " + DB.SQLString(_cPeriodo) +
" " +
141 " AND EMPRESA = " + DB.SQLString(_oDocLin._Empresa) +
" " +
142 " AND NUMERO = " + DB.SQLString(_oDocLin._Numero) +
" " +
143 " AND LOTE = " + DB.SQLString(toDetCodigo.
_Codigo) +
" " +
144 " AND UBICA = " + DB.SQLString(toDetCodigo.
_Ubicacion) +
" " +
145 " AND TALLA = " + DB.SQLString(toDetCodigo.
_Talla) +
" " +
146 " AND COLOR = " + DB.SQLString(toDetCodigo.
_Color) +
" ";
149 DB.SQLExec(lcSqlPrevistas, ref table);
151 if (table != null && table.Rows.Count > 0)
153 _Previstas = Convert.ToDecimal(table.Rows[0][
"PREVISTAS"]);
161 string lcSql =
" AND PERIODO = " + DB.SQLString(_cPeriodo) +
" " +
162 " AND EMPRESA = " + DB.SQLString(_oDocLin._Empresa) +
" " +
163 " AND NUMERO = " + DB.SQLString(_oDocLin._Numero) +
" " +
164 " AND LOTE = " + DB.SQLString(toDetCodigo.
_Codigo) +
" " +
165 " AND UBICA = " + DB.SQLString(toDetCodigo.
_Ubicacion) +
" " +
166 " AND TALLA = " + DB.SQLString(toDetCodigo.
_Talla) +
" " +
167 " AND COLOR = " + DB.SQLString(toDetCodigo.
_Color) +
" ";
169 _dOldCreated = Convert.ToDateTime(DB.SQLValor(
"LTCTRAN",
"1=1 " + lcSql +
" AND '' ",
"",
"CREATED",
"LOTES"));
172 lcSql =
"DELETE FROM " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" WHERE 1=1 " + lcSql;
183 string lcSql =
string.Empty;
185 lcSql =
"INSERT INTO " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" " +
186 "(EMPRESA,NUMERO,FECHA,ARTICULO,LOTE,UNIDADES,PREVISTAS,ACABADO,PERIODO,ALMACEN,CADUCIDAD,UBICA,FECHA2,PESO,TALLA,COLOR,ASI" +
187 (_dOldCreated == DateTime.MinValue ?
"" :
",CREATED") +
190 DB.SQLString(_oDocLin._Empresa) +
", " +
191 DB.SQLString(_oDocLin._Numero) +
", " +
192 DB.SQLString(_oDocLin._Fecha) +
", " +
193 DB.SQLString(_oDocLin._Articulo) +
", " +
194 DB.SQLString(toDetCodigo.
_Codigo) +
", " +
195 DB.SQLString(toDetCodigo.
_Unidades) +
", " +
196 DB.SQLString(_Previstas) +
", " +
197 DB.SQLString(
false) +
", " +
198 DB.SQLString(_cPeriodo) +
", " +
199 DB.SQLString(_oDocLin._Almacen) +
", " +
202 DB.SQLString(DateTime.Now) +
", " +
203 DB.SQLString(toDetCodigo.
_Peso) +
", " +
204 DB.SQLString(_oDocLin._Talla) +
", " +
205 DB.SQLString(_oDocLin._Color) +
", " +
206 DB.SQLString(toDetCodigo.
_Asi) +
" " +
207 (_dOldCreated == DateTime.MinValue ?
"" :
", " + DB.SQLString(_dOldCreated)) +
219 return _oDocLin._NombreArticulo;
241 if (_oLotesConfig._Coste_Lote)
251 _Coste_Cargar_Datos();
252 _Coste_Actualitzar_Datos();
264 return _oLotesConfig._Crear_Transformacion;
274 DataTable ldtCosteLote =
new DataTable();
276 DB.SQLExec(
"SELECT ARTICULO,LOTE" + lcConsulta +
" FROM " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
277 " WHERE PERIODO = " + DB.SQLString(_cPeriodo) +
" " +
278 " AND EMPRESA = " + DB.SQLString(_oDocLin._Empresa) +
279 " AND NUMERO = " + DB.SQLString(_oDocLin._Numero) +
280 " AND LOTE!='' ", ref ldtCosteLote);
291 DB.SQLExec(
" Update " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
292 " Set Asi = " + DB.SQLString(lcAsi) +
293 " WHERE PERIODO = " + DB.SQLString(_cPeriodo) +
" " +
294 " AND EMPRESA = " + DB.SQLString(_oDocLin._Empresa) +
295 " AND NUMERO = " + DB.SQLString(_oDocLin._Numero) +
299 #region IStockExtRegulari 308 toDic.Add(
"SALIDA", tnValor);
318 toDic.Add(
"PESO", tnValor);
340 DataTable ldtOldDades =
new DataTable();
342 bool llCamposAdicionales = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_mcampos2"));
345 lcSql =
"SELECT DISTINCT ASI, ARTICULO, ALMACEN, TALLA, COLOR " + (llCamposAdicionales ?
", LOTE" :
"") +
346 " FROM " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" " +
347 " WHERE PERIODO = " + DB.SQLString(_cPeriodo) +
" " +
348 " AND EMPRESA = " + DB.SQLString(toLinea.
_Empresa) +
" " +
349 " AND NUMERO = " + DB.SQLString(toLinea.
_Numero);
352 if (!DB.SQLExec(lcSql, ref ldtOldDades))
355 lcSql =
"Delete From " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
356 " Where empresa = " + DB.SQLString(toLinea.
_Empresa) +
357 " And numero = " + DB.SQLString(toLinea.
_Numero) +
358 " And periodo = " + DB.SQLString(_cPeriodo);
360 if (!DB.SQLExec(lcSql))
364 string lcArticulo =
string.Empty;
365 string lcAlmacen =
string.Empty;
366 string lcTalla =
string.Empty;
367 string lcColor =
string.Empty;
369 if (ldtOldDades.Rows.Count > 0)
371 foreach (DataRow ldr
in ldtOldDades.Rows)
373 lcArticulo = ldr[
"ARTICULO"].ToString().Trim();
374 lcAlmacen = ldr[
"ALMACEN"].ToString().Trim();
375 lcTalla = ldr[
"TALLA"].ToString().Trim();
376 lcColor = ldr[
"COLOR"].ToString().Trim();
378 if (_oLotesConfig._Coste_Lote)
380 lcSql =
"DELETE " + DB.SQLDatabase(
"LOTES",
"COSTELOT") +
" WHERE ASI = " + DB.SQLString(ldr[
"asi"]) +
" ";
385 if (llCamposAdicionales)
388 DataTable ldtStockPartidas = _Stocklote_Tabla(lcArticulo, ldr[
"LOTE"].ToString().Trim(),
"", lcTalla, lcColor);
389 if (ldtStockPartidas.Rows.Count == 0)
391 string tcCodigoTmp = lcArticulo.PadRight(Convert.ToInt32(EW_GLOBAL._GetLenCampo(global.Diccionarios.KeyDiccionarioLenCampos.wn_articulo))) + ldr[
"LOTE"].ToString().Trim();
400 _Refrescar_Stocks(lcArticulo, lcAlmacen, lcTalla, lcColor);
405 if (lcArticulo != toLinea.
_Articulo.Trim() || lcAlmacen != toLinea.
_Almacen.Trim() || lcTalla != toLinea.
_Talla.Trim() || lcColor != toLinea.
_Color.Trim())
445 bool llGestionEspecial =
false;
456 if (toValue == null) _ReadOnly =
true;
464 if ((toValue is
bool && (
bool)toValue ==
false) || _ReadOnly)
465 _Iniciar_Asignacion_Lotes(toLinea,
false);
467 _Iniciar_Asignacion_Lotes(toLinea,
true);
469 tcMensajeError = _Error_Message;
470 llGestionEspecial =
true;
477 return llGestionEspecial;
487 string lcSql =
"Update " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
488 " Set acabado = " + DB.SQLString(toLinea.
_Acabado) +
", fecha = " + DB.SQLString(toLinea.
_Fecha) +
489 " Where empresa = " + DB.SQLString(toLinea.
_Empresa) +
490 " And numero = " + DB.SQLString(toLinea.
_Numero) +
491 " And periodo = " + DB.SQLString(_cPeriodo);
507 toDic.Add(
"COSTEUNIT", tnValor);
519 string lcSql = String.Empty;
521 lcSql =
"SELECT LOTE AS CODIGO, UNIDADES, PESO " +
522 "FROM " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" " +
523 "WHERE EMPRESA = " + DB.SQLString(toLinea.
_Empresa) +
524 " AND NUMERO = " + DB.SQLString(toLinea.
_Numero) +
525 " AND PERIODO = " + DB.SQLString(_cPeriodo);
526 llOk = DB.SQLExec(lcSql, ref tdtResultados);
541 bool llCondicion =
false;
545 llCondicion = llCondicion || teCampo ==
eCampoDocumentLinea.Talla && !String.IsNullOrWhiteSpace(toLinea.
_Talla) && String.Compare(toLinea.
_Talla, (
string)toValue) != 0;
546 llCondicion = llCondicion || teCampo ==
eCampoDocumentLinea.Color && !String.IsNullOrWhiteSpace(toLinea.
_Color) && String.Compare(toLinea.
_Color, (
string)toValue) != 0;
547 llCondicion = llCondicion && toLinea.
_Unidades > 0;
554 string lcDef = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_deflote"));
556 tcMensajeRespuesta =
"No se puede modificar el artículo de la cabecera, porque existen unidades asignadas.";
584 #endregion IStockExtRegulari 592 private string _cPeriodo = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_any"));
611 DataTable table =
new DataTable();
615 DB.SQLExec(
" SELECT 1 FROM " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" " +
616 " WHERE PERIODO = " + DB.SQLString(_cPeriodo) +
617 " AND EMPRESA = " + DB.SQLString(toLinea.
_Empresa) +
618 " AND NUMERO = " + DB.SQLString(toLinea.
_Numero) +
619 " AND LINIA = " + DB.SQLString(lnlinea) +
620 " AND LOTE = " + DB.SQLString(toLote._Lote) +
621 " AND UBICA = " + DB.SQLString(
"") +
622 " AND TALLA = " + DB.SQLString(toLinea.
_Talla) +
623 " AND COLOR = " + DB.SQLString(toLinea.
_Color), ref table);
625 if (table.Rows.Count == 0)
627 DB.SQLExec(
"INSERT INTO " + DB.SQLDatabase(
"LOTES",
"LTCTRAN") +
" " +
628 "(EMPRESA,NUMERO,FECHA,ARTICULO,LINIA,LOTE,UNIDADES,PERIODO,ALMACEN,CADUCIDAD,UBICA,FECHA2,PESO,TALLA,COLOR,ASI) " +
630 DB.SQLString(toLinea.
_Empresa) +
", " +
631 DB.SQLString(toLinea.
_Numero) +
", " +
632 DB.SQLString(toLinea.
_Fecha) +
", " +
633 DB.SQLString(toLote._Articulo) +
", " +
634 DB.SQLString(lnlinea) +
", " +
635 DB.SQLString(toLote._Lote) +
", " +
636 DB.SQLString(toLote._Unidades) +
", " +
637 DB.SQLString(_cPeriodo) +
", " +
638 DB.SQLString(toLinea.
_Almacen) +
", " +
639 DB.SQLString(toLote._Caducidad) +
", " +
640 DB.SQLString(toLote._Ubicacion) +
", " +
641 DB.SQLString(DateTime.Now) +
", " +
642 DB.SQLString(toLote._Peso) +
", " +
643 DB.SQLString(toLinea.
_Talla) +
", " +
644 DB.SQLString(toLinea.
_Color) +
", " +
645 DB.SQLString(toLote._Asi) +
") ");
Clase para controlar toda la gestion de venta de un lote/ubicacion de artículo
Clase para la gestión de los lotes
string _Talla
Codigo de la talla
Interficie mínima de las líneas (Mantener lo mas reducida posible)
eCampoDocumentLinea
Definición del enumerado de los campos de una linea de documento
Nullable< DateTime > _Caducidad
Fecha de caducidad del lote (Accepta NULL)
Interficie para operaciones extendidas de fabricación
string _Color
Codigo de color
virtual Boolean _Delete()
Elimina los valores de los campos adicionales
string _Codigo
Código de lote asociado
decimal _Peso
Peso asignado a la venta
string _Ubicacion
Código de la ubicación
TipoDocumento
Enum del tipo de codumento
Definición de la interfície necesaria para los objetos de documento utilizados en el formulario FormD...
string _Asi
Asi del registro
int _LineaReal
Devuelve el campo linia: para todos los documentos sera el mismo valor que la linea pero en el docume...
decimal _Unidades
Unidades asignadas a la venta