基本信息
源码名称:C# 仓库条码对比验证工具源码
源码大小:0.17M
文件格式:.zip
开发语言:C#
更新时间:2018-08-22
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 10 元 
   源码介绍
扫描仓库货物条码与数据库中数据比对,相同报警,不同的写入到数据库

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;

namespace 仓库条码机1
{
    public partial class Form1 : Form
    {
        Color bc = Form1.DefaultBackColor;
        private Point point1;


        public Form1()
        {
            InitializeComponent();
            this.AlmText.Visible = false;
            point1 = this.Location;
        }

        private void barcode_KeyDown(object sender, KeyEventArgs e)
        {
            string sj = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
           
            string strbar = barcode.Text.Replace("\t", "").Replace("\n", "").Replace("\t", "").ToLower().Trim();

            if (e.KeyCode == Keys.Enter && strbar.Length > 0)
            {
                // this.barcode.Clear();
                SqlContrl sql = new SqlContrl();
                // string ss = sql.GetTop(DisCode.Text);
                string ss = sql.GetTop(barcode.Text.Trim().ToLower());
                if (ss == "已存在")
                {
                    this.AlmText.Visible = true;
                    alm();
                    barcode.Clear();
                }
                else
                {
                    sql.insertStation(textBox1.Text, sj, barcode.Text);
                    this.DisCode.Text = barcode.Text.Trim().ToLower();
                    barcode.Clear();
                }
                dv_DateView.DataSource = sql.SelectDt("barcode", textBox1.Text);
                //dv_DateView.RowsDefaultCellStyle.Font = new Font("宋体", 8, FontStyle.Regular);//属性文本编辑
                // dv_DateView.Columns[1].FillWeight = 9;//设置列宽
                // dv_DateView.RowHeadersVisible = false;//是否显示标题列
                //dv_DateView.Columns[1].DisplayIndex = 0;//当前单元格属性取得与更改
                dv_DateView.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 10, FontStyle.Regular);//设置标题字体
                dv_DateView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;//设置自动列宽
                dv_DateView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;//设置自动行高
                dv_DateView.Columns[1].HeaderCell.Value = "条码";
                dv_DateView.Columns[2].HeaderCell.Value = "时间";
                dv_DateView.Columns[3].HeaderCell.Value = "作业员";
            }
        }


        private void alm()
        {
            this.BackColor = Color.Red;
            DialogResult dr = MessageBox.Show("输入条形码重复", "警告", MessageBoxButtons.OK);
            if (dr == DialogResult.OK)
            {
                this.BackColor = bc;
                this.AlmText.Visible = false;

            }


        }

        private void Form1_Load(object sender, EventArgs e)
        {
            barcode.Focus();

        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                barcode.Focus();
                this.textBox1.Enabled = false;
            }

        }

        private void Form1_Move(object sender, EventArgs e)
        {
            this.Location = point1;
        }
    }
}