public DataSet GetData(string sSQL) { ISession session = CallContext.GetData("nhsession") as ISession; IDbConnection cnn = session.Connection; IDbCommand command = cnn.CreateCommand(); command.CommandText = sSQL; IDataReader dataReader = command.ExecuteReader(CommandBehavior.Default); DataSet ds = DataAccessUtil.ConvertDataReadertoDataSet(dataReader); return(ds); }
public DataSet GetDataAndRowCount(string sDataSQL, int iCurrentPage, int iPageSize, ref int iRowCount) { string sQueryData = string.Format("select * from ({0}) t where t.num between {1} and {2}", sDataSQL, (iCurrentPage - 1) * iPageSize + 1, iCurrentPage * iPageSize); string sQueryDataCount = string.Format("select count(*) from ({0}) t", sDataSQL); ISession session = CallContext.GetData("nhsession") as ISession; IDbConnection cnn = session.Connection; IDbCommand command = cnn.CreateCommand(); command.CommandText = sQueryData; IDataReader dataReader = command.ExecuteReader(CommandBehavior.Default); DataSet ds = DataAccessUtil.ConvertDataReadertoDataSet(dataReader); command.CommandText = sQueryDataCount; iRowCount = int.Parse(command.ExecuteScalar().ToString()); return(ds); }
/// <summary> /// 通过组织ID查询项目ID /// </summary> public string GetProjectIDByOperationOrg(string opgID) { string projectID = ""; ISession session = CallContext.GetData("nhsession") as ISession; IDbConnection conn = session.Connection; IDbCommand command = conn.CreateCommand(); session.Transaction.Enlist(command); //分公司信息 command.CommandText = " select t1.id from resconfig t1 where t1.ownerorg='" + opgID + "' and nvl(t1.projectcurrstate,0) != 20 and t1.projectcode != '0000'"; IDataReader dataReader = command.ExecuteReader(); DataSet ds = DataAccessUtil.ConvertDataReadertoDataSet(dataReader); if (ds != null) { DataTable dataTable = ds.Tables[0]; foreach (DataRow dataRow in dataTable.Rows) { projectID = TransUtil.ToString(dataRow["id"]); } } return(projectID); }