6 using System.Collections.Generic;
10 using System.Windows.Forms;
26 public const string _cPathBase =
@"\reports\sage.ew.reports\etiquetas\base\";
31 public const string _cPathPersonalizado =
@"\reports\sage.ew.reports\etiquetas\personalizados\";
36 public const string _cReportBase =
"template.template";
38 private string _cPathEtiquetas =
string.Empty;
43 public string _TipoEtiqueta
47 return _cTipoEtiqueta;
51 _cTipoEtiqueta = value;
54 private string _cTipoEtiqueta =
string.Empty;
59 public List<EtiquetaCliente> _EtiquetasCliente =
new List<EtiquetaCliente>();
61 private string _cTerminalActual = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_terminal")).ToString().Trim();
63 private DataTable ldtEtiqueta =
new DataTable();
69 #region PUBLIC METHODS 86 DataTable table =
new DataTable();
100 DataTable table =
new DataTable();
112 ldtEtiqueta =
new DataTable();
113 string lcEtiqueta =
string.Empty;
116 _EtiquetasCliente =
new List<EtiquetaCliente>();
119 if (
string.IsNullOrWhiteSpace(_TipoEtiqueta))
123 ldtEtiqueta = _etiquetasClienteDA.
Load(_TipoEtiqueta,
"");
125 ComprobarEtiquetaTerminalActual(ldtEtiqueta);
127 ldtEtiqueta = _etiquetasClienteDA.
Load(_TipoEtiqueta,
"");
130 _cPathEtiquetas = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_iniservidor")).ToString().Trim() + _cPathBase + _TipoEtiqueta +
@"\";
133 string[] filePaths = { };
136 filePaths = Directory.GetFiles(_cPathEtiquetas,
"*.report")
137 .Select(path => Path.GetFileNameWithoutExtension(path))
143 sage.
ew.
functions.
FUNCTIONS._MessageBox(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
147 foreach (DataRow ldrRow
in ldtEtiqueta.Rows)
149 lcEtiqueta = Convert.ToString(ldrRow[
"nombre"]).Trim();
151 string lcRutaPersonalizado = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_iniservidor")).ToString().Trim() + _cPathPersonalizado + _TipoEtiqueta +
@"\";
154 _cPathEtiquetas = lcRutaPersonalizado;
156 if (!File.Exists(_cPathEtiquetas + lcEtiqueta +
".report"))
158 _cPathEtiquetas = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_iniservidor")).ToString().Trim() + _cPathBase + _TipoEtiqueta +
@"\";
161 if (File.Exists(_cPathEtiquetas + lcEtiqueta +
".report"))
165 loEtiqueta.
_Nombre = lcEtiqueta;
168 XmlDocument doc =
new XmlDocument();
169 doc.LoadXml(ldrRow[
"config"].ToString());
170 XmlElement root = doc.DocumentElement;
171 XmlNodeList nodes = root.SelectNodes(
"//*");
172 foreach (XmlNode node
in nodes)
177 loEtiqueta._Impresora = node.InnerText;
180 case "impresoraEtiqueta":
181 loEtiqueta._ImpresoraEtiqueta = Convert.ToBoolean(node.InnerText);
184 case "predeterminada":
185 loEtiqueta._Predeterminada = Convert.ToBoolean(node.InnerText);
190 _EtiquetasCliente.Add(loEtiqueta);
194 bool llTrobat =
false;
195 foreach (
string lcFile
in filePaths)
213 _EtiquetasCliente.Add(loEtiqueta);
218 #endregion PUBLIC METHODS 220 #region PRIVATE METHODS 222 private void ComprobarEtiquetaTerminalActual(DataTable ldtEtiqueta)
224 DataTable ldtEtiqTerminal =
new DataTable();
226 if (ldtEtiqueta != null && ldtEtiqueta.Rows.Count > 0)
228 List<string> valoresNombre = ldtEtiqueta.AsEnumerable()
229 .Select(d => d.Field<
string>(
"nombre")).Distinct().ToList();
231 if (valoresNombre.Count > 0)
233 var nombresTerminal = ldtEtiqueta.AsEnumerable().Where(r => r.Field<
string>(
"terminal").ToString().Trim() == _cTerminalActual).Select(g => g.Field<
string>(
"nombre")).ToList();
234 if (nombresTerminal.Count != valoresNombre.Count)
236 foreach (
string loVal
in valoresNombre)
238 if (!nombresTerminal.Contains(loVal))
240 DataRow loRegistro = ldtEtiqueta.AsEnumerable().Where(r => r.Field<
string>(
"nombre").ToString() == loVal).Select(g => g).FirstOrDefault();
241 if (loRegistro != null)
243 _etiquetasClienteDA.
Insert(loRegistro, _TipoEtiqueta);
252 #endregion PRIVATE METHODS 264 private string _cPathEtiquetas =
string.Empty;
266 private string _cNombre =
string.Empty;
267 private string _cImpresora =
string.Empty;
268 private bool _bImpresoraEtiqueta =
false;
269 private bool _bPredeterminada =
false;
270 private string _cTipoEtiqueta =
string.Empty;
278 private List<string> _lstFields =
new List<string>()
280 "codigo",
"definicion",
"direccion",
"postal",
"poblacion",
"provincia",
"contacto" 287 public DataTable _DataTable
292 if (_oDataTable.Columns.Count == 0)
294 foreach (
string field
in _lstFields)
296 _oDataTable.Columns.Add(field);
298 _oDataTable.TableName = _cTableName;
307 private DataTable _oDataTable =
new DataTable();
311 private string _cTableName =
"cliente";
316 public string _TipoEtiqueta
320 return _cTipoEtiqueta;
324 _cTipoEtiqueta = value.ToLower();
331 public string _ReportBase
339 _cReportBase = value;
347 public string _Nombre
355 _cNombre = value.ToLower();
362 public string _Impresora
377 public bool _ImpresoraEtiqueta
381 return _bImpresoraEtiqueta;
385 _bImpresoraEtiqueta = value;
392 public bool _Predeterminada
396 return _bPredeterminada;
400 _bPredeterminada = value;
426 _lstFields = tlisCampos;
432 #region PUBLIC METHODS 439 string lcSql =
string.Empty;
440 DataTable ldtEtiqueta =
new DataTable();
441 string lcXmlConfig =
string.Empty;
446 if (this._Predeterminada)
448 DataTable ldtEtiquetasTipo =
new DataTable();
452 loEtiquetasCliente.
_Load();
461 ldtEtiqueta = _etiquetasClienteDA.
Load(_TipoEtiqueta, _Nombre);
462 lcXmlConfig = _EtiquetaConfigToXml();
464 if (ldtEtiqueta != null && ldtEtiqueta.Rows.Count > 0)
467 _etiquetasClienteDA.
Update(_TipoEtiqueta, _Nombre, lcXmlConfig);
472 _etiquetasClienteDA.
Insert(_TipoEtiqueta, _Nombre, lcXmlConfig);
485 botones.Clases.btImprimir btImprimir1 =
new botones.Clases.btImprimir();
490 btImprimir1._TipoEtiqueta = _TipoEtiqueta;
491 btImprimir1._Report = _Nombre +
".report";
494 btImprimir1._DataTable = _DataTable;
495 btImprimir1._Title = btImprimir1._DataTable.TableName;
497 btImprimir1._Filtros.Clear();
509 botones.Clases.btImprimir btImprimir1 =
new botones.Clases.btImprimir();
512 btImprimir1._TipoEtiqueta = _TipoEtiqueta;
513 btImprimir1._Report = _Nombre +
".report";
515 btImprimir1._Filtros.Clear();
517 btImprimir1._DataTable = _DataTable;
518 btImprimir1._Title =
"cliente";
520 btImprimir1._Printer = _Impresora;
522 btImprimir1._Print();
534 DataTable ldtEtiqueta = _etiquetasClienteDA.
Load(_TipoEtiqueta, _Nombre);
536 if (ldtEtiqueta != null && ldtEtiqueta.Rows.Count > 0)
540 string lcRutaPersonalizado = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_iniservidor")).ToString().Trim() + _cPathPersonalizado + _TipoEtiqueta +
@"\";
543 _cPathEtiquetas = lcRutaPersonalizado;
545 if (!File.Exists(_cPathEtiquetas + _ReportBase))
547 _cPathEtiquetas = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_iniservidor")).ToString().Trim() + _cPathBase + _TipoEtiqueta +
@"\";
551 if (File.Exists(_cPathEtiquetas + _ReportBase))
555 if (!(Directory.Exists(lcRutaPersonalizado)))
557 Directory.CreateDirectory(lcRutaPersonalizado);
560 if (Directory.Exists(lcRutaPersonalizado))
562 File.Copy(_cPathEtiquetas + _ReportBase, lcRutaPersonalizado + _Nombre +
".report",
true);
564 _Treure_Solo_Lectura(lcRutaPersonalizado + _Nombre +
".report");
578 _cPathEtiquetas = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_iniservidor")).ToString().Trim() + _cPathPersonalizado + _TipoEtiqueta +
@"\";
580 if (!File.Exists(_cPathEtiquetas + _Nombre +
".report"))
582 _cPathEtiquetas = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_iniservidor")).ToString().Trim() + _cPathBase + _TipoEtiqueta +
@"\";
586 if (File.Exists(_cPathEtiquetas + _Nombre +
".report"))
588 _Treure_Solo_Lectura(_cPathEtiquetas + _Nombre +
".report");
590 File.Delete(_cPathEtiquetas + _Nombre +
".report");
595 _etiquetasClienteDA.
Delete(_TipoEtiqueta, _Nombre);
605 formul.Forms.frmEtiquetasPropiedades loForm =
new formul.Forms.frmEtiquetasPropiedades();
606 loForm._Etiqueta = (interficies.IEtiquetasPropiedades)
this;
607 loForm._ShowDialog();
608 return loForm.DialogResult;
613 #region PRIVATE METHODS 619 private string _EtiquetaConfigToXml()
621 XmlDocument doc =
new XmlDocument();
622 XmlNode docNode = doc.CreateXmlDeclaration(
"1.0",
"UTF-8", null);
623 doc.AppendChild(docNode);
625 XmlNode etiquetaNode = doc.CreateElement(
"etiqueta");
626 doc.AppendChild(etiquetaNode);
629 XmlNode nombreNode = doc.CreateElement(
"nombre");
630 nombreNode.InnerText = _Nombre;
631 etiquetaNode.AppendChild(nombreNode);
634 XmlNode tipoNode = doc.CreateElement(
"tipo");
635 tipoNode.InnerText = _TipoEtiqueta;
636 etiquetaNode.AppendChild(tipoNode);
639 XmlNode impresoraNode = doc.CreateElement(
"impresora");
640 impresoraNode.InnerText = _Impresora;
641 etiquetaNode.AppendChild(impresoraNode);
644 XmlNode impresoraEtiquetaNode = doc.CreateElement(
"impresoraEtiqueta");
645 impresoraEtiquetaNode.InnerText = _ImpresoraEtiqueta.ToString();
646 etiquetaNode.AppendChild(impresoraEtiquetaNode);
649 XmlNode predeterminadaNode = doc.CreateElement(
"predeterminada");
650 predeterminadaNode.InnerText = _Predeterminada.ToString();
651 etiquetaNode.AppendChild(predeterminadaNode);
656 private void _Treure_Solo_Lectura(String tcFile)
658 FileAttributes loattributes = File.GetAttributes(tcFile);
660 if ((loattributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
663 loattributes = loattributes & ~FileAttributes.ReadOnly;
664 File.SetAttributes(tcFile, loattributes);
683 #region PROPIEDADES PUBLICAS 688 public bool _Sel {
get;
set; } =
false;
693 public string _Codigo
701 if (_cCodigo != value)
707 _Nombre = _Cliente._Nombre;
709 if (!
string.IsNullOrWhiteSpace(_Nombre))
711 _Direccion = _Cliente._Direccion;
712 _Postal = _Cliente._CodPost; ;
713 _Poblacion = _Cliente._Poblacion;
714 _Provincia = _Cliente._Provincia;
715 _Contacto = _Cliente._Contacto;
722 private string _cCodigo =
string.Empty;
727 public string _Nombre {
get;
set; } =
string.Empty;
734 public string _Direccion {
get;
set; } =
string.Empty;
739 public string _Postal {
get;
set; } =
string.Empty;
744 public string _Poblacion {
get;
set; } =
string.Empty;
749 public string _Provincia {
get;
set; } =
string.Empty;
754 public string _Contacto {
get;
set; } =
string.Empty;
759 public int _Etiquetas {
get;
set; } = 0;
765 #endregion PROPIEDADES PUBLICAS 792 _Etiquetas = tnEtiquetas;
794 _Cliente = toCliente;
800 _Direccion = loDic[
"direccion"].ToString();
801 _Postal = loDic[
"codpos"].ToString();
802 _Poblacion = loDic[
"poblacion"].ToString();
803 _Provincia = loDic[
"provincia"].ToString();
807 _Direccion = _Cliente._Direccion;
808 _Postal = _Cliente._CodPost; ;
809 _Poblacion = _Cliente._Poblacion;
810 _Provincia = _Cliente._Provincia;
813 _Contacto = _Cliente._Contacto;
823 _Sel = Convert.ToBoolean(tdrLin[
"SELECCIONADAS"]);
825 _Codigo = Convert.ToString(tdrLin[
"CLIENTE"]).Trim();
826 _Nombre = Convert.ToString(tdrLin[
"DEFINICION"]).Trim();
828 _Cliente =
new Cliente(_Codigo);
830 if (
string.IsNullOrWhiteSpace(_Nombre))
832 _Nombre = _Cliente._Nombre;
835 _Direccion = _Cliente._Direccion;
836 _Postal = _Cliente._CodPost; ;
837 _Poblacion = _Cliente._Poblacion;
838 _Provincia = _Cliente._Provincia;
839 _Contacto = _Cliente._Contacto;
842 _Etiquetas = Convert.ToInt32(tdrLin[
"ETIQUETAS"]);
string _TipoEtiqueta
propiedad publica para el tipo de etiqueta a partir del cual se cargaran las etiquetas en _Load ...
string _TipoEtiqueta
Tipo de Etiqueta
bool _Predeterminada
nos indica que es la impresora predeterminada
Clase Etiqueta de cliente
DataTable Load(string tcTipoEtiqueta, string tcNombre)
Método para cargar los registros de las etiquetas
EtiquetaImprimir()
Inicializa una nueva instancia de la clase LotePesadas
override string _Codigo
PE-102491: override de _Codigo para que en el Set podamos convertir el número que nos llega a código ...
EtiquetaImprimir(Cliente toCliente, int tnEnv_Cli, int tnEtiquetas)
Inicializa una nueva instancia de la clase EtiquetaImprimir
object Retrieve(Type T)
Resuelve objeto de tipo T
override string _Nombre
Nombre del cliente a partir del campo NOMBRE de la tabla CLIENTES de la base de datos de GESTION de E...
void _Save()
método _Save para guardar en la base de datos las propiedades de la Etiqueta en la tabla de COMUNES!E...
Interfaz de etiquetas de cliente
bool _Comprobar()
Método para comprobar si la etiqueta es correcta
DataTable GetContactos(string tcCodigo)
Método para cargar los contactos del cliente
Clase para la gestión de las etiquetas de cliente
string _Nombre
Nombre de la Etiqueta
Clase para cargar la configuración del módulo de LOTES
bool Delete(string tcTipoEtiqueta, string tcNombre)
Método para eliminar los registros de las etiquetas
void _Print()
Método para lanzar la impresión de la Etiqueta a partir de un DataTable El datatable debe tener los c...
Dictionary< string, object > _Direccion_Predeterminada(int tnDireccion=0)
Devuelve en un diccionario la dirección predeterminada del cliente
Clase para uso de funciones genéricas
const string _cReportBase
Report base del que se copiaran los nuevos reports
EtiquetaImprimir(DataRow tdrLin)
Inicializa una nueva instancia de la clase EtiquetaImprimir
DataTable _GetDirecciones(string tcCodigo)
Método para cargar las direcciones del cliente
DataTable _GetContactos(string tcCodigo)
Método para cargar los contactos del cliente
Clase de las etiquetas para imprimir
EtiquetasCliente()
Constructor vacío
TipoReport
Enum para saber TipoReport
EtiquetaCliente(List< string > tlisCampos)
Constructor con parámetros
DataTable GetDirecciones(string tcCodigo)
Método para cargar las direcciones del cliente
static DependencyInjector Instance
Instancia
EtiquetaCliente()
constructor
bool Insert(DataRow loRegistro, string TipoEtiqueta)
Método para la inserción de registros
void _Load()
método para cargar la lista de etiquetas en _Etiquetas a partir del _TipoEtiqueta ...
void _Design()
Método para lanzar el diseño de la Etiqueta
void _Delete()
borrar una etiqueta (borrar de la tabla etiquetas y borrar el fichero .report)
bool Update(string tcTipoEtiqueta, string tcNombre, string tcXml)
Método para la actualización de registros
Clase Inyector de dependencias para resolver las dependencias
DialogResult _Show()
Método para lanzar el formulario frmEtiquetasPropiedades