public static void BindDropDownList(DropDownList ddl, string tableName, string text) { string mConn = IConfiguration.getParameter("connectString"); IDBOSQL.IDBO dbo = IDBOSQL.IDBO.getIDBO(mConn); dbo.openDatabase(); DataSet ds = dbo.executeSelectSql("select distinct " + text + " from " + tableName); ddl.DataSource = ds; ddl.DataTextField = text; ddl.DataBind(); dbo.closeDatabase(); }
/// <summary> /// 在线人数 /// </summary> /// <returns></returns> protected int GetOnlineCount() { DateTime lastM = DateTime.Now.AddMinutes(-15); string strSql = "select cast(COUNT(*) as varchar(5)) from sys_Onlines where UpdateTime>'" + lastM + "'"; string mConn = IConfiguration.getParameter("connectString"); IDBOSQL.IDBO dbo = IDBOSQL.IDBO.getIDBO(mConn); dbo.openDatabase(); string str = dbo.executeSql(strSql); dbo.closeDatabase(); return(int.Parse(str)); }
public static DataTable GetDataTable(string strSql) { string mConn = IConfiguration.getParameter("connectString"); IDBOSQL.IDBO dbo = IDBOSQL.IDBO.getIDBO(mConn); dbo.openDatabase(); try { DataSet ds = dbo.executeSelectSql(strSql); return(ds.Tables[0]); } catch (Exception ex) { throw ex; } }
public static string BuildOrderID(string strTableName, string strCodeColumn) { string mConn = IConfiguration.getParameter("connectString"); IDBOSQL.IDBO dbo = IDBOSQL.IDBO.getIDBO(mConn); dbo.openDatabase(); string strSql = "Select Max(" + strCodeColumn + ") as bh From " + strTableName; DataSet ds = dbo.executeSelectSql(strSql); if (ds.Tables[0].Rows.Count == 0) { return("1"); } else { int orderid = int.Parse(ds.Tables[0].Rows[0]["bh"].ToString()) + 1; return(orderid.ToString()); } }
//tablename 表名 //colnames string[] 列名 //values string[] 值 //strwhere 修改条件 public static bool checkExists(string tableName, string strWhere) { string strSql = "select cast(count(*)as varchar(10)) from " + tableName + " where " + strWhere; string mConn = IConfiguration.getParameter("connectString"); IDBOSQL.IDBO dbo = IDBOSQL.IDBO.getIDBO(mConn); dbo.openDatabase(); string str = dbo.executeSql(strSql); dbo.closeDatabase(); if (int.Parse(str) == 0) { return(false); } else { return(true); } }