//获取数据 private string getData() { DefVal dv = new DefVal(); dv.CheckPhysicsTable(); string enName = getUTF8ToString("FK_MapData"); string AttrKey = getUTF8ToString("AttrKey"); string lb = getUTF8ToString("lb"); if (lb == "readWords")//读取txt文件 { return(readTxt()); } try { DataTable dt = new DataTable(); string sql = ""; string addQue = "";//公用sql查询条件 addQue = " and FK_MapData='" + enName + "' and AttrKey='" + AttrKey + "'"; if (lb == "myWords")//我的词汇 { sql = "select * from sys_defval where LB='1' and FK_Emp='" + WebUser.No + "'" + addQue; } if (lb == "hisWords")//历史词汇 { sql = "select * from sys_defval where LB='2' and FK_Emp='" + WebUser.No + "'" + addQue; } if (lb == "sysWords")//系统词汇 { switch (DBAccess.AppCenterDBType) { case DBType.Oracle: sql = "select * from sys_defval where LB='3' and FK_Emp is null" + addQue; break; case DBType.MSSQL: sql = "select * from sys_defval where LB='3' and FK_Emp=''" + addQue; break; } } string pageNumber = getUTF8ToString("pageNumber"); int iPageNumber = string.IsNullOrEmpty(pageNumber) ? 1 : Convert.ToInt32(pageNumber); //每页多少行 string pageSize = getUTF8ToString("pageSize"); int iPageSize = string.IsNullOrEmpty(pageSize) ? 9999 : Convert.ToInt32(pageSize); switch (DBAccess.AppCenterDBType) { case DBType.Oracle: case DBType.MSSQL: return(DBPaging("(" + sql + ")sqlStr", iPageNumber, iPageSize, "OID", "OID")); case DBType.MySQL: return(DBPaging("(" + sql + " order by OID DESC )sqlStr", iPageNumber, iPageSize, "OID", "")); default: throw new Exception("暂不支持您的数据库类型."); } } catch (Exception) { return(""); } }
/// <summary> /// 添加数据 /// </summary> /// <returns></returns> private string addData() { string lb = getUTF8ToString("lb"); if (lb == "readWords" || lb == "hisWords")//文件,历史词汇 { return("false"); } string text = getUTF8ToString("text"); text = DataTableConvertJson.GetFilteredStrForJSON(text); if (string.IsNullOrEmpty(text)) { return("false"); } string enName = getUTF8ToString("FK_MapData"); string AttrKey = getUTF8ToString("AttrKey"); string lbStr = ""; string fk_emp = ""; if (lb == "myWords")//我的词汇 { lbStr = "1"; fk_emp = WebUser.No; } if (lb == "sysWords")//系统词汇 { lbStr = "3"; fk_emp = ""; } string addQue = " and FK_MapData='" + enName + "' and AttrKey='" + AttrKey + "' and CurValue='" + text + "'"; string sql = "select * from sys_defval where LB='" + lbStr + "' and FK_Emp='" + fk_emp + "'" + addQue; if (DBAccess.RunSQLReturnCOUNT(sql) != 0) { return("false"); } try { DefVal dv = new DefVal(); dv.FK_MapData = enName; dv.AttrKey = AttrKey; dv.LB = lbStr; dv.FK_Emp = fk_emp; dv.CurValue = text; dv.Insert(); } catch { DefVal dv = new DefVal(); dv.RunSQL("drop table Sys_DefVal"); dv.CheckPhysicsTable(); } return("true"); }