public ObservableCollection<FalseAlarmPolicyOR> selectAllDate()
        {
            string sql = @"select fp.*,t.StationName,d.DeviceName,c.ChannelName  from t_FalseAlarmPolicy fp
            inner join t_AlarmPolicyManagement am on fp.PolicyID= am.AlarmPolicyManagementID
            inner join t_Station t  on am.StationID=t.StationID
            inner join t_Device d on am.DeviceID=d.DeviceID
            inner join t_Channel c on am.DeviceChannelID=c.ChannelNo and c.DeviceID=d.DeviceID
            ";

            DataTable dt = null;
            try
            {
                dt = db.ExecuteQuery(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ObservableCollection<FalseAlarmPolicyOR> _List = new ObservableCollection<FalseAlarmPolicyOR>();
            foreach (DataRow dr in dt.Rows)
            {
                FalseAlarmPolicyOR obj = new FalseAlarmPolicyOR(dr);
                _List.Add(obj);
            }
            return _List;
        }
 public FalseAlarmPolicyEditViewModel(FalseAlarmPolicyListViewModel _vm, FalseAlarmPolicyEditView _mw)
 {
     _FalseAlarmPolicyListVM = _vm;
     _Window = _mw;
     OperationType = OpType.Add;
     FalseAlarmPolicyObj = new FalseAlarmPolicyOR();
     //UpdatetxtSource(_Window.gridContent);
     Init();
 }
        public FalseAlarmPolicyEditViewModel(FalseAlarmPolicyListViewModel _vm, FalseAlarmPolicyEditView _mw, FalseAlarmPolicyOR _FalseAlarmPolicyObj)
        {
            _FalseAlarmPolicyListVM = _vm;
            _Window = _mw;
            _SourceObj = _FalseAlarmPolicyObj;

            OperationType = OpType.Alert;
            FalseAlarmPolicyObj = new FalseAlarmPolicyOR();
            FalseAlarmPolicyObj.Clone(_FalseAlarmPolicyObj);

            Init();
        }
 /// <summary>
 /// 插入t_FalseAlarmPolicy
 /// </summary>
 public virtual bool Insert(FalseAlarmPolicyOR falseAlarmPolicy)
 {
     string sql = @"insert into t_FalseAlarmPolicy ( FalsePolicyID, PolicyID, FalseType)
     values (@FalsePolicyID, @PolicyID, @FalseType)";
     SqlParameter[] parameters = new SqlParameter[]
     {
         //new SqlParameter("@FalseAlarmID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "FalseAlarmID", DataRowVersion.Default, falseAlarmPolicy.Falsealarmid),
         new SqlParameter("@FalsePolicyID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "FalsePolicyID", DataRowVersion.Default, falseAlarmPolicy.Falsepolicyid),
         new SqlParameter("@PolicyID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "PolicyID", DataRowVersion.Default, falseAlarmPolicy.Policyid),
         new SqlParameter("@FalseType", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "FalseType", DataRowVersion.Default, falseAlarmPolicy.Falsetype)
     };
     return db.ExecuteNoQuery(sql, parameters) > -1;
 }
 /// <summary>
 /// 更新t_FalseAlarmPolicy
 /// </summary>
 public virtual bool Update(FalseAlarmPolicyOR falseAlarmPolicy)
 {
     string sql = "update t_FalseAlarmPolicy set  FalsePolicyID = @FalsePolicyID,  PolicyID = @PolicyID,  FalseType = @FalseType where  FalseAlarmID = @FalseAlarmID";
     SqlParameter[] parameters = new SqlParameter[]
     {
         new SqlParameter("@FalseAlarmID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "FalseAlarmID", DataRowVersion.Default, falseAlarmPolicy.Falsealarmid),
         new SqlParameter("@FalsePolicyID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "FalsePolicyID", DataRowVersion.Default, falseAlarmPolicy.Falsepolicyid),
         new SqlParameter("@PolicyID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "PolicyID", DataRowVersion.Default, falseAlarmPolicy.Policyid),
         new SqlParameter("@FalseType", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "FalseType", DataRowVersion.Default, falseAlarmPolicy.Falsetype)
     };
     return db.ExecuteNoQuery(sql, parameters) > -1;
 }
 public FalseAlarmPolicyOR selectARowDate(string m_id)
 {
     string sql = string.Format("select * from t_FalseAlarmPolicy where  Falsealarmid='{0}'", m_id);
     DataTable dt = null;
     try
     {
         dt = db.ExecuteQueryDataSet(sql).Tables[0];
     }
     catch (Exception ex)
     {
         throw ex;
     }
     if (dt == null)
         return null;
     if (dt.Rows.Count == 0)
         return null;
     DataRow dr = dt.Rows[0];
     FalseAlarmPolicyOR m_Fals = new FalseAlarmPolicyOR(dr);
     return m_Fals;
 }
 public FalseAlarmPolicyEditViewModel(FalseAlarmPolicyOR _Sta)
 {
     OperationType = OpType.Alert;
     FalseAlarmPolicyObj = _Sta;
 }
 public FalseAlarmPolicyEditView(FalseAlarmPolicyListViewModel _List, FalseAlarmPolicyOR _FalseAlarmPolicy)
 {
     InitializeComponent();
     this.DataContext = new FalseAlarmPolicyEditViewModel(_List, this, _FalseAlarmPolicy);
 }
        public void Clone(FalseAlarmPolicyOR obj)
        {
            //机房名称
            Falsealarmid = obj.Falsealarmid;
            //设备名称
            Falsepolicyid = obj.Falsepolicyid;
            //策略名
            Policyid = obj.Policyid;
            //限制类型
            Falsetype = obj.Falsetype;

            StationName = obj.StationName;
            DeviceName = obj.DeviceName;
            ChannelName = obj.ChannelName;
        }