using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.Common; using Utility.Utils.DbUtils; namespace LayerWebservice { public class DbOperator { private DbUtil db = null; public Database dbType; public DbOperator(string connStr, string dbTypeStr) { switch (dbTypeStr.Trim().ToUpper()) { case "ORACLE9I": dbType = Database.ORACLE9I; break; case "ORACLE": dbType = Database.ORACLE; break; case "MSSQL": dbType = Database.MSSQL; break; default: dbType = Database.MSSQL; break; } db = new DbUtil(dbType, connStr); } public bool Connect() { try { db.Connect(); return true; } catch (Exception ee) { return false; } } public bool Close() { try { db.Close(); return true; } catch { return false; } } public DataTable Select(string sqlStr, int pageSize = 0, int pageIndex = -1) { DataTable dt; try { dt = db.Select(sqlStr, 0, 0); } catch(Exception e) { return null; throw; } return dt; } public DataTable Select(ref DbTransaction tran, string sqlStr, int pageSize = 0, int pageIndex = -1) { DataTable dt; try { dt = db.Select(ref tran, sqlStr, 0, 0); } catch { return null; throw; } return dt; } public int Update(string sqlStr, string separator) { int resCount = 0; resCount = db.Update(sqlStr, separator); return resCount; } public int Update(ref DbTransaction tran, string sqlStr, string separator) { int resCount = 0; resCount = db.Update(ref tran, sqlStr, separator); return resCount; } } }