Esempio n. 1
0
 /// <summary>
 /// 插入t_Device
 /// </summary>
 public virtual bool Insert(t_Device device)
 {
     string sql = "insert into t_Device (DeviceID, DeviceName, CommunicateType, CommunicateID, SubAddr, DeviceTypeID, StationID, StationName, IP, UserId, Password, Enable, Port) values (@DeviceID, @DeviceName, @CommunicateType, @CommunicateID, @SubAddr, @DeviceTypeID, @StationID, @StationName, @IP, @UserId, @Password, @Enable, @Port)";
     SqlParameter [] parameters = new SqlParameter[]
     {
         new SqlParameter("@DeviceID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "DeviceID", DataRowVersion.Default, device.DeviceID),
         new SqlParameter("@DeviceName", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "DeviceName", DataRowVersion.Default, device.DeviceName),
         new SqlParameter("@CommunicateType", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "CommunicateType", DataRowVersion.Default, device.Communicatetype),
         new SqlParameter("@CommunicateID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "CommunicateID", DataRowVersion.Default, device.CommunicateID),
         new SqlParameter("@SubAddr", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "SubAddr", DataRowVersion.Default, device.SubAddr),
         new SqlParameter("@DeviceTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "DeviceTypeID", DataRowVersion.Default, device.DeviceTypeID),
         new SqlParameter("@StationID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "StationID", DataRowVersion.Default, device.StationID),
         new SqlParameter("@StationName", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "StationName", DataRowVersion.Default, device.StationName),
         new SqlParameter("@IP", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "IP", DataRowVersion.Default, device.IP),
         new SqlParameter("@UserId", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "UserId", DataRowVersion.Default, device.UserID),
         new SqlParameter("@Password", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Password", DataRowVersion.Default, device.Password),
         new SqlParameter("@Enable", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "Enable", DataRowVersion.Default, device.Enable),
         new SqlParameter("@Port", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "Port", DataRowVersion.Default, device.Port)
     };
     return db.ExecuteNoQuery(sql, parameters) > -1;
 }
Esempio n. 2
0
        public List<t_Device> GetDevicesByStationId(int stationId)
        {
            string sql = "select * from t_Device where StationID = " + stationId;

            DataTable dt = null;
            try
            {
                dt = db.ExecuteQuery(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            List<t_Device> _List = new List<t_Device>();
            foreach (DataRow dr in dt.Rows)
            {
                t_Device obj = new t_Device(dr);
                _List.Add(obj);
            }
            return _List;
        }
Esempio n. 3
0
        public ObservableCollection<t_Device> selectAllDate()
        {
            string sql = "select * from t_Device";

            DataTable dt = null;
            try
            {
                dt = db.ExecuteQuery(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ObservableCollection<t_Device> _List = new ObservableCollection<t_Device>();
            foreach (DataRow dr in dt.Rows)
            {
                t_Device obj = new t_Device(dr);
                _List.Add(obj);
            }
            return _List;
        }
Esempio n. 4
0
 /// <summary>
 /// 更新t_Device
 /// </summary>
 public virtual bool Update(t_Device device)
 {
     string sql = "update t_Device set  DeviceName = @DeviceName,  CommunicateType = @CommunicateType,  CommunicateID = @CommunicateID,  SubAddr = @SubAddr,  DeviceTypeID = @DeviceTypeID,  StationID = @StationID,  StationName = @StationName,  IP = @IP,  UserId = @UserId,  Password = @Password,  Enable = @Enable,  Port = @Port where  DeviceID = @DeviceID";
     SqlParameter [] parameters = new SqlParameter[]
     {
         new SqlParameter("@DeviceID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "DeviceID", DataRowVersion.Default, device.DeviceID),
         new SqlParameter("@DeviceName", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "DeviceName", DataRowVersion.Default, device.DeviceName),
         new SqlParameter("@CommunicateType", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "CommunicateType", DataRowVersion.Default, device.Communicatetype),
         new SqlParameter("@CommunicateID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "CommunicateID", DataRowVersion.Default, device.CommunicateID),
         new SqlParameter("@SubAddr", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "SubAddr", DataRowVersion.Default, device.SubAddr),
         new SqlParameter("@DeviceTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "DeviceTypeID", DataRowVersion.Default, device.DeviceTypeID),
         new SqlParameter("@StationID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "StationID", DataRowVersion.Default, device.StationID),
         new SqlParameter("@StationName", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "StationName", DataRowVersion.Default, device.StationName),
         new SqlParameter("@IP", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "IP", DataRowVersion.Default, device.IP),
         new SqlParameter("@UserId", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "UserId", DataRowVersion.Default, device.UserID),
         new SqlParameter("@Password", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Password", DataRowVersion.Default, device.Password),
         new SqlParameter("@Enable", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "Enable", DataRowVersion.Default, device.Enable),
         new SqlParameter("@Port", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "Port", DataRowVersion.Default, device.Port)
     };
     return db.ExecuteNoQuery(sql, parameters) > -1;
 }
Esempio n. 5
0
 public t_Device selectARowDate(string m_id)
 {
     string sql = string.Format("select * from t_Device where  Deviceid='{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];
     t_Device m_Devi=new t_Device(dr);
      return m_Devi;
 }
Esempio n. 6
0
 public void Clone(t_Device obj)
 {
     //
     DeviceID = obj.DeviceID;
     //
     DeviceName = obj.DeviceName;
     //
     Communicatetype = obj.Communicatetype;
     //
     CommunicateID = obj.CommunicateID;
     //
     SubAddr = obj.SubAddr;
     //
     DeviceTypeID = obj.DeviceTypeID;
     //
     StationID = obj.StationID;
     //
     StationName = obj.StationName;
     //
     IP = obj.IP;
     //
     UserID = obj.UserID;
     //
     Password = obj.Password;
     //
     Enable = obj.Enable;
     //
     Port = obj.Port;
 }