Ejemplo n.º 1
0
        /// <summary>
        /// 插入t_AlarmPolicyManagement
        /// </summary>
        public virtual bool Insert(AlarmPolicyManagementSaveOR objPolicy)
        {
            string sql = string.Format(@"insert into t_AlarmPolicyManagement (StationID,DeviceTypeID,DeviceID,DeviceChannelID,
            ValueType,MaxValue,MinValue,SwitchValue,MaxTiggerType,MinTiggerType,AlarmTimes , AlarmfilterTimes,EventID,IsEnable,AlarmAudioFile,
            DisAlarmAudioFile,SmsMsg,LightID,ReleaseLightID)
            values ({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},'{12}',{13},'{14}','{15}','{16}',{17},{18})",
            objPolicy.Stationid, objPolicy.Devicetypeid, objPolicy.Deviceid, objPolicy.Devicechannelid, objPolicy.Valuetype,
               objPolicy.Maxvalue, objPolicy.Minvalue, objPolicy.Switchvalue,
               objPolicy.Mintiggertype, objPolicy.Mintiggertype,
               objPolicy.Alarmtimes, objPolicy.Alarmfiltertimes, objPolicy.Eventid, objPolicy.Isenable, objPolicy.Alarmaudiofile, objPolicy.Disalarmaudiofile,
               objPolicy.Smsmsg, objPolicy.Lightid, objPolicy.Releaselightid);

            return db.ExecuteNoQuery(sql) > 0;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新t_AlarmPolicyManagement
 /// </summary>
 public virtual bool Update(AlarmPolicyManagementSaveOR objPolicy)
 {
     string sql = string.Format(@"update dbo.t_AlarmPolicyManagement set ValueType={0},MaxValue={1},MinValue={2},SwitchValue={3},MaxTiggerType={4},MinTiggerType={5},
     AlarmTimes={6} , AlarmfilterTimes={7},EventID='{8}',IsEnable={9},AlarmAudioFile='{10}',DisAlarmAudioFile='{11}',SmsMsg='{12}',LightID={13},ReleaseLightID={14}
     where   StationID ={15} and DeviceTypeID = {16} and DeviceID ={17} and DeviceChannelID = {18}",
        objPolicy.Valuetype, objPolicy.Maxvalue, objPolicy.Minvalue, objPolicy.Switchvalue, objPolicy.Maxtiggertype, objPolicy.Mintiggertype, objPolicy.Alarmtimes, objPolicy.Alarmfiltertimes, objPolicy.Eventid, objPolicy.Isenable,
        objPolicy.Alarmaudiofile, objPolicy.Disalarmaudiofile, objPolicy.Smsmsg, objPolicy.Lightid, objPolicy.Releaselightid, objPolicy.Stationid, objPolicy.Devicetypeid, objPolicy.Deviceid, objPolicy.Devicechannelid);
     return db.ExecuteNoQuery(sql) > 0;
 }
        private AlarmPolicyManagementSaveOR SetValue()
        {
            StringBuilder sbError = new StringBuilder();

            AlarmPolicyManagementSaveOR obj = new AlarmPolicyManagementSaveOR();
            obj.Stationid = AlarmPolicyManagementObj.Stationid;
            obj.Devicetypeid = AlarmPolicyManagementObj.Devicetypeid;
            obj.Deviceid = AlarmPolicyManagementObj.Deviceid;
            obj.Devicechannelid = AlarmPolicyManagementObj.Devicechannelid;

            obj.Isenable = AlarmPolicyManagementObj.Isenable;
            obj.Valuetype=AlarmPolicyManagementObj.Valuetype;

            string EvHi, EvLo, EvSg;
            string EventID = "";
            if (AlarmPolicyManagementObj.Valuetype == 0)
            {

                if (SelectHiEventTypeOR.Eventid != -1)
                    EvHi = SelectHiEventTypeOR.Eventid.ToString();
                else
                    EvHi = "";

                if (SelectLoEventTypeOR.Eventid != -1)
                    EvLo = SelectLoEventTypeOR.Eventid.ToString();
                else
                    EvLo = "";

                EventID = EvHi + "-" + EvLo;

                obj.Maxvalue = AlarmPolicyManagementObj.Maxvalue.HasValue
                    ? AlarmPolicyManagementObj.Maxvalue.ToString() : "NULL";

                obj.Minvalue = AlarmPolicyManagementObj.Minvalue.HasValue
                    ? AlarmPolicyManagementObj.Minvalue.ToString() : "NULL";

                obj.Maxtiggertype = AlarmPolicyManagementObj.Maxtiggertype;
                obj.Mintiggertype = AlarmPolicyManagementObj.Mintiggertype;
            }
            else
            {
                if(SelectSwitchEventTypeOR.Eventid !=-1)
                    EvSg = SelectSwitchEventTypeOR.Eventid.ToString();
                else
                    EvSg = "";

                EventID = EvSg;

                obj.Maxvalue = "NULL";
                obj.Minvalue = "NULL";
                if (selectSwitchvalue == "高电平")
                    obj.Switchvalue = 1;
                else if (selectSwitchvalue == "低电平")
                    obj.Switchvalue = 0;
            }
            obj.Eventid = EventID;
            if (AlarmPolicyManagementObj.Alarmfiltertimes.HasValue)
                obj.Alarmfiltertimes = AlarmPolicyManagementObj.Alarmfiltertimes.Value;
            if (AlarmPolicyManagementObj.Alarmtimes.HasValue)
                obj.Alarmtimes = AlarmPolicyManagementObj.Alarmtimes.Value;

            obj.Smsmsg = AlarmPolicyManagementObj.Smsmsg;
            obj.Lightid = SelectLightAlarmOR.Lightid;
            obj.Releaselightid = SelectReleaseLightAlarmOR.Lightid;
            obj.Disalarmaudiofile = AlarmPolicyManagementObj.Disalarmaudiofile;
            obj.Alarmaudiofile = AlarmPolicyManagementObj.Alarmaudiofile;

            string ErrorMsg = sbError.ToString();
            if (!string.IsNullOrEmpty(ErrorMsg))
            {
                ShowMsgError(ErrorMsg);
                return null;
            }

            return obj;
        }