Exemplo n.º 1
0
        public bool Insert(TerminalConfigEntity entity)
        {
            try
            {
                string         SQL_Config = @"INSERT INTO PreTerConfig(TerminalID,PreUpperLimit,PreLowLimit,PreSlopeUpLimit,PreSlopeLowLimit,EnablePreAlarm,EnableSlopeAlarm) VALUES(
                @TerminalID,@PreUpperLimit,@PreLowLimit,@PreSlopeUpLimit,@PreSlopeLowLimit,@EnablePreAlarm,@EnableSlopeAlarm)";
                SqlParameter[] parms      = new SqlParameter[] {
                    new SqlParameter("@TerminalID", DbType.Int32),
                    new SqlParameter("@PreUpperLimit", DbType.Decimal),
                    new SqlParameter("@PreLowLimit", DbType.Single),
                    new SqlParameter("@PreSlopeUpLimit", DbType.Single),
                    new SqlParameter("@PreSlopeLowLimit", DbType.Single),

                    new SqlParameter("@EnablePreAlarm", DbType.Int32),
                    new SqlParameter("@EnableSlopeAlarm", DbType.Int32),
                };
                parms[0].Value = entity.TerminalID;
                parms[1].Value = entity.PreUpLimit;
                parms[2].Value = entity.PreLowLimit;
                parms[3].Value = entity.PreSlopeUpLimit;
                parms[4].Value = entity.PreSlopeLowLimit;

                parms[5].Value = entity.EnablePreAlarm ? 1 : 0;
                parms[6].Value = entity.EnableSlopeAlarm ? 1 : 0;

                SQLHelper.ExecuteNonQuery(SQL_Config, parms);

                terDal.SaveTerInfo(entity.TerminalID, entity.TerminalName, entity.TerminalAddr, entity.Remark, TerType.PreTer, null, false);
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private TerminalConfigEntity GetEntity()
        {
            TerminalConfigEntity entity = new TerminalConfigEntity();

            entity.TerminalID       = Convert.ToInt32(txtTerminalID.Text.Trim());
            entity.TerminalName     = txtTerminalName.Text.Trim();
            entity.TerminalAddr     = txtAddress.Text.Trim();
            entity.Remark           = txtRemark.Text;
            entity.EnablePreAlarm   = cboxPreAlarm.Checked;
            entity.EnableSlopeAlarm = cboxSlopeAlarm.Checked;

            if (cboxPreAlarm.Checked)
            {
                entity.PreLowLimit = Convert.ToDecimal(txtPreLowLimit.Text);
                entity.PreUpLimit  = Convert.ToDecimal(txtPreUpLimite.Text);
            }
            else
            {
                entity.PreLowLimit = 0;
                entity.PreUpLimit  = 0;
            }

            if (cboxSlopeAlarm.Checked)
            {
                entity.PreSlopeLowLimit = Convert.ToDecimal(txtSlopeLowLimit.Text);
                entity.PreSlopeUpLimit  = Convert.ToDecimal(txtSlopeUpLimit.Text);
            }
            else
            {
                entity.PreSlopeLowLimit = 0;
                entity.PreSlopeUpLimit  = 0;
            }

            return(entity);
        }
Exemplo n.º 3
0
 public bool Modify(TerminalConfigEntity entity)
 {
     if (DeletePreTer(entity.TerminalID.ToString()))
     {
         Insert(entity);
     }
     return(true);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 修改一条记录(根据终端编号)
        /// </summary>
        public bool Modify(TerminalConfigEntity entity)
        {
            try
            {
                return(dal.Modify(entity));
            }
            catch (Exception ex)
            {
                return(false);

                logger.ErrorException("Modify", ex);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 插入一条记录
        /// </summary>
        public bool Insert(TerminalConfigEntity entity)
        {
            try
            {
                return(dal.Insert(entity));
            }
            catch (Exception ex)
            {
                return(false);

                logger.ErrorException("Insert", ex);
            }
        }
Exemplo n.º 6
0
        public List <TerminalConfigEntity> GetAllPreTerminals()
        {
            lock (ConstValue.obj)
            {
                string SQL = @"SELECT DISTINCT Ter.TerminalID,Ter.TerminalName,Ter.[Address],Ter.Remark,PreUpperLimit,PreLowLimit,PreSlopeUpLimit,PreSlopeLowLimit,EnablePreAlarm,EnableSlopeAlarm FROM Terminal Ter, [PreTerConfig] Config 
                WHERE Ter.TerminalID=Config.TerminalID AND Ter.TerminalType='" + (int)TerType.PreTer + "' ORDER BY TerminalName";
                using (SqlDataReader reader = SQLHelper.ExecuteReader(SQL, null))
                {
                    List <TerminalConfigEntity> lstConfig = new List <TerminalConfigEntity>();
                    while (reader.Read())
                    {
                        TerminalConfigEntity entity = new TerminalConfigEntity();

                        entity.TerminalID   = reader["TerminalID"] != DBNull.Value ? Convert.ToInt32(reader["TerminalID"]) : 0;
                        entity.TerminalName = reader["TerminalName"] != DBNull.Value ? reader["TerminalName"].ToString() : "";
                        entity.TerminalAddr = reader["Address"] != DBNull.Value ? reader["Address"].ToString() : "";
                        entity.Remark       = reader["Remark"] != DBNull.Value ? reader["Remark"].ToString() : "";

                        entity.EnablePreAlarm   = reader["EnablePreAlarm"] != DBNull.Value ? (Convert.ToInt32(reader["EnablePreAlarm"]) == 1 ? true : false) : true;
                        entity.EnableSlopeAlarm = reader["EnableSlopeAlarm"] != DBNull.Value ? (Convert.ToInt32(reader["EnableSlopeAlarm"]) == 1 ? true : false) : true;

                        if (entity.EnablePreAlarm)
                        {
                            entity.PreLowLimit = reader["PreLowLimit"] != DBNull.Value ? Convert.ToDecimal(reader["PreLowLimit"]) : 0;
                            entity.PreUpLimit  = reader["PreUpperLimit"] != DBNull.Value ? Convert.ToDecimal(reader["PreUpperLimit"]) : 0;
                        }
                        if (entity.EnableSlopeAlarm)
                        {
                            entity.PreSlopeLowLimit = reader["PreSlopeLowLimit"] != DBNull.Value ? Convert.ToDecimal(reader["PreSlopeLowLimit"]) : 0;
                            entity.PreSlopeUpLimit  = reader["PreSlopeUpLimit"] != DBNull.Value ? Convert.ToDecimal(reader["PreSlopeUpLimit"]) : 0;
                        }

                        lstConfig.Add(entity);
                    }
                    return(lstConfig);
                }
                return(null);
            }
        }
Exemplo n.º 7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (Validate())
            {
                TerminalConfigEntity entity = null;
                if (configBLL.IsExist(txtTerminalID.Text.Trim()))
                {
                    if (DialogResult.Yes == XtraMessageBox.Show("终端编号[" + txtTerminalID.Text + "]已经存在,是否更新?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk))
                    {
                        entity = GetEntity();
                        if (configBLL.Modify(entity))
                        {
                            XtraMessageBox.Show("更新成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            MonitorView = (PreTerMonitor)GlobalValue.MainForm.GetView(typeof(PreTerMonitor));
                            if (MonitorView != null)
                            {
                                MonitorView.ShowTerList(false, true);
                                MonitorView.ShowTerData();
                            }

                            ClearConfigControls();
                            GetConfigFromDB();
                        }
                        else
                        {
                            XtraMessageBox.Show("更新失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    if (DialogResult.Yes == XtraMessageBox.Show("是否新增终端编号[" + txtTerminalID.Text + "]?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk))
                    {
                        entity = GetEntity();
                        if (configBLL.Insert(entity))
                        {
                            XtraMessageBox.Show("新增成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            MonitorView = (PreTerMonitor)GlobalValue.MainForm.GetView(typeof(PreTerMonitor));
                            if (MonitorView != null)
                            {
                                MonitorView.ShowTerList(false, true);
                                MonitorView.ShowTerData();
                            }

                            ClearConfigControls();
                            GetConfigFromDB();
                        }
                        else
                        {
                            XtraMessageBox.Show("新增失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }