/// <summary> /// 编辑数据 /// </summary> /// <returns></returns> private string editData() { string lb = getUTF8ToString("lb"); if (lb == "readWords" || lb == "hisWords")//文件,历史词汇 { return("false"); } string oid = getUTF8ToString("oid"); string text = getUTF8ToString("text"); try { DefVal dv = new DefVal(); dv.RetrieveByAttr(DefValAttr.OID, oid); dv.CurValue = text; dv.Update(); return("true"); } catch (Exception) { return("false"); } }
/// <summary> /// 根据oid删除 /// </summary> /// <returns></returns> private string deleteData() { string oids = getUTF8ToString("oids"); if (string.IsNullOrEmpty(oids)) { return("false"); } string lb = getUTF8ToString("lb"); if (lb == "readWords" || lb == "hisWords") { return("false"); } try { string[] oidsArray = oids.Split(','); foreach (string oid in oidsArray) { if (string.IsNullOrEmpty(oid)) { continue; } DefVal dv = new DefVal(); dv.RetrieveByAttr(DefValAttr.OID, oid); dv.Delete(); } return("true"); } catch (Exception) { return("false"); } }
/// <summary> /// 保存历史数据 /// </summary> /// <returns></returns> private string saveHistoryData() { string lb = getUTF8ToString("lb"); if (lb == "readWords" || lb == "hisWords") { return("false"); } string enName = getUTF8ToString("FK_MapData"); string AttrKey = getUTF8ToString("AttrKey"); string str = getUTF8ToString("str"); string sql = "select * from sys_defval where LB='2' and FK_Emp='" + WebUser.No + "' and FK_MapData='" + enName + "' and AttrKey='" + AttrKey + "' and CurValue='" + str + "'"; if (DBAccess.RunSQLReturnCOUNT(sql) != 0)//禁止添加重复数据 { return("false"); } sql = "select * from sys_defval where LB='2' and FK_Emp='" + WebUser.No + "' and FK_MapData='" + enName + "' and AttrKey='" + AttrKey + "'"; DataTable dt = DBAccess.RunSQLReturnTable(sql); DefVal dv = new DefVal(); if (dt.Rows.Count == 50)//动态更新数据,限制50条 { try { int minOid = int.Parse(dt.Rows[0]["OID"].ToString()); foreach (DataRow dr in dt.Rows) { int drOid = int.Parse(dr["OID"].ToString()); if (minOid > drOid) { minOid = drOid; } } dv = new DefVal(); dv.RetrieveByAttr(DefValAttr.OID, minOid); dv.Delete(); } catch (Exception) { if (dt.Rows.Count != 0) { return("false"); } } } dv = new DefVal(); dv.FK_MapData = enName; dv.AttrKey = AttrKey; dv.LB = "2"; dv.FK_Emp = WebUser.No; dv.CurValue = str; dv.Insert(); return("true"); }