Esempio n. 1
0
        /// <summary>
        /// Get paramter entity
        /// </summary>
        public List <ParamEntity> GetParams()
        {
            var _params = new List <ParamEntity>();

            using (var conn = new SQLiteConnection(registryConnectionString)) {
                conn.SetPassword(dbPassword);
                conn.Open();
                using (var command = new SQLiteCommand(SqliteCommands.Registry_Get_Param, conn)) {
                    using (var rdr = command.ExecuteReader(CommandBehavior.CloseConnection)) {
                        while (rdr.Read())
                        {
                            var _param = new ParamEntity();
                            _param.Id    = SqlTypeConverter.DBNullParamIdHandler(rdr["id"]);
                            _param.Value = SqlTypeConverter.DBNullStringHandler(rdr["value"]);
                            _param.Time  = SqlTypeConverter.DBNullDateTimeHandler(rdr["time"]);
                            _params.Add(_param);
                        }
                    }
                }
            }
            return(_params);
        }
Esempio n. 2
0
        private void paramSaveButton_Click(object sender, EventArgs e)
        {
            try {
                var tag = _currentNode.Tag as TagModel;
                if (tag.Type != NodeType.Param)
                {
                    throw new Exception("节点类型错误。");
                }

                if (string.IsNullOrWhiteSpace(scOff.Text))
                {
                    scOff.Focus();
                    MessageBox.Show("信号编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (string.IsNullOrWhiteSpace(fsuOff.Text))
                {
                    fsuOff.Focus();
                    MessageBox.Show("信号编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (string.IsNullOrWhiteSpace(fzdl.Text))
                {
                    fzdl.Focus();
                    MessageBox.Show("信号编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (string.IsNullOrWhiteSpace(gzzt.Text))
                {
                    gzzt.Focus();
                    MessageBox.Show("信号编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (string.IsNullOrWhiteSpace(dczdy.Text))
                {
                    dczdy.Focus();
                    MessageBox.Show("信号编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (string.IsNullOrWhiteSpace(dczdl.Text))
                {
                    dczdy.Focus();
                    MessageBox.Show("信号编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (string.IsNullOrWhiteSpace(dcdy.Text))
                {
                    dczdy.Focus();
                    MessageBox.Show("信号编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (string.IsNullOrWhiteSpace(dcwd.Text))
                {
                    dczdy.Focus();
                    MessageBox.Show("信号编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var sc = new ParamEntity {
                    Id = ParamId.ScOff, Value = scOff.Text.Trim(), Time = DateTime.Now
                };
                var fsu = new ParamEntity {
                    Id = ParamId.FsuOff, Value = fsuOff.Text.Trim(), Time = DateTime.Now
                };
                var _fzdl = new ParamEntity {
                    Id = ParamId.FZDL, Value = fzdl.Text.Trim(), Time = DateTime.Now
                };
                var _gzzt = new ParamEntity {
                    Id = ParamId.GZZT, Value = gzzt.Text.Trim(), Time = DateTime.Now
                };
                var _dczdy = new ParamEntity {
                    Id = ParamId.DCZDY, Value = dczdy.Text.Trim(), Time = DateTime.Now
                };
                var _dczdl = new ParamEntity {
                    Id = ParamId.DCZDL, Value = dczdl.Text.Trim(), Time = DateTime.Now
                };
                var _dcdy = new ParamEntity {
                    Id = ParamId.DCDY, Value = dcdy.Text.Trim(), Time = DateTime.Now
                };
                var _dcwd = new ParamEntity {
                    Id = ParamId.DCWD, Value = dcwd.Text.Trim(), Time = DateTime.Now
                };
                var _nhzq = new ParamEntity {
                    Id = ParamId.NHZQ, Value = nhPeriodField.SelectedValue.ToString(), Time = DateTime.Now
                };
                var _xxpl = new ParamEntity {
                    Id = ParamId.XXPL, Value = vpPeriod.Value.ToString(), Time = DateTime.Now
                };
                var _gjjk = new ParamEntity {
                    Id = ParamId.GJJK, Value = gjjkField.Checked ? "1" : "0", Time = DateTime.Now
                };
                var _dcsj = new ParamEntity {
                    Id = ParamId.DCSJ, Value = batField.Checked ? "1" : "0", Time = DateTime.Now
                };
                var _dxgj = new ParamEntity {
                    Id = ParamId.DXGJ, Value = dxgjField.Checked ? "1" : "0", Time = DateTime.Now
                };
                var _yygj = new ParamEntity {
                    Id = ParamId.YYGJ, Value = yygjField.Checked ? "1" : "0", Time = DateTime.Now
                };

                _registry.SaveParams(new List <ParamEntity> {
                    sc, fsu, _fzdl, _gzzt, _dczdy, _dczdl, _dcdy, _dcwd, _nhzq, _xxpl, _gjjk, _dcsj, _dxgj, _yygj
                });
                MessageBox.Show("保存成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            } catch (Exception err) {
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }