Exemplo n.º 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();
            }
        }
Exemplo n.º 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);
            }
        }