超市POS收银系统
前台收银用户名:haiyang 密码:1
后台管理用户名:admin 密码:1
后台管理功能主要用:商品分类管理、商品添加、商品修改、商品管理、日汇总、月汇总、年汇总、用户管理等,配合条码机、扫描枪、小票打印机等硬件使用,适合超市收银使用。。
要求必须安装 office,因为 数据库用的 access using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace FOUPOS{ public partial class Cash : Form { POS.Model.FUser m_User = new POS.Model.FUser(); public Cash(POS.Model.FUser fuser) { InitializeComponent(); this.m_User = fuser; } private int sumCount = 0; POS.BLL.FGoods b_Goods = new POS.BLL.FGoods(); POS.Model.FGoods m_Goods = new POS.Model.FGoods(); private void Cash_Load(object sender, EventArgs e) { skinEngine1.SkinFile = "OneBlue.ssk"; SetlvGoods(); } #region 在界面Load的时候先设置好标题名和长度. protected void SetlvGoods() { lvGoods.Columns.Add("数量", 60); lvGoods.Columns.Add("条码", 170); lvGoods.Columns.Add("商品名", 210); lvGoods.Columns.Add("单价", 80); lvGoods.Columns.Add("金额", 80); lvGoods.Columns.Add("收银员", 80); } #endregion private void btnAdd_Click(object sender, EventArgs e) { int scount = 1; if (!string.IsNullOrEmpty(txtNum.Text)) { if (b_Goods.Exists(txtNum.Text.Trim())) { m_Goods = b_Goods.GetModelByNum(txtNum.Text.Trim()); if (lvGoods.Items.Count > 0) { bool exist = false; foreach (ListViewItem checklvi in lvGoods.Items) { if (checklvi.SubItems[1].Text == txtNum.Text.Trim()) { exist = true; checklvi.SubItems[0].Text = (int.Parse(checklvi.SubItems[0].Text) 1).ToString(); checklvi.SubItems[4].Text = string.Format("{0:F2}", (int.Parse(checklvi.SubItems[0].Text) * m_Goods.SSalePrice)); sumCount = 1; lblSumMoney.Text = GetSumMoney().ToString(); txtSumMoney.Text = lblSumMoney.Text; txtShouldGetMoney.Text = lblSumMoney.Text; lblSumCount.Text = sumCount.ToString();//记录商品总数 txtNum.Text = ""; return;//跳出button事件之前更新商品总数和txtNum的text属性 } } if (exist == false) { ListViewItem lvi = lvGoods.Items.Add(scount.ToString()); lvi.SubItems.Add(m_Goods.SNum); lvi.SubItems.Add(m_Goods.SName); lvi.SubItems.Add(string.Format("{0:F2}", m_Goods.SSalePrice)); lvi.SubItems.Add(string.Format("{0:F2}", m_Goods.SSalePrice)); lvi.SubItems.Add(m_User.UName); sumCount = 1; } } else { ListViewItem lvi = lvGoods.Items.Add(scount.ToString()); lvi.SubItems.Add(m_Goods.SNum); lvi.SubItems.Add(m_Goods.SName); lvi.SubItems.Add(string.Format("{0:F2}", m_Goods.SSalePrice)); lvi.SubItems.Add(string.Format("{0:F2}", m_Goods.SSalePrice)); lvi.SubItems.Add(m_User.UName); sumCount = 1; } } } lblSumMoney.Text = GetSumMoney().ToString(); txtSumMoney.Text = lblSumMoney.Text; txtShouldGetMoney.Text = lblSumMoney.Text; lblSumCount.Text = sumCount.ToString();//记录商品总数 txtNum.Text = ""; } private void Cash_Activated(object sender, EventArgs e) { txtNum.Focus(); } #region 获取金额 protected decimal GetSumMoney() { decimal summoney = 0; foreach (ListViewItem checklvi in lvGoods.Items) { summoney = decimal.Parse(checklvi.SubItems[4].Text); } return summoney; } #endregion private void lvGoods_AfterLabelEdit(object sender, LabelEditEventArgs e) { try { ListView lv = (ListView)sender; int a = int.Parse(e.Label); lv.SelectedItems[0].SubItems[4].Text = (a * decimal.Parse(lv.SelectedItems[0].SubItems[3].Text)).ToString(); lblSumMoney.Text = GetSumMoney().ToString(); txtSumMoney.Text = lblSumMoney.Text; txtShouldGetMoney.Text = lblSumMoney.Text; } catch (Exception ex) { e.CancelEdit = true; MessageBox.Show(ex.Message); } } private void txtGetMoney_Leave(object sender, EventArgs e) { try { decimal shouldmoney = decimal.Parse(txtShouldGetMoney.Text); decimal getmoney = decimal.Parse(txtGetMoney.Text); if (getmoney > shouldmoney) { txtReturnMoney.Text = string.Format("{0:F2}", getmoney - shouldmoney); } else { MessageBox.Show("交来金额小于实收金额。"); } } catch { MessageBox.Show("数据有误,请仔细检查输入金额。"); } } #region 取出精确到毫秒的时间做流水号 protected string GetAccountNum() { int year = System.DateTime.Now.Year; int month = System.DateTime.Now.Month; int day = System.DateTime.Now.Day; int hour = System.DateTime.Now.Hour; int minute = System.DateTime.Now.Minute; int second = System.DateTime.Now.Second; int millisecond = System.DateTime.Now.Millisecond; string num = year.ToString() month.ToString() day.ToString() hour.ToString() minute.ToString() second.ToString() millisecond.ToString(); return num; } #endregion private void button1_Click(object sender, EventArgs e) { POS.BLL.FAccount b_Account = new POS.BLL.FAccount(); POS.Model.FAccount m_Account = new POS.Model.FAccount(); m_Account.AccountNum = GetAccountNum(); m_Account.GetMoney = decimal.Parse(txtShouldGetMoney.Text); m_Account.JoinTime = DateTime.Now; m_Account.NoGetMoney = 0; m_Account.SumMoney = decimal.Parse(txtSumMoney.Text); m_Account.UID = m_User.UID; b_Account.Add(m_Account); int id = b_Account.GetMaxID(); POS.Model.FDetail m_Detail = new POS.Model.FDetail(); POS.BLL.FDetail b_Detail = new POS.BLL.FDetail(); m_Detail.AID = id; foreach (ListViewItem checklvi in lvGoods.Items) { m_Detail.GNum = checklvi.SubItems[1].Text; m_Detail.DCount = int.Parse(checklvi.SubItems[0].Text); b_Detail.Add(m_Detail); } GetClear(); MessageBox.Show("收银成功。"); } protected void GetClear() { lvGoods.Items.Clear(); lblSumMoney.Text = null; lblSumCount.Text = null; txtGetMoney.Text = null; txtReturnMoney.Text = null; txtShouldGetMoney.Text = null; txtSumMoney.Text = null; } }}
评论