Пример #1
0
        public List <OLWQConfigEntity> Select(string where)
        {
            string SQL = @"SELECT TerminalID,EnableTurbidityAlarm,EnableResidualClAlarm,EnablePHAlarm,
            EnableConductivityAlarm,TurbidityUpLimit,TurbidityLowLimit,ResidualClUpLimit,ResidualClLowLimit,PHUpLimit,PHLowLimit,
            ConductivityUpLimit,ConductivityLowLimit FROM OLWQConfig ";

            if (!string.IsNullOrEmpty(where))
            {
                SQL = SQL + "WHERE " + where;
            }
            using (SqlDataReader reader = SQLHelper.ExecuteReader(SQL, null))
            {
                List <OLWQConfigEntity> lst_Config = new List <OLWQConfigEntity>();
                while (reader.Read())
                {
                    OLWQConfigEntity config = new OLWQConfigEntity();
                    config.TerId = reader["TerminalID"] != DBNull.Value ? reader["TerminalID"].ToString().Trim() : "";
                    config.enableTurbidityAlarm    = reader["EnableTurbidityAlarm"] != DBNull.Value ? (Convert.ToInt32(reader["EnableTurbidityAlarm"]) == 1 ? true : false) : false;
                    config.enableResidualClAlarm   = reader["EnableResidualClAlarm"] != DBNull.Value ? (Convert.ToInt32(reader["EnableResidualClAlarm"]) == 1 ? true : false) : false;
                    config.enablePHAlarm           = reader["EnablePHAlarm"] != DBNull.Value ? (Convert.ToInt32(reader["EnablePHAlarm"]) == 1 ? true : false) : false;
                    config.enableConductivityAlarm = reader["EnableConductivityAlarm"] != DBNull.Value ? (Convert.ToInt32(reader["EnableConductivityAlarm"]) == 1 ? true : false) : false;
                    config.TurbidityUpLimit        = reader["TurbidityUpLimit"] != DBNull.Value ? Convert.ToSingle(reader["TurbidityUpLimit"]) : 0;
                    config.TurbidityLowLimit       = reader["TurbidityLowLimit"] != DBNull.Value ? Convert.ToSingle(reader["TurbidityLowLimit"]) : 0;
                    config.ResidualClUpLimit       = reader["ResidualClUpLimit"] != DBNull.Value ? Convert.ToSingle(reader["ResidualClUpLimit"]) : 0;
                    config.ResidualClLowLimit      = reader["ResidualClLowLimit"] != DBNull.Value ? Convert.ToSingle(reader["ResidualClLowLimit"]) : 0;
                    config.PHUpLimit            = reader["PHUpLimit"] != DBNull.Value ? Convert.ToSingle(reader["PHUpLimit"]) : 0;
                    config.PHLowLimit           = reader["PHLowLimit"] != DBNull.Value ? Convert.ToSingle(reader["PHLowLimit"]) : 0;
                    config.ConductivityUpLimit  = reader["ConductivityUpLimit"] != DBNull.Value ? Convert.ToSingle(reader["ConductivityUpLimit"]) : 0;
                    config.ConductivityLowLimit = reader["ConductivityLowLimit"] != DBNull.Value ? Convert.ToSingle(reader["ConductivityLowLimit"]) : 0;

                    lst_Config.Add(config);
                }
                return(lst_Config);
            }
        }
Пример #2
0
 public bool Insert(OLWQConfigEntity configData)
 {
     try
     {
         return(dal.Insert(configData));
     }
     catch (Exception ex)
     {
         logger.ErrorException("Insert", ex);
         return(false);
     }
 }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            #region 校验
            if (string.IsNullOrEmpty(txtID.Text))
            {
                XtraMessageBox.Show("请输入终端编号!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtID.Focus();
                return;
            }
            if (!Regex.IsMatch(txtID.Text, @"^\d{1,5}$"))
            {
                XtraMessageBox.Show("请输入合法终端编号!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtID.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtName.Text))
            {
                XtraMessageBox.Show("请输入终端名称!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtName.Focus();
                return;
            }
            if (cboxTurbidityAlarm.Checked)
            {
                if (!Regex.IsMatch(txtTurbidityLowLimit.Text, @"^\d{1,4}(.\d{1,4})?$"))
                {
                    XtraMessageBox.Show("请填写合法的终端浊度下限值", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtTurbidityLowLimit.SelectAll();
                    txtTurbidityLowLimit.Focus();
                    return;
                }
            }

            if (cboxTurbidityAlarm.Checked)
            {
                if (!Regex.IsMatch(txtTurbidityUpLimit.Text, @"^\d{1,4}(.\d{1,4})?$"))
                {
                    XtraMessageBox.Show("请填写合法的终端浊度上限值", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtTurbidityUpLimit.SelectAll();
                    txtTurbidityUpLimit.Focus();
                    return;
                }
            }

            if (cboxResidualClAlarm.Checked)
            {
                if (!Regex.IsMatch(txtResidualClLowLimit.Text, @"^\d{1,4}(.\d{1,4})?$"))
                {
                    XtraMessageBox.Show("请填写合法的终端余氯下限值", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtResidualClLowLimit.SelectAll();
                    txtResidualClLowLimit.Focus();
                    return;
                }
            }

            if (cboxResidualClAlarm.Checked)
            {
                if (!Regex.IsMatch(txtResidualClUpLimit.Text, @"^\d{1,4}(.\d{1,4})?$"))
                {
                    XtraMessageBox.Show("请填写合法的终端余氯上限值", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtResidualClUpLimit.SelectAll();
                    txtResidualClUpLimit.Focus();
                    return;
                }
            }

            if (cboxPHAlarm.Checked)
            {
                if (!Regex.IsMatch(txtPHLowLimit.Text, @"^\d{1,4}(.\d{1,4})?$"))
                {
                    XtraMessageBox.Show("请填写合法的终端PH下限值", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtPHLowLimit.SelectAll();
                    txtPHLowLimit.Focus();
                    return;
                }
            }

            if (cboxPHAlarm.Checked)
            {
                if (!Regex.IsMatch(txtPHUpLimit.Text, @"^\d{1,4}(.\d{1,4})?$"))
                {
                    XtraMessageBox.Show("请填写合法的终端PH上限值", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtPHUpLimit.SelectAll();
                    txtPHUpLimit.Focus();
                    return;
                }
            }

            if (cboxConductivityAlarm.Checked)
            {
                if (!Regex.IsMatch(txtConductivityLowLimit.Text, @"^\d{1,4}(.\d{1,4})?$"))
                {
                    XtraMessageBox.Show("请填写合法的终端电导率下限值", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtConductivityLowLimit.SelectAll();
                    txtConductivityLowLimit.Focus();
                    return;
                }
            }

            if (cboxConductivityAlarm.Checked)
            {
                if (!Regex.IsMatch(txtConductivityUpLimit.Text, @"^\d{1,4}(.\d{1,4})?$"))
                {
                    XtraMessageBox.Show("请填写合法的终端电导率上限值", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtConductivityUpLimit.SelectAll();
                    txtConductivityUpLimit.Focus();
                    return;
                }
            }
            #endregion

            int saveresult = Terbll.SaveTerInfo(Convert.ToInt32(txtID.Text), txtName.Text, txtAddr.Text, txtRemark.Text, TerType.OLWQTer, null);
            if (saveresult == 1)
            {
                OLWQConfigEntity configEntity = new OLWQConfigEntity();
                configEntity.TerId = txtID.Text.Trim();
                configEntity.enableTurbidityAlarm = cboxTurbidityAlarm.Checked;
                if (configEntity.enableTurbidityAlarm)
                {
                    configEntity.TurbidityLowLimit = Convert.ToSingle(txtTurbidityLowLimit.Text);
                    configEntity.TurbidityUpLimit  = Convert.ToSingle(txtTurbidityUpLimit.Text);
                }
                configEntity.enableResidualClAlarm = cboxResidualClAlarm.Checked;
                if (configEntity.enableResidualClAlarm)
                {
                    configEntity.ResidualClLowLimit = Convert.ToSingle(txtResidualClLowLimit.Text);
                    configEntity.ResidualClUpLimit  = Convert.ToSingle(txtResidualClUpLimit.Text);
                }
                configEntity.enablePHAlarm = cboxPHAlarm.Checked;
                if (configEntity.enablePHAlarm)
                {
                    configEntity.PHLowLimit = Convert.ToSingle(txtPHLowLimit.Text);
                    configEntity.PHUpLimit  = Convert.ToSingle(txtPHUpLimit.Text);
                }
                configEntity.enableConductivityAlarm = cboxConductivityAlarm.Checked;
                if (configEntity.enableConductivityAlarm)
                {
                    configEntity.ConductivityLowLimit = Convert.ToSingle(txtConductivityLowLimit.Text);
                    configEntity.ConductivityUpLimit  = Convert.ToSingle(txtConductivityUpLimit.Text);
                }
                if ((new OLWQConfigBLL()).Insert(configEntity))
                {
                    XtraMessageBox.Show("保存成功!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadTerminalData();
                }
                else
                {
                    XtraMessageBox.Show("保存发生异常,请联系管理员!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                XtraMessageBox.Show("保存发生异常,请联系管理员!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            UpdateMonitroUI();
        }
Пример #4
0
        public bool Insert(OLWQConfigEntity configData)
        {
            SqlTransaction trans = null;

            try
            {
                if (configData == null)
                {
                    return(true);
                }

                trans = SQLHelper.GetTransaction();
                string     SQL_Del = "DELETE FROM OLWQConfig WHERE TerminalID='" + configData.TerId + "'";
                SqlCommand cmd_Del = new SqlCommand();
                cmd_Del.CommandText = SQL_Del;
                cmd_Del.Connection  = SQLHelper.Conn;
                cmd_Del.Transaction = trans;
                cmd_Del.ExecuteNonQuery();

                string         SQL_Insert = @"INSERT INTO OLWQConfig(TerminalID,EnableTurbidityAlarm,EnableResidualClAlarm,EnablePHAlarm,
            EnableConductivityAlarm,TurbidityUpLimit,TurbidityLowLimit,ResidualClUpLimit,ResidualClLowLimit,PHUpLimit,PHLowLimit,
            ConductivityUpLimit,ConductivityLowLimit) VALUES(@terid,@enableTurbidity,@enableResidualCl,@enablePH,@enableConductivity,
            @turbidityUpLimit,@turbidityLowLimit,@residualUpLimit,@residualLowLimit,@phUpLimit,@phLowLimit,@conductivityUpLimit,@conductivityLowLimit)";
                SqlParameter[] parms      = new SqlParameter[] {
                    new SqlParameter("@terid", DbType.Int32),
                    new SqlParameter("@enableTurbidity", DbType.Int32),
                    new SqlParameter("@enableResidualCl", DbType.Int32),
                    new SqlParameter("@enablePH", DbType.Int32),
                    new SqlParameter("@enableConductivity", DbType.Int32),

                    new SqlParameter("@turbidityUpLimit", DbType.Decimal),
                    new SqlParameter("@turbidityLowLimit", DbType.Decimal),
                    new SqlParameter("@residualUpLimit", DbType.Decimal),
                    new SqlParameter("@residualLowLimit", DbType.Decimal),
                    new SqlParameter("@phUpLimit", DbType.Decimal),

                    new SqlParameter("@phLowLimit", DbType.Decimal),
                    new SqlParameter("@conductivityUpLimit", DbType.Decimal),
                    new SqlParameter("@conductivityLowLimit", DbType.Decimal)
                };
                parms[0].Value  = configData.TerId;
                parms[1].Value  = configData.enableTurbidityAlarm;
                parms[2].Value  = configData.enableResidualClAlarm;
                parms[3].Value  = configData.enablePHAlarm;
                parms[4].Value  = configData.enableConductivityAlarm;
                parms[5].Value  = configData.TurbidityUpLimit;
                parms[6].Value  = configData.TurbidityLowLimit;
                parms[7].Value  = configData.ResidualClUpLimit;
                parms[8].Value  = configData.ResidualClLowLimit;
                parms[9].Value  = configData.PHUpLimit;
                parms[10].Value = configData.PHLowLimit;
                parms[11].Value = configData.ConductivityUpLimit;
                parms[12].Value = configData.ConductivityLowLimit;
                SqlCommand cmd_insert = new SqlCommand();
                cmd_insert.CommandText = SQL_Insert;
                cmd_insert.Connection  = SQLHelper.Conn;
                cmd_insert.Transaction = trans;
                cmd_insert.Parameters.AddRange(parms);
                cmd_insert.ExecuteNonQuery();

                trans.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                throw ex;
            }
        }