/// <summary> 每个一秒检查一次摄像头条码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { Bitmap SnapShot = videoSourcePlayer1.GetCurrentVideoFrame(); //截取当前摄像头图像 if (SnapShot != null) //摄像头正式有效时 { String Code_str = ScanBarcode.CheckBarCode(SnapShot); //存放条码值字符串 if (Code_str != null) { ScanBarcode.Stop(videoSourcePlayer1); //停止摄像头 timer1.Enabled = false; //停止计时器检查 Boolean New = true; //标记是否是新一类商品 String[] GoodsInfo; //商品信息集 if (DBMgr.IsGoodsExists(Code_str)) //若已存在此类商品 { GoodsInfo = DBMgr.GetGoodsInfo(Code_str); //调用数据库管理器的商品信息查询 New = false; //标记New为假 } else//DB中不存在此类商品 { GoodsInfo = ScanBarcode.GetGoodsInfo(Code_str); //调用摄像头类,网络获取商品信息 } GoodsAdd GoodsAdd_frm = new GoodsAdd(GoodsInfo, false, New); //实例化新增商品类 if (GoodsAdd_frm.ShowDialog() == DialogResult.OK) //模态显示新增商品窗体 { //成功新增 Flush(); //刷新列表 Modified = true; //标记增删改 } ScanBarcode.Start(this.videoSourcePlayer1); //打开摄像头 timer1.Enabled = true; //继续检测 } } }
/// <summary> 添加员工 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 添加ToolStripMenuItem1_Click(object sender, EventArgs e) { GoodsAdd GoodsAdd_frm = new GoodsAdd(); //实例化新增商品类 if (GoodsAdd_frm.ShowDialog() == DialogResult.OK) //模态显示新增商品窗体 { //成功新增 Flush(); //刷新列表 Modified = true; //标记增删改 } }