Пример #1
0
        /// <summary>
        /// 扫描事件处理,响应barcodeInput的回车事件
        /// 如果barcode为空执行现金支付命令
        /// 如果不为空根据barcode模糊查询商品信息,
        /// 返回结果为空设置当前商品界面信息为未找到商品
        /// 返回结果为一条记录直接添加到当前售卖单据明细
        /// 返回结果为多条弹出商品选择界面
        /// </summary>
        public void scanCode()
        {
            // MQHelper.getInstance().sendMessage("");
            string barcode = view.barcodeInput.Text;

            if (barcode == "")
            {
                CommandManager.Exec(CommandManager.PAY_COMMAND_CASH, view);
                return;
            }
            DataTable dt = productService.getByBarCode(barcode);
            DataRow   dr = null;

            if (dt.Rows.Count <= 0)
            {
                setCurrentProduct(dr);
                return;
            }
            else if (dt.Rows.Count == 1)
            {
                //一条记录
                dr = dt.Rows[0];
                Dictionary <String, Object> row = new Dictionary <string, object>();
                row["orderlistid"] = Guid.NewGuid().ToString("N");
                row["orderid"]     = SystemInfo.CurrentOrderId;
                row["ordercode"]   = SystemInfo.CurrentOrderCode;
                row["productid"]   = dr["id"];
                row["barcode"]     = dr["barcode"];
                row["name"]        = dr["name"];
                row["spec"]        = dr["spec"];
                row["unit"]        = dr["unit"];
                row["tintype"]     = dr["tintype"];
                row["midtype"]     = dr["midtype"];
                row["bigtype"]     = dr["bigtype"];
                row["classtype"]   = dr["classtype"];
                row["barcode"]     = dr["barcode"];
                row["depttype"]    = dr["depttype"];
                row["price"]       = dr["price"];
                row["count"]       = 1;
                row["discount"]    = 90;
                view.dataGridView1.AutoGenerateColumns = false;
                view.dataGridView1.DataSource          = orderService.createList(row);
            }
            else
            {
                //多条记录
                ProductChosseForm pcf = new ProductChosseForm();
                pcf.dataGridView1.AutoGenerateColumns = false;
                pcf.dataGridView1.DataSource          = dt;
                DialogResult dr1 = pcf.ShowDialog();
                if (dr1 == DialogResult.OK)
                {
                    DataRowView drv = (DataRowView)pcf.CurrentRow.DataBoundItem;
                    Dictionary <String, Object> row = new Dictionary <string, object>();
                    row["orderlistid"] = Guid.NewGuid().ToString("N");
                    row["orderid"]     = SystemInfo.CurrentOrderId;
                    row["ordercode"]   = SystemInfo.CurrentOrderCode;
                    row["productid"]   = drv["id"];
                    row["barcode"]     = drv["barcode"];
                    row["name"]        = drv["name"];
                    row["spec"]        = drv["spec"];
                    row["unit"]        = drv["unit"];
                    row["tintype"]     = drv["tintype"];
                    row["midtype"]     = drv["midtype"];
                    row["bigtype"]     = drv["bigtype"];
                    row["classtype"]   = drv["classtype"];
                    row["barcode"]     = drv["barcode"];
                    row["depttype"]    = drv["depttype"];
                    row["price"]       = drv["price"];
                    row["count"]       = 1;
                    row["discount"]    = 90;
                    view.dataGridView1.AutoGenerateColumns = false;
                    view.dataGridView1.DataSource          = orderService.createList(row);
                }
            }
            setCurrentProduct(dr);
            setCurrentOrder();
            selectLastRow();
        }