Example #1
0
        private void bind()
        {
            BLL.UserBLL bll = new BLL.UserBLL();
            this.dataGridView2.DataSource = bll.GetData();
            BLL.DeviceDataAreaBLL bll1  = new BLL.DeviceDataAreaBLL();
            DataTable             table = bll1.GetData();

            Models.DeviceDataArea area = null;
            if (table.Rows.Count > 0)
            {
                area = bll1.GetModelByRow(table.Rows[0]);
                this.textBox6.Text = area.MaxValue.ToString();
                this.textBox5.Text = area.MinValue.ToString();
            }
        }
Example #2
0
        private void button7_Click(object sender, EventArgs e)
        {
            BLL.DeviceDataAreaBLL bll   = new BLL.DeviceDataAreaBLL();
            DataTable             table = bll.GetData();

            Models.DeviceDataArea area = null;
            string str = this.textBox5.Text;

            if (!Regex.IsMatch(str, "^\\d{15}$"))
            {
                MessageBox.Show("最小值应为十五位数字");
                return;
            }
            str = this.textBox6.Text;
            if (!Regex.IsMatch(str, "^\\d{15}$"))
            {
                MessageBox.Show("最大值应为十五位数字");
                return;
            }
            double min = double.Parse(this.textBox5.Text);
            double max = double.Parse(this.textBox6.Text);

            if (min >= max)
            {
                MessageBox.Show("最小值应小于最大值");
                return;
            }
            if (table.Rows.Count > 0)
            {
                area          = bll.GetModelByRow(table.Rows[0]);
                area.MaxValue = double.Parse(this.textBox6.Text);
                area.MinValue = double.Parse(this.textBox5.Text);
                bll.Edit(area);
            }
            else
            {
                area = new Models.DeviceDataArea()
                {
                    AreaId   = Utils.getGUID(),
                    MaxValue = double.Parse(this.textBox6.Text),
                    MinValue = double.Parse(this.textBox5.Text)
                };
                bll.Create(area);
            }
        }
Example #3
0
        public Form1()
        {
            InitializeComponent();
            this.GroupTextlist = new List <TextBox>()
            {
                this.textBox1,
                this.textBox2,
                this.textBox3,

                this.textBox4,
                this.textBox5,
                this.textBox6,

                this.textBox7,
                this.textBox8,
                this.textBox9,
            };
            this.GroupTextLabellist = new List <Label>()
            {
                this.label18,
                this.label19,
                this.label20,
                this.label21,
                this.label22,
                this.label23,
                this.label24,
                this.label25,
                this.label26
            };

            this.GroupTextPictureBoxlist = new List <PictureBox>()
            {
                this.pictureBox2,
                this.pictureBox3,
                this.pictureBox4,
                this.pictureBox5,
                this.pictureBox6,
                this.pictureBox7,
                this.pictureBox8,
                this.pictureBox9,
                this.pictureBox10
            };

            this.GroupTextPictureBoxlist.ForEach(p =>
            {
                toolTip1.SetToolTip(p, "点击以清除左侧文本框信息");
                p.Click += (a, b) =>
                {
                    GroupTextlist.ForEach(tt => tt.Enabled = false);
                    int n     = this.GroupTextPictureBoxlist.IndexOf(p);
                    TextBox t = this.GroupTextlist[n];
                    t.Text    = "";
                    t.Enabled = true;
                    t.Focus();
                };
            });
            GroupTextlist.ForEach(p =>
            {
                p.KeyDown += (a, b) =>
                {
                    if (b.KeyCode == Keys.Enter)
                    {
                        if (p.TextLength == 15)
                        {
                            BLL.DeviceDataBLL DeviceDataBLL = new BLL.DeviceDataBLL();
                            string message = "";
                            bool ifExist   = false;
                            if (DeviceDataBLL.GetModelByWhere(" DeviceValue='" + p.Text + "'") != null)
                            {
                                ifExist = true;
                                message = "绑定数据库中已经存在[" + p.Text + "]电子标签请核实!";
                            }
                            int n = this.GroupTextlist.Where(t => t.Text == p.Text).Count();
                            if (n > 1)
                            {
                                ifExist = true;
                                message = "编号为[" + p.Text + "]的电子标签已经绑定在其他试块上,请核实确认!";
                            }
                            if (!Regex.IsMatch(p.Text, "^\\d{15}$"))
                            {
                                ifExist = true;
                                message = "请填写15位电子标签!";
                            }
                            else
                            {
                                BLL.DeviceDataAreaBLL bll = new BLL.DeviceDataAreaBLL();
                                if (!bll.IfInArea(double.Parse(p.Text)))
                                {
                                    ifExist = true;
                                    message = "填写电子标签编号的值超出范围,请检查!";
                                }
                            }
                            if (ifExist)
                            {
                                MessageBox.Show(message);    //扫描后马上有回车?看不到弹出
                                p.Text    = "";
                                p.Enabled = true;
                                p.Focus();
                                return;
                            }

                            p.Enabled = false;
                            MoveToNextText();
                        }
                        else
                        {
                            MessageBox.Show("填写电子标签编号不正确!");    //扫描后马上有回车?看不到弹出
                            p.Text    = "";
                            p.Enabled = true;
                            p.Focus();
                            return;
                        }
                    }
                };


                p.TextChanged += (a, b) =>
                {
                    if (p.TextLength == 1)
                    {
                        dt = DateTime.Now;
                    }
                    else
                    {
                        //DateTime tempDt = DateTime.Now;        //保存按键按下时刻的时间点
                        //TimeSpan ts = tempDt.Subtract(dt);     //获取时间间隔
                        //if (ts.Milliseconds > 100)              //判断时间间隔,如果时间间隔大于50毫秒,则将TextBox清空
                        //    p.Text = "";
                        //dt = tempDt;
                    }
                };

                resetTextBox();
            });
        }