C# 简易POS零售系统架构设计源码(1)
C# 简易POS零售系统架构设计源码(1)
C# 简易POS零售系统架构设计源码(1)
C# 简易POS零售系统架构设计源码(1)
程序运行效果:
C# Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CSFramework.Tech2011.PosTerminal
{
public partial class frmPosMain : Form
{
private PosTerminal _terminal = null; //收银管理器实例
public frmPosMain()
{
InitializeComponent();
}
private void frmPosMain_Load(object sender, EventArgs e)
{
//IPrinter printer = new Printer_Epson600();
//IMonitor monitor = new Monitor_Samsung200();
ICashier cashier = new StandardCashier();
IPrinter printer = new Printer_HP5000();
IMonitor monitor = new Monitor_BENQ500();
IStockDataView view = new ListBoxStockDataView(lbStocks);
ITraceLog log = new TraceLogListBox(lbTrace);
printer.Init(lbPrinter, log);
cashier.Init(label9, label10, log);
monitor.Init(lbCurStock, lblRec, log);
//创建收银管理器实例
_terminal = new PosTerminal(cashier, monitor, printer, view);
//检查系统
_terminal.CheckSystem();
//加载完毕...可以收银
}
private void txtStock_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Enter) &&&& (txtStock.Text != null))
{
string code = txtStock.Text.Trim();
Stock stock = StockData.GetStock(code); //跟据输入的货品编号创建Stock对象
if (stock != null)//数据库存在货品编号
_terminal.AddStock(stock, int.Parse(txtQty.Text));
else
lbTrace.Items.Add("Stock " txtStock.Text " doesn't exists!");
txtStock.Clear();
txtStock.Focus();
}
}
private void txtPay_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Enter) & (txtPay.Text != null))
{
decimal amt = 0;
bool ok = decimal.TryParse(txtPay.Text, out amt);
if (ok & amt > 0)
{
bool pay = _terminal.Pay(amt); // Pay by the customer
if (pay) //收款成功将焦点移入货品输入框
{
txtPay.Clear();
txtStock.Clear();
txtStock.Focus();
}
}
else
{
lbTrace.Items.Add("不是数字!");
}
}
}
private void btnReset_Click(object sender, EventArgs e)
{
decimal rcv = _terminal.PosStockDataView.GetReceivableAmount();
if (rcv > 0)
{
DialogResult ret = MessageBox.Show("正在收银,要取消么?", "正在收银", MessageBoxButtons.YesNo);
if (ret == DialogResult.No) return;
}
lbTrace.Items.Clear();
_terminal.Reset();
}
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CSFramework.Tech2011.PosTerminal
{
public partial class frmPosMain : Form
{
private PosTerminal _terminal = null; //收银管理器实例
public frmPosMain()
{
InitializeComponent();
}
private void frmPosMain_Load(object sender, EventArgs e)
{
//IPrinter printer = new Printer_Epson600();
//IMonitor monitor = new Monitor_Samsung200();
ICashier cashier = new StandardCashier();
IPrinter printer = new Printer_HP5000();
IMonitor monitor = new Monitor_BENQ500();
IStockDataView view = new ListBoxStockDataView(lbStocks);
ITraceLog log = new TraceLogListBox(lbTrace);
printer.Init(lbPrinter, log);
cashier.Init(label9, label10, log);
monitor.Init(lbCurStock, lblRec, log);
//创建收银管理器实例
_terminal = new PosTerminal(cashier, monitor, printer, view);
//检查系统
_terminal.CheckSystem();
//加载完毕...可以收银
}
private void txtStock_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Enter) &&&& (txtStock.Text != null))
{
string code = txtStock.Text.Trim();
Stock stock = StockData.GetStock(code); //跟据输入的货品编号创建Stock对象
if (stock != null)//数据库存在货品编号
_terminal.AddStock(stock, int.Parse(txtQty.Text));
else
lbTrace.Items.Add("Stock " txtStock.Text " doesn't exists!");
txtStock.Clear();
txtStock.Focus();
}
}
private void txtPay_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Enter) & (txtPay.Text != null))
{
decimal amt = 0;
bool ok = decimal.TryParse(txtPay.Text, out amt);
if (ok & amt > 0)
{
bool pay = _terminal.Pay(amt); // Pay by the customer
if (pay) //收款成功将焦点移入货品输入框
{
txtPay.Clear();
txtStock.Clear();
txtStock.Focus();
}
}
else
{
lbTrace.Items.Add("不是数字!");
}
}
}
private void btnReset_Click(object sender, EventArgs e)
{
decimal rcv = _terminal.PosStockDataView.GetReceivableAmount();
if (rcv > 0)
{
DialogResult ret = MessageBox.Show("正在收银,要取消么?", "正在收银", MessageBoxButtons.YesNo);
if (ret == DialogResult.No) return;
}
lbTrace.Items.Clear();
_terminal.Reset();
}
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网