예제 #1
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            DialogResult        result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    BLL.DeviceDataBLL bll       = new BLL.DeviceDataBLL();
                    DataTable         table     = bll.Query(this.comboBox1.SelectedValue.ToString(), this.comboBox2.SelectedValue.ToString(), this.comboBox3.SelectedValue.ToString(), this.comboBox4.SelectedValue.ToString(), this.dateTimePicker1.Value.ToString("yyyy-MM-dd"), this.dateTimePicker2.Value.ToString("yyyy-MM-dd"), txtDeviceValue.Text, this.comboBox5.SelectedIndex);
                    byte[]            byteArray = Office.ExcelExport.StreamExport(table, null);
                    string            name      = dialog.SelectedPath + "\\导出数据.xls";
                    FileStream        fs        = File.Open(name, FileMode.Create);
                    fs.Write(byteArray, 0, byteArray.Length);
                    fs.Flush();
                    fs.Close();
                    MessageBox.Show("导出完成");
                    System.Diagnostics.Process.Start("Explorer.exe", dialog.SelectedPath);
                }
                catch (Exception ex)
                {
                }
            }
        }
예제 #2
0
        void bindData()
        {
            BLL.DeviceDataBLL bll   = new BLL.DeviceDataBLL();
            DataTable         table = bll.Query(this.comboBox1.SelectedValue.ToString(), this.comboBox2.SelectedValue.ToString(), this.comboBox3.SelectedValue.ToString(), this.comboBox4.SelectedValue.ToString(), this.dateTimePicker1.Value.ToString("yyyy-MM-dd"), this.dateTimePicker2.Value.ToString("yyyy-MM-dd"), txtDeviceValue.Text, this.comboBox5.SelectedIndex);

            this.dataGridView1.DataSource = table;
        }
예제 #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();
            });
        }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Task.Factory.StartNew(() =>
            //{
            if (yanzhengGroupText())
            {
                Models.ProjectDetails details = detailsBLL.GetModel(this.comboBox4.SelectedValue.ToString());
                //details.DeviceDataList = new List<Models.DeviceData>();
                BLL.DeviceDataBLL DeviceDataBLL = new BLL.DeviceDataBLL();
                List <string>     list          = new List <string>()
                {
                    "A", "B", "C", "D", "E", "F", "G", "H", "I"
                };
                int    n                  = (this.GroupInfo.SelectedIndex + 1) * 3;
                bool   ifSuccess          = true;
                string CreateDataStr      = DateTime.Now.ToString("yyyyMMddHHmmss");
                string CreateDataStrGroup = "";

                int m = this.GroupTextlist.Where(p => !string.IsNullOrWhiteSpace(p.Text)).Count();
                int a = m / 3;
                int b = m % 3;
                //if (a == 0)
                //{
                //    DialogResult dr = MessageBox.Show("至少需要填写一组数据,是否继续","提示",MessageBoxButtons.OKCancel );
                //    if (dr != DialogResult.OK)
                //    {
                //        MoveToNextText();
                //        return;
                //    }
                //}
                if (b != 0)
                {
                    string messagestr = "";

                    if (this.GroupInfo.SelectedIndex == 0)
                    {
                        if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0)
                        {
                            messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                    }
                    else if (this.GroupInfo.SelectedIndex == 1)
                    {
                        if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0)
                        {
                            messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                        if (textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0)
                        {
                            messagestr += "第二组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                    }
                    else if (this.GroupInfo.SelectedIndex == 2)
                    {
                        if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0)
                        {
                            messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                        if (textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0)
                        {
                            messagestr += "第二组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                        if (textBox7.Text.Length == 0 || textBox8.Text.Length == 0 || textBox9.Text.Length == 0)
                        {
                            messagestr += "第三组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                    }



                    DialogResult dr = MyDialogOption.show("提示", messagestr, "是,继续完成绑定", "否,返回补充完整");
                    // DialogResult dr = MessageBoxEx.Show("数据不完整,是否继续提交绑定", "提示", MessageBoxButtons.OKCancel, new string[] { "是,继续完成绑定", "否,返回补充完整" });
                    // DialogResult dr = MessageBox.Show("数据不完整,是否继续提交绑定?", "确认", MessageBoxButtons.OKCancel);
                    if (dr != DialogResult.OK)
                    {
                        MoveToNextText();
                        return;
                    }
                }

                for (int i = 0; i < n; i++)
                {
                    if (list[i] == "A" || list[i] == "B" || list[i] == "C")
                    {
                        CreateDataStrGroup = CreateDataStr + "A";
                    }
                    else if (list[i] == "D" || list[i] == "E" || list[i] == "F")
                    {
                        CreateDataStrGroup = CreateDataStr + "B";
                    }
                    else
                    {
                        CreateDataStrGroup = CreateDataStr + "C";
                    }
                    Models.DeviceData deviceData = new Models.DeviceData()
                    {
                        DataId          = this.comboBox4.SelectedValue.ToString() + "_" + list[i] + "_" + Utils.getGUID(),
                        DeviceValue     = this.GroupTextlist[i].Text,
                        GroupName       = list[i],
                        ProjectDetailId = this.comboBox4.SelectedValue.ToString(),
                        Instar          = this.Instar.SelectedItem.ToString(),
                        YangSheng       = this.yangsheng.SelectedItem.ToString(),
                        SamplingDate    = this.SamplingDate.Value.ToString("yyyy-MM-dd"),
                        CreateDate      = CreateDataStrGroup,
                        IfUpload        = 0,
                        NotUploadReason = "网络"
                    };

                    if (!Regex.IsMatch(deviceData.DeviceValue, "^\\d{15}$"))
                    {
                        continue;
                    }
                    //判断重复
                    if (DeviceDataBLL.GetModelByWhere(" DeviceValue='" + deviceData.DeviceValue + "'") != null)
                    {
                        MessageBox.Show("绑定数据库中已经存在[" + deviceData.DeviceValue + "]RFID编号请核实!");
                        return;
                    }



                    BLL.FunctionResult result = DeviceDataBLL.Create(deviceData);
                    if (!result.ExcuteState)
                    {
                        ifSuccess = false;
                        break;
                    }
                    this.DeviceDataTotal++;
                    setProcess();

                    this.DetailsForUpload.Enqueue(deviceData);
                }
                if (ifSuccess)
                {
                    details.DetailState = 1;

                    this.Invoke(new EventHandler((aa, bb) =>
                    {
                        MessageBox.Show("绑定数据完成!");
                        resetTextBox();
                        MoveToNextText();
                    }));
                }
            }
            //});
        }