/// <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"); }
/// <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"); }
private void BPToolBar2_ButtonClick(object sender, System.EventArgs e) { try { ToolbarBtn btn = (ToolbarBtn)sender; DefVal en = new DefVal(); QueryObject qo = new QueryObject(en); // BP.En.Entity enDA = DA.ClassFactory.GetEn(this.EnsName); switch (btn.ID) { case NamesOfBtn.Cancel: this.WinClose(); break; case "Btn_SaveToMyDefaultValues": if (AttrKeyValue.Trim().Length == 0) { throw new Exception("@默认值不能为空。"); } en.FK_Emp = WebUser.No; en.EnsName = this.EnsName; en.AttrKey = this.AttrKey; en.Val = this.AttrKeyValue; qo.AddWhere(DefValAttr.FK_Emp, en.FK_Emp); qo.addAnd(); qo.AddWhere(DefValAttr.AttrKey, en.AttrKey); qo.addAnd(); qo.AddWhere(DefValAttr.EnsName, en.EnsName); qo.addAnd(); qo.AddWhere(DefValAttr.Val, en.Val); if (qo.DoQuery() == 0) { en.Insert(); } this.SetDGData(); this.ResponseWriteBlueMsg_SaveOK(); break; case "Btn_SaveToAppDefaultValues": if (AttrKeyValue.Trim().Length == 0) { throw new Exception("@默认值不能为空。"); } en.FK_Emp = "0"; en.EnsName = this.EnsName; en.AttrKey = this.AttrKey; en.Val = this.AttrKeyValue; qo.AddWhere(DefValAttr.FK_Emp, en.FK_Emp); qo.addAnd(); qo.AddWhere(DefValAttr.AttrKey, en.AttrKey); qo.addAnd(); qo.AddWhere(DefValAttr.EnsName, en.EnsName); qo.addAnd(); qo.AddWhere(DefValAttr.Val, en.Val); if (qo.DoQuery() == 0) { en.Insert(); } this.SetDGData(); this.ResponseWriteBlueMsg_SaveOK(); break; case NamesOfBtn.Confirm: this.Confirm(); break; default: throw new Exception("没有处理的控件" + btn.ID); } } catch (Exception ex) { this.ResponseWriteRedMsg(ex); } }