Cash.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Data;
6 using System.Xml;
7 using System.Xml.Linq;
8 
9 using sage.ew.interficies;
10 using sage.ew.db;
11 using sage.ew.global;
12 using sage.ew.docsven;
13 using System.Net.Sockets;
14 using System.ComponentModel;
15 using System.Collections;
16 using sage.ew.tpv.Clases;
17 using sage.ew.ewbase;
19 
20 namespace sage.ew.tpv
21 {
25  public class Cash : ICash, INotifyPropertyChanged
26  {
30  protected internal ewMascara _oMascaraPrecio = new ewMascara(EW_GLOBAL._GetMascara(KeyDiccionarioMascara.wc_total));
31 
35  protected internal string _cMoneda = EW_GLOBAL._GetVariable("wc_moneda").ToString();
36 
37  #region Custom Events
38 
43 
49  public void LanzarEvento_MostrarMensajeUsuario(bool tlMostrar = true, bool tlOk = true)
50  {
51  var handler = _NotificarUsuario; //Copia del evento para garantizar ThreadSafe
52  if (handler != null)
53  {
54  handler(this, new EwCashNotifyEventArgs(tlMostrar, tlOk));
55  }
56  }
57 
58  #endregion Custom Events
59 
60  #region INotifyPropertyChanged
61 
65  public event PropertyChangedEventHandler PropertyChanged;
66 
71  private void NotifyPropertyChanged(String tcNombrePropidad)
72  {
73  var handler = PropertyChanged; //Copia del evento para garantizar ThreadSafe
74  if (handler != null)
75  {
76  handler(this, new PropertyChangedEventArgs(tcNombrePropidad));
77  }
78  }
79 
80  #endregion INotifyPropertyChanged
81 
82  #region PROPIEDADES
83 
87  public string _CodigoFormaCobro
88  {
89  get { return _cCodigoFormaCobro; }
90  set
91  {
92  if (_cCodigoFormaCobro != value)
93  {
94  _cCodigoFormaCobro = value;
95  NotifyPropertyChanged("_CodigoFormaCobro");
96  }
97  }
98  }
99  private string _cCodigoFormaCobro;
100 
104  public decimal _Entrega
105  {
106  get { return _nEntrega; }
107  set
108  {
109  if (_nEntrega != value)
110  {
111  _nEntrega = value;
112  NotifyPropertyChanged("_Entrega");
113  }
114  }
115  }
116  private decimal _nEntrega;
117 
121  public decimal _Cambio
122  {
123  get { return _nCambio; }
124  set
125  {
126  if (_nCambio != value)
127  {
128  _nCambio = value;
129  NotifyPropertyChanged("_Cambio");
130  }
131  }
132  }
133  private decimal _nCambio;
134 
138  public bool _Activo
139  {
140  get { return _lActivo; }
141  set
142  {
143  if (_lActivo != value)
144  {
145  _lActivo = value;
146  NotifyPropertyChanged("_Activo");
147  }
148  }
149  }
150  private bool _lActivo;
151 
155  public bool _PermitirEntregasParciales
156  {
157  get { return _nPermitirEntregasParciales; }
158  set
159  {
160  if (_nPermitirEntregasParciales != value)
161  {
162  _nPermitirEntregasParciales = value;
163  NotifyPropertyChanged("_PermitirEntregasParciales");
164  }
165  }
166  }
167  private bool _nPermitirEntregasParciales;
168 
172  public string _Terminal
173  {
174  get { return _cTerminal; }
175  set
176  {
177  if (_cTerminal != value)
178  {
179  _cTerminal = value;
180  NotifyPropertyChanged("_Terminal");
181  }
182  }
183  }
184  private string _cTerminal = Convert.ToString(EW_GLOBAL._GetVariable("wc_terminal"));
185 
189  public string _Error_Message
190  {
191  get { return _cError_Message; }
192  set
193  {
194  if (_cError_Message != value)
195  {
196  _cError_Message = value;
197  NotifyPropertyChanged("_Error_Message");
198  }
199  }
200  }
201  private string _cError_Message;
202 
206  public string _Warning_Message
207  {
208  get { return _cWarning_Message; }
209  set
210  {
211  if (_cWarning_Message != value)
212  {
213  _cWarning_Message = value;
214  NotifyPropertyChanged("_Warning_Message");
215  }
216  }
217  }
218  private string _cWarning_Message;
219 
223  public string _Wait_Conection_Message
224  {
225  get { return _cWait_Conection_Message; }
226  set
227  {
228  if (_cWait_Conection_Message != value)
229  {
230  _cWait_Conection_Message = value;
231  NotifyPropertyChanged("_Wait_Conection_Message");
232  }
233  }
234  }
235  private string _cWait_Conection_Message = "Operando con el cajón inteligente.";
236 
237 
241  public Dictionary<string, object> _Propiedades
242  {
243  get { return _oPropiedades; }
244  set
245  {
246  if (_oPropiedades != value)
247  {
248  _oPropiedades = value;
249  NotifyPropertyChanged("_Propiedades");
250  }
251  }
252  }
253  private Dictionary<string, object> _oPropiedades = new Dictionary<string, object>();
254 
258  public eCash_OrdenImpresion _ImprimirDocumento
259  {
260  get { return _oImprimirDocumento; }
261  set
262  {
263  if (_oImprimirDocumento != value)
264  {
265  _oImprimirDocumento = value;
266  NotifyPropertyChanged("_ImprimirDocumento");
267  }
268  }
269  }
270  private eCash_OrdenImpresion _oImprimirDocumento = eCash_OrdenImpresion.DespuesCash;
271 
272  #region Cobros Caja
273  public bool _Visible_CobrosCaja
277  {
278  get { return _lVisible_CobrosCaja; }
279  set
280  {
281  if (_lVisible_CobrosCaja != value)
282  {
283  _lVisible_CobrosCaja = value;
284  NotifyPropertyChanged("_Visible_CobrosCaja");
285  }
286  }
287  }
288  private bool _lVisible_CobrosCaja = true;
289 
293  public bool _Permitir_CobrosCaja
294  {
295  get { return _lPermitir_CobrosCaja; }
296  set
297  {
298  if (_lPermitir_CobrosCaja != value)
299  {
300  _lPermitir_CobrosCaja = value;
301  NotifyPropertyChanged("_Permitir_CobrosCaja");
302  }
303  }
304  }
305  private bool _lPermitir_CobrosCaja = true;
306  #endregion
307 
308  #region Cobros Facturas
309  public bool _Visible_CobrosFacturas
313  {
314  get { return _lVisible_CobrosFacturas; }
315  set
316  {
317  if (_lVisible_CobrosFacturas != value)
318  {
319  _lVisible_CobrosFacturas = value;
320  NotifyPropertyChanged("_Visible_CobrosFacturas");
321  }
322  }
323  }
324  private bool _lVisible_CobrosFacturas = true;
325 
329  public bool _Permitir_CobrosFacturas
330  {
331  get { return _lPermitir_CobrosFacturas; }
332  set
333  {
334  if (_lPermitir_CobrosFacturas != value)
335  {
336  _lPermitir_CobrosFacturas = value;
337  NotifyPropertyChanged("_Permitir_CobrosFacturas");
338  }
339  }
340  }
341  private bool _lPermitir_CobrosFacturas = false;
342  #endregion
343 
344  #region Cobros Varios
345  public bool _Visible_CobrosVarios
349  {
350  get { return _lVisible_CobrosVarios; }
351  set
352  {
353  if (_lVisible_CobrosVarios != value)
354  {
355  _lVisible_CobrosVarios = value;
356  NotifyPropertyChanged("_Visible_CobrosVarios");
357  }
358  }
359  }
360  private bool _lVisible_CobrosVarios = true;
361 
365  public bool _Permitir_CobrosVarios
366  {
367  get { return _lPermitir_CobrosVarios; }
368  set
369  {
370  if (_lPermitir_CobrosVarios != value)
371  {
372  _lPermitir_CobrosVarios = value;
373  NotifyPropertyChanged("_Permitir_CobrosVarios");
374  }
375  }
376  }
377  private bool _lPermitir_CobrosVarios = false;
378  #endregion
379 
380  #region Pagos Varios
381  public bool _Visible_PagosVarios
385  {
386  get { return _lVisible_PagosVarios; }
387  set
388  {
389  if (_lVisible_PagosVarios != value)
390  {
391  _lVisible_PagosVarios = value;
392  NotifyPropertyChanged("_Visible_PagosVarios");
393  }
394  }
395  }
396  private bool _lVisible_PagosVarios = true;
397 
401  public bool _Permitir_PagosVarios
402  {
403  get { return _lPermitir_PagosVarios; }
404  set
405  {
406  if (_lPermitir_PagosVarios != value)
407  {
408  _lPermitir_PagosVarios = value;
409  NotifyPropertyChanged("_Permitir_PagosVarios");
410  }
411  }
412  }
413  private bool _lPermitir_PagosVarios = false;
414  #endregion
415 
416  #region Reposiciones
417  public bool _Visible_Reposiciones
421  {
422  get { return _lVisible_Reposiciones; }
423  set
424  {
425  if (_lVisible_Reposiciones != value)
426  {
427  _lVisible_Reposiciones = value;
428  NotifyPropertyChanged("_Visible_Reposiciones");
429  }
430  }
431  }
432  private bool _lVisible_Reposiciones = true;
433 
437  public bool _Permitir_Reposiciones
438  {
439  get { return _lPermitir_Reposiciones; }
440  set
441  {
442  if (_lPermitir_Reposiciones != value)
443  {
444  _lPermitir_Reposiciones = value;
445  NotifyPropertyChanged("_Permitir_Reposiciones");
446  }
447  }
448  }
449  private bool _lPermitir_Reposiciones = false;
450  #endregion
451 
452  #region Retiros
453  public bool _Visible_Retiros
457  {
458  get { return _lVisible_Retiros; }
459  set
460  {
461  if (_lVisible_Retiros != value)
462  {
463  _lVisible_Retiros = value;
464  NotifyPropertyChanged("_Visible_Retiros");
465  }
466  }
467  }
468  private bool _lVisible_Retiros = true;
469 
473  public bool _Permitir_Retiros
474  {
475  get { return _lPermitir_Retiros; }
476  set
477  {
478  if (_lPermitir_Retiros != value)
479  {
480  _lPermitir_Retiros = value;
481  NotifyPropertyChanged("_Permitir_Retiros");
482  }
483  }
484  }
485  private bool _lPermitir_Retiros = false;
486  #endregion
487 
488  #region Arqueos
489  public bool _Visible_Arqueos
493  {
494  get { return _lVisible_Arqueos; }
495  set
496  {
497  if (_lVisible_Arqueos != value)
498  {
499  _lVisible_Arqueos = value;
500  NotifyPropertyChanged("_Visible_Arqueos");
501  }
502  }
503  }
504  private bool _lVisible_Arqueos = false;
505 
509  public bool _Permitir_Arqueos
510  {
511  get { return _lPermitir_Arqueos; }
512  set
513  {
514  if (_lPermitir_Arqueos != value)
515  {
516  _lPermitir_Arqueos = value;
517  NotifyPropertyChanged("_Permitir_Arqueos");
518  }
519  }
520  }
521  private bool _lPermitir_Arqueos = false;
522  #endregion
523 
524  #endregion PROPIEDADES
525 
526  #region CONSTRUCTOR
527 
531  public Cash()
532  {
533  // Carrega els valors
534  this._Load();
535  }
536 
537  #endregion CONSTRUCTOR
538 
539  #region METODOS
540  public virtual bool _Load()
544  {
545  bool llOk = false;
546 
547  //Si no tenemos el codigo del terminal que ha entrado, salimos
548  if (this._Terminal == null)
549  {
550  this._Error_Message = "Para cargar la configuración del cash es necesario el terminal.";
551  return false;
552  }
553 
554  //Contendra el registro "cash" de la Base de datos
555  DataTable dtResult = new DataTable();
556 
557  //Recogemos la configuración de la bascula
558  string sql = "select CASHXML from " + DB.SQLDatabase("COMUNES", "TERMINAL") + " WHERE codigo=" + DB.SQLString(this._Terminal);
559  if (DB.SQLExec(sql, ref dtResult))
560  {
561  if (dtResult != null && dtResult.Rows.Count > 0)
562  {
563  //Carga el contenido del XML de la Base de datos
564  XmlDocument doc = new XmlDocument();
565  DataRow drRow = dtResult.Rows[0];
566  if (!String.IsNullOrEmpty(drRow[0].ToString()))
567  {
568  doc.LoadXml(drRow[0].ToString());
569 
570  //Cogemos todas las variables, en un diccionario
571  foreach (XmlNode node in doc.SelectSingleNode("//curCash"))
572  {
573  if (node.LastChild != null)
574  {
575  if (this._oPropiedades.ContainsKey(node.Name))
576  {
577  this._oPropiedades[node.Name] = node.LastChild.Value; //Modificamos
578  }
579  else
580  {
581  this._oPropiedades.Add(node.Name, node.LastChild.Value); //Añadimos
582  }
583 
584  //Convierto el nombre del nodo al enumerable de propiedades
585  eCash_NombrePropiedad lePropiedad = _GetEnum_NombrePropiedad(node.Name);
586 
587  switch (lePropiedad)
588  {
589  case eCash_NombrePropiedad.Permitir_CobrosCaja:
590  _lPermitir_CobrosCaja = Convert.ToBoolean(node.LastChild.Value);
591  break;
592 
593  case eCash_NombrePropiedad.Permitir_CobrosFacturas:
594  _lPermitir_CobrosFacturas = Convert.ToBoolean(node.LastChild.Value);
595  break;
596  case eCash_NombrePropiedad.Permitir_CobrosVarios:
597  _lPermitir_CobrosVarios = Convert.ToBoolean(node.LastChild.Value);
598  break;
599  case eCash_NombrePropiedad.Permitir_PagosVarios:
600  _lPermitir_PagosVarios = Convert.ToBoolean(node.LastChild.Value);
601  break;
602  case eCash_NombrePropiedad.Permitir_Reposiciones:
603  _lPermitir_Reposiciones = Convert.ToBoolean(node.LastChild.Value);
604  break;
605 
606  case eCash_NombrePropiedad.Permitir_Retiros:
607  _lPermitir_Retiros = Convert.ToBoolean(node.LastChild.Value);
608  break;
609  case eCash_NombrePropiedad.Visible_CobrosCaja:
610  _lVisible_CobrosCaja = Convert.ToBoolean(node.LastChild.Value);
611  break;
612 
613  case eCash_NombrePropiedad.Visible_CobrosFacturas:
614  _lVisible_CobrosFacturas = Convert.ToBoolean(node.LastChild.Value);
615  break;
616 
617  case eCash_NombrePropiedad.Visible_CobrosVarios:
618  _lVisible_CobrosVarios = Convert.ToBoolean(node.LastChild.Value);
619  break;
620 
621  case eCash_NombrePropiedad.Visible_PagosVarios:
622  _lVisible_PagosVarios = Convert.ToBoolean(node.LastChild.Value);
623  break;
624 
625  case eCash_NombrePropiedad.Visible_Reposiciones:
626  _lVisible_Reposiciones = Convert.ToBoolean(node.LastChild.Value);
627  break;
628  case eCash_NombrePropiedad.Visible_Retiros:
629  _lVisible_Retiros = Convert.ToBoolean(node.LastChild.Value);
630  break;
631 
632  case eCash_NombrePropiedad.formacobro:
633  this._cCodigoFormaCobro = node.LastChild.Value;
634  break;
635 
636  case eCash_NombrePropiedad.imprimirdocumento:
637  switch (node.LastChild.Value)
638  {
639  case "0":
640  this._oImprimirDocumento = eCash_OrdenImpresion.AntesCash;
641  break;
642 
643  case "1":
644  this._oImprimirDocumento = eCash_OrdenImpresion.DespuesCash;
645  break;
646 
647  case "2":
648  this._oImprimirDocumento = eCash_OrdenImpresion.NoImprimir;
649  break;
650  }
651  break;
652 
653  default:
654  break;
655  }
656  }
657  }
658  llOk = true;
659  }
660  }
661  }
662 
663  //Inicio un notificador
664  _Obtener_Notificador();
665 
666  return llOk;
667  }
668 
672  public virtual bool _Save()
673  {
674  //Si no tenemos el codigo del usuario que ha entrado, salimos
675  if (this._Terminal == null)
676  {
677  this._Error_Message = "Para guardar la configuración del cash es necesario el terminal.";
678  return false;
679  }
680 
681  //Si no tenemos la forma de cobro asignada, salimos
682  if (this._CodigoFormaCobro == null)
683  {
684  this._Error_Message = "Para guardar la configuración del cash es necesario definir la forma de cobro asociada.";
685  return false;
686  }
687 
688  //Variable para resolver el nombre de la propiedad
689  string lcNombrePropiedad = "";
690 
691 
692  // Guardo la forma de cobro
693  lcNombrePropiedad = eCash_NombrePropiedad.formacobro.ToString().ToLower();
694  _Update_Property(lcNombrePropiedad, _cCodigoFormaCobro);
695 
696  // Guardo el moment en que s'ha d'imprimir el document
697  int lnImprimirDocumento = 0;
698  switch (this._oImprimirDocumento)
699  {
700  case eCash_OrdenImpresion.AntesCash:
701  lnImprimirDocumento = 0;
702  break;
703 
704  case eCash_OrdenImpresion.DespuesCash:
705  lnImprimirDocumento = 1;
706  break;
707 
708  case eCash_OrdenImpresion.NoImprimir:
709  lnImprimirDocumento = 2;
710  break;
711  }
712 
713  //Propiedad imprmimir documento
714  lcNombrePropiedad = eCash_NombrePropiedad.imprimirdocumento.ToString().ToLower();
715  _Update_Property(lcNombrePropiedad, lnImprimirDocumento);
716 
717  #region Propiedades de operativa permitida
718 
719  lcNombrePropiedad = eCash_NombrePropiedad.Permitir_CobrosCaja.ToString().ToLower();
720  _Update_Property(lcNombrePropiedad, _lPermitir_CobrosCaja);
721 
722  lcNombrePropiedad = eCash_NombrePropiedad.Permitir_CobrosFacturas.ToString().ToLower();
723  _Update_Property(lcNombrePropiedad, _lPermitir_CobrosFacturas);
724 
725  lcNombrePropiedad = eCash_NombrePropiedad.Permitir_CobrosVarios.ToString().ToLower();
726  _Update_Property(lcNombrePropiedad, _lPermitir_CobrosVarios);
727 
728  lcNombrePropiedad = eCash_NombrePropiedad.Permitir_PagosVarios.ToString().ToLower();
729  _Update_Property(lcNombrePropiedad, _lPermitir_PagosVarios);
730 
731  lcNombrePropiedad = eCash_NombrePropiedad.Permitir_Reposiciones.ToString().ToLower();
732  _Update_Property(lcNombrePropiedad, _lPermitir_Reposiciones);
733 
734  lcNombrePropiedad = eCash_NombrePropiedad.Permitir_Retiros.ToString().ToLower();
735  _Update_Property(lcNombrePropiedad, _lPermitir_Retiros);
736 
737  #endregion Propiedades de operativa permitida
738 
739  #region Propiedades de visibilidad de operativa
740 
741  lcNombrePropiedad = eCash_NombrePropiedad.Visible_CobrosCaja.ToString().ToLower();
742  _Update_Property(lcNombrePropiedad, _lVisible_CobrosCaja);
743 
744  lcNombrePropiedad = eCash_NombrePropiedad.Visible_CobrosFacturas.ToString().ToLower();
745  _Update_Property(lcNombrePropiedad, _lVisible_CobrosFacturas);
746 
747  lcNombrePropiedad = eCash_NombrePropiedad.Visible_CobrosVarios.ToString().ToLower();
748  _Update_Property(lcNombrePropiedad, _lVisible_CobrosVarios);
749 
750  lcNombrePropiedad = eCash_NombrePropiedad.Visible_PagosVarios.ToString().ToLower();
751  _Update_Property(lcNombrePropiedad, _lVisible_PagosVarios);
752 
753  lcNombrePropiedad = eCash_NombrePropiedad.Visible_Reposiciones.ToString().ToLower();
754  _Update_Property(lcNombrePropiedad, _lVisible_Reposiciones);
755 
756  lcNombrePropiedad = eCash_NombrePropiedad.Visible_Retiros.ToString().ToLower();
757  _Update_Property(lcNombrePropiedad, _lVisible_Retiros);
758 
759  #endregion Propiedades de visibilidad de operativa
760 
761  //Create XML header
762  XDeclaration lsHead = new XDeclaration("1.0", "Windows-1252", "yes");
763  //Create XML content
764  XElement lsContent = new XElement("VFPData", new XElement("curCash", this._oPropiedades.Select(kv => new XElement(kv.Key, kv.Value))));
765  //Create XML string
766  string lsXml = lsHead.ToString() + Environment.NewLine + lsContent.ToString();
767 
768  //Saves XML string to the DataBase table: terminal
769  string sql = "update " + DB.SQLDatabase("COMUNES", "TERMINAL") + " set cashxml = " + DB.SQLString(lsXml) + " WHERE codigo=" + DB.SQLString(this._Terminal);
770 
771  if (!DB.SQLExec(sql))
772  {
773  this._Error_Message = "Se ha producido un error guardando la configuración de su cash en la Base de Datos.";
774  return false;
775  }
776 
777  return true;
778  }
779 
785  private void _Update_Property(string tcNombrePropiedad, object toValue)
786  {
787  if (_oPropiedades.ContainsKey(tcNombrePropiedad))
788  _oPropiedades[tcNombrePropiedad] = toValue;
789  else
790  _oPropiedades.Add(tcNombrePropiedad, toValue);
791  }
792 
798  private eCash_NombrePropiedad _GetEnum_NombrePropiedad(string tcNombre)
799  {
800  string[] lcNames = Enum.GetNames(typeof(eCash_NombrePropiedad));
801 
802  foreach (string lcName in lcNames)
803  {
804  if (lcName.Trim().ToLower() == tcNombre.Trim().ToLower()) return (eCash_NombrePropiedad)Enum.Parse(typeof(eCash_NombrePropiedad), lcName);
805  }
806 
807  return eCash_NombrePropiedad.none;
808  }
809 
818  public virtual bool _Cobrar(docventatpv.ewDocVentaTPV toDocVenta, Decimal tnImporte)
819  {
820  return true;
821  }
822 
826  public virtual void _Show()
827  {
828  Forms.frmCash loForm = new Forms.frmCash(this);
829  loForm._ShowDialog();
830  }
831 
836  public virtual bool _Probar()
837  {
838  return true;
839  }
840 
845  public virtual bool _BackOffice()
846  {
847  return true;
848  }
849 
854  public virtual bool _Desconectar()
855  {
856  return true;
857  }
858 
865  public virtual bool _CobroFactura(CobrosPrevision toCobroFactura, decimal tnImporte)
866  {
867  //Se debe implemntar en la clase deribada
868  return true;
869  }
870 
877  public virtual bool _CobroVarios(CobrosVarios toCobroVarios, decimal tnImporte)
878  {
879  //Se debe implemntar en la clase deribada
880  return true;
881  }
882 
889  public virtual bool _PagoVarios(PagosVarios toPagosVarios, decimal tnImporte)
890  {
891  //Se debe implemntar en la clase deribada
892  return true;
893  }
894 
901  public virtual bool _Reposicion(Reposicion toReposicion, decimal tnImporte)
902  {
903  //Se debe implemntar en la clase deribada
904  return true;
905  }
906 
913  public virtual bool _Retiro(Retiros toRetiro, decimal tnImporte)
914  {
915  //Se debe implemntar en la clase deribada
916  return true;
917  }
918 
925  public virtual bool _Abono(Retiros toRetiro, decimal tnImporte)
926  {
927  //Se debe implemntar en la clase deribada
928  return _Retiro(toRetiro, tnImporte);
929  }
930 
937  public virtual bool _Arqueo(ArqueoTpv toArqueo, decimal tnImporte)
938  {
939  //Se debe implemntar en la clase deribada
940  return true;
941  }
942 
947  public virtual void _Obtener_Notificador()
948  {
949  //Instancia un formulario de notificación y le paso un ICash como parámetro
951  {
952  _oNotifier = new Forms.frmWaitingFor(this);
953  }
954  }
958  private object _oNotifier = null;
959 
965  public static bool _GetICash(out ICash toCash)
966  {
967  Terminal loTerminal = new Terminal();
968  ICash loCash = loTerminal.Cash();
969  if (loCash != null)
970  {
971  toCash = loCash;
972  return true;
973  }
974  toCash = null;
975  return false;
976  }
977 
978  #endregion METODOS
979 
980  #region METODOS PROTECTED
981 
988  protected string _Connect(string tcServerIP, int tnPort, string lcMessage)
989  {
990 
991  string lcResposta = string.Empty;
992 
993  try
994  {
995  // Create a TcpClient.
996  // The client requires a TcpServer that is connected
997  // to the same address specified by the server and port
998  // combination.
999 
1000  TcpClient client = new TcpClient(tcServerIP, tnPort);
1001 
1002  // Translate the passed message into ASCII and store it as a byte array.
1003  Byte[] data = new Byte[256];
1004  data = System.Text.Encoding.ASCII.GetBytes(lcMessage);
1005 
1006  // Get a client stream for reading and writing.
1007  // Stream stream = client.GetStream();
1008  NetworkStream stream = client.GetStream();
1009 
1010  // Send the message to the connected TcpServer.
1011  stream.Write(data, 0, data.Length);
1012 
1013  // Buffer to store the response bytes.
1014  data = new Byte[256];
1015 
1016  // String to store the response ASCII representation.
1017  String responseData = String.Empty;
1018 
1019  // Read the first batch of the TcpServer response bytes.
1020  Int32 bytes = stream.Read(data, 0, data.Length);
1021  responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
1022 
1023  lcResposta = responseData;
1024 
1025  // Close everything.
1026  stream.Close();
1027  client.Close();
1028  }
1029  catch (ArgumentNullException e)
1030  {
1031  _Error_Message = "ArgumentNullException: " + e;
1032  }
1033  catch (SocketException e)
1034  {
1035  _Error_Message = "SocketException: " + e.ToString();
1036  }
1037 
1038  return lcResposta;
1039  }
1040  #endregion METODOS PROTECTED
1041  }
1042 }
virtual bool _Abono(Retiros toRetiro, decimal tnImporte)
Operación de retiro
Definition: Cash.cs:925
Clase que nos gestiona los retiros de caja. Esta clase utilizará como base la tabla TPV...
Definition: Retiros.cs:19
virtual bool _PagoVarios(PagosVarios toPagosVarios, decimal tnImporte)
Operación de pago vario
Definition: Cash.cs:889
delegate void UserNotifyerEvent(object sender, EwCashNotifyEventArgs e)
Delegado para la notificación al usuario
eCash_NombrePropiedad
Enumeración de las propiedades que componen la clase ICash
Definition: ICash.cs:331
string _Connect(string tcServerIP, int tnPort, string lcMessage)
Conectar a traves de socket.
Definition: Cash.cs:988
Clase derivada de Movcaja, per a gestionar els pagos varios
Definition: PagosVarios.cs:20
virtual bool _CobroFactura(CobrosPrevision toCobroFactura, decimal tnImporte)
Operación de cobro de factura
Definition: Cash.cs:865
virtual bool _Save()
Ens guardarà a la taula TERMINAL les següents propietats { _CodigoFormaCobro, _Propiedades } ...
Definition: Cash.cs:672
virtual bool _Reposicion(Reposicion toReposicion, decimal tnImporte)
Operación de reposición
Definition: Cash.cs:901
virtual bool _Cobrar(docventatpv.ewDocVentaTPV toDocVenta, Decimal tnImporte)
Ens executa perquè cobri el CASH Ens retornarà TRUE en cas que ha anat OK Ens retornarà FALSE en cas ...
Definition: Cash.cs:818
La classe Cash compleix la interficie ICash, per treballar amb calaixos intel·ligents ...
Definition: Cash.cs:25
virtual bool _Probar()
Farà una prova de comunicació amb el calaix
Definition: Cash.cs:836
ICash Cash()
Ens retornarà un objecte de tipus ICash a partir del IDNCASH fent una instancia de la llibreria que h...
Definition: Terminal.cs:87
KeyDiccionarioMascara
Clave para diccionario de máscaras
UserNotifyerEvent _NotificarUsuario
Evento de notificación al usuario
Definition: Cash.cs:42
Clase de argumentos de respuesta. Deriba de EventArgs incorporando un booleano para determinar si deb...
Definition: ICash.cs:267
virtual bool _Desconectar()
Desconectar la comunicación con el cajón
Definition: Cash.cs:854
PropertyChangedEventHandler PropertyChanged
Evento público para notificar cambios en las propiedades
Definition: Cash.cs:65
Cash()
Constructor de la clase
Definition: Cash.cs:531
virtual void _Obtener_Notificador()
Método que instancia un elemento para mostrar avisos de interacción con el cajon al usuario Sino se s...
Definition: Cash.cs:947
Clase no visual que nos gestiona las diferentes reposiciones que pueden haber en un TPV ...
Definition: Reposicion.cs:20
virtual bool _CobroVarios(CobrosVarios toCobroVarios, decimal tnImporte)
Operación de cobro vario
Definition: Cash.cs:877
void LanzarEvento_MostrarMensajeUsuario(bool tlMostrar=true, bool tlOk=true)
Método para lanzar eventos de notificación al usuario
Definition: Cash.cs:49
Proporciona características adicionales de las máscaras de Eurowin
Definition: clsEwBase.cs:6212
Definició de la interficie pels calaixos intel·ligents (cash)
Definition: ICash.cs:14
PE-86618 : Clase Terminal
Definition: Terminal.cs:22
virtual bool _BackOffice()
Acceso al BackOffice del cajón electrónico
Definition: Cash.cs:845
virtual bool _Retiro(Retiros toRetiro, decimal tnImporte)
Operación de retiro
Definition: Cash.cs:913
Clase Arqueo TPV: Para crear un arqueo nuevo para consultar lo pendiente de arquear: ...
Definition: ArqueoTpv.cs:45
Clase derivada de Movcaja, per a gestionar els cobros varios
Definition: CobrosVarios.cs:19
static bool _GetICash(out ICash toCash)
Método que determina y retorna un objeto ICash
Definition: Cash.cs:965
virtual bool _Arqueo(ArqueoTpv toArqueo, decimal tnImporte)
Operación de Arqueo
Definition: Cash.cs:937
virtual void _Show()
Ens presenta la pantalla de configuració del Cash
Definition: Cash.cs:826
eCash_OrdenImpresion
Se añadirá una nueva propiedad que indicará si el ticket se imprime antes o después de haber ejecutad...
Definition: ICash.cs:312