/// <summary> /// 获取接口服务账号 /// </summary> /// <param name="ConncetId">连接端编号</param> /// <returns>接口服务账号对象</returns> public virtual TSConnect Get(string ConncetId) { TSConnect tsConnect = null; try { string strSQL = "select * from TSConnect where ConncetId=@ConncetId"; Param param = new Param(); param.Clear(); param.Add("@ConncetId", ConncetId); db.Open(); ComDataReader dr = db.ExecuteReader(CommandType.Text, strSQL, param); if (dr.Read()) { tsConnect = ReadData(dr); } dr.Close(); } catch (Exception e) { throw e; } finally { db.Close(); } return(tsConnect); }
/// <summary> /// 读取接口服务账号信息 /// </summary> /// <param name="dr">记录指针</param> /// <returns>接口服务账号对象</returns> protected virtual TSConnect ReadData(ComDataReader dr) { TSConnect tsConnect = new TSConnect(); tsConnect.ConncetId = dr["ConncetId"].ToString(); //连接端编号 tsConnect.Token = dr["Token"].ToString(); //口令 return(tsConnect); }
/// <summary> /// 修改接口服务账号 /// </summary> /// <param name="data">数据库连接</param> /// <param name="tsConnect">接口服务账号</param> public virtual void Edit(DataAccess data, TSConnect tsConnect) { string strSQL = "update TSConnect set Token=@Token where ConncetId=@ConncetId"; Param param = new Param(); param.Clear(); param.Add("@Token", tsConnect.Token); //口令 param.Add("@ConncetId", tsConnect.ConncetId); //连接端编号 data.ExecuteNonQuery(CommandType.Text, strSQL, param); }
protected DataAccess db = new DataAccess(DataAccess.DBConn);//数据库连接 #region 代码生成器自动生成 /// <summary> /// 增加接口服务账号 /// </summary> /// <param name="data">数据库连接</param> /// <param name="tsConnect">接口服务账号</param> public virtual void Add(DataAccess data, TSConnect tsConnect) { string strSQL = "insert into TSConnect (ConncetId,Token) values (@ConncetId,@Token)"; Param param = new Param(); param.Clear(); param.Add("@ConncetId", tsConnect.ConncetId); //连接端编号 param.Add("@Token", tsConnect.Token); //口令 data.ExecuteNonQuery(CommandType.Text, strSQL, param); }
/// <summary> /// 修改接口服务账号 /// </summary> /// <param name="tsConnect">接口服务账号</param> public virtual void Edit(TSConnect tsConnect) { try { db.Open(); Edit(db, tsConnect); } catch (Exception e) { throw e; } finally { db.Close(); } }