C# 简易POS零售系统架构设计源码(2)
作者:C/S框架网  发布日期:2011/05/09 12:06:47
C# 简易POS零售系统架构设计源码(2)


PosDevices.cs

C# Code:

using System;
using System.Collections.Generic;
using System.Text;
using Tech2007.Common;
using System.Windows.Forms;


namespace CSFramework.Tech2011.PosTerminal
{
   #region ICashier Interface and Class
   
   /// <summary>
   /// 钱箱接口
   /// </summary>
   public interface ICashier
   {
      //ITraceLog事件跟踪
      void Init(Label currentReceive, Label totalReceive, ITraceLog log);//初始化钱箱
      
      void Reset();
      void OpenDoor();
      void CloseDoor();
      void AcceptMoney(decimal amount); //客户结账收钱
   }
   
   /// <summary>
   /// 普通收银钱箱
   /// </summary>
   public class StandardCashier : ICashier
   {
      private ITraceLog _Log;
      private Label _currentReceive;
      private Label _totalReceive;
      
      private decimal _Total = 0;
      
      public void Init(Label currentReceive, Label totalReceive, ITraceLog log)
      {
         _currentReceive = currentReceive;
         _totalReceive = totalReceive;
         _Log = log;
      }
      
      public void OpenDoor()
      {
         _currentReceive.Text = "Open Door";
         _Log.ShowMessage("The cashier door opened!");
      }
      
      public void CloseDoor()
      {
         _currentReceive.Text = "Close Door";
         _Log.ShowMessage("The cashier door closed!");
      }
      
      public void AcceptMoney(decimal amount)
      {
         _Total = _Total amount;
         _currentReceive.Text = "Receive:" amount.ToString();
         _totalReceive.Text = "Total:" _Total.ToString();
         
         _Log.ShowMessage("Total received money:" amount.ToString());
      }
      
      public void Reset()
      {
         _currentReceive.Text = "Receive:0.00";
         _totalReceive.Text = "Total:0.00";
         this.CloseDoor();
         _Log.ShowMessage("钱箱初始化成功!");
      }
   }
   
   #endregion
   
   #region IMonitor interface and Classes
   
   /// <summary>
   /// 显示器接口
   /// </summary>
   public interface IMonitor
   {
      void Reset();
      void Init(Label lbCurStock, Label lbReceivable, ITraceLog log);
      void ShowMessage(string line1, string line2); //一般的小显示器只支持显示2行消息.
   }
   
   /// <summary>
   /// BENQ50显示器
   /// </summary>
   public class Monitor_BENQ500 : IMonitor
   {
      private ITraceLog _Log;
      private Label _label;
      private Label _lbReceivable;
      
      public void Init(Label lbCurStock, Label lbReceivable, ITraceLog log)
      {
         _label = lbCurStock;
         _lbReceivable = lbReceivable;
         _Log = log;
      }
      
      public void ShowMessage(string line1, string line2)
      {
         if (line1 != "") _label.Text = line1;
         if (line2 != "") _lbReceivable.Text = line2;
         _Log.ShowMessage("BENQ500:" line1);
      }
      
      public void Reset()
      {
         _label.Text = "Welcome!";
         _lbReceivable.Text = "应收:0.00";
         _Log.ShowMessage("BENQ500初始化成功!");
      }
   }
   
   /// <summary>
   /// 三星Samsung200显示器
   /// </summary>
   public class Monitor_Samsung200 : IMonitor
   {
      private ITraceLog _Log;
      private Label _label;
      private Label _lbReceivable;
      
      public void Init(Label lbCurStock, Label lbReceivable, ITraceLog log)
      {
         _label = lbCurStock;
         _lbReceivable = lbReceivable;
         _Log = log;
      }
      
      public void ShowMessage(string line1, string line2)
      {
         _label.Text = line1;
         _lbReceivable.Text = line2;
         _Log.ShowMessage("Samsung200:" line1);
      }
      public void Reset()
      {
         _label.Text = "Welcome!";
         _lbReceivable.Text = "应收:0.00";
         _Log.ShowMessage("Samsung200初始化成功!");
      }
   }
   #endregion
   
   #region IPrinter interface and classes
   
   /// <summary>
   /// 打印机接口
   /// </summary>
   public interface IPrinter
   {
      void Reset();
      void Init(ListBox listbox, ITraceLog log);
      void Print(string msg);
   }
   
   /// <summary>
   /// 打印机:HP5000型号
   /// </summary>
   public class Printer_HP5000 : IPrinter
   {
      private ITraceLog _Log;
      
      private ListBox _listbox;
      
      public void Init(ListBox listbox, ITraceLog log)
      {
         _listbox = listbox;
         _Log = log;
      }
      
      public void Print(string msg)
      {
         _listbox.Items.Add(msg);
         _Log.ShowMessage("HP5000:" msg);
      }
      public void Reset()
      {
         _listbox.Items.Clear();
         _listbox.Items.Add("Printer OK!");
         _Log.ShowMessage("HP5000初始化成功!");
      }
   }
   
   /// <summary>
   /// 打印机:Epson600型号
   /// </summary>
   public class Printer_Epson600 : IPrinter
   {
      private ITraceLog _Log;
      private ListBox _listbox;
      
      public void Init(ListBox listbox, ITraceLog log)
      {
         _listbox = listbox;
         _Log = log;
      }
      
      public void Print(string msg)
      {
         _listbox.Items.Add(msg);
         _Log.ShowMessage("Epson600:" msg);
      }
      public void Reset()
      {
         _listbox.Items.Clear();
         _listbox.Items.Add("Printer OK!");
      }
   }
   
   #endregion
   
}


//来源:C/S框架网(www.csframework.com) QQ:1980854898


 

上一篇 下一篇