• UCML针对数据表的修改自定义维护数据变更记录


    1、BPO新建服务端函数,在服务端业务提交后调用,参数:VCName

     1 DBLayer.ProjectM.yq_projectplan objyq_projectplan = new DBLayer.ProjectM.yq_projectplan();
     2 DBLayer.ProjectM.yq_projectplanInfo objyq_projectplanInfo = new DBLayer.ProjectM.yq_projectplanInfo();
     3 string result = "";
     4 DataTable deltaTable = BC_projectplansLBase.deltaTable;
     5 //获取VC字段
     6 DataTable fieldArray = GetFieldArray(vcname);
     7 //用户信息
     8 string userID = base.loginUserInfo.UserOID.ToString();
     9 string userName = base.loginUserInfo.PersonName .ToString();
    10 string tableName = "yq_projectplan";
    11 string oldValue = "",newValue = "";
    12 UCMLCommon.DataChangeLog dlog = new UCMLCommon.DataChangeLog();
    13 
    14 for (int i = 0; i < deltaTable.Rows.Count; i++)
    15 {
    16    if (deltaTable.Rows[i].RowState == DataRowState.Modified){
    17         string COID = deltaTable.Rows[i]["yq_projectplanOID"].ToString();//数据主键 
    18            string NewOID = Guid.NewGuid().ToString();
    19            for(int j=0;j<fieldArray.Rows.Count;j++){
    20                string fieldname = fieldArray.Rows[j]["FieldName"].ToString();
    21                string fielddesc = fieldArray.Rows[j]["ChineseName"].ToString();
    22                //遍历判断每个字段
    23                if (!deltaTable.Rows[i][""+fieldname+""].Equals(deltaTable.Rows[i][""+fieldname+"", DataRowVersion.Original]))
    24             {
    25                    oldValue = deltaTable.Rows[i][""+fieldname+"", DataRowVersion.Original].ToString();
    26                 newValue = deltaTable.Rows[i][""+fieldname+""].ToString();
                 //插入单个字段的修改记录 
    27 string resultlog = dlog.SetInsertLog(NewOID,userID,userName,tableName,COID,fieldname,fielddesc,oldValue,newValue,"修改","数据修改"); 28 } 29 } 30 //插入针对数据行变更的修改记录 31 string resultlogm = dlog.SetInsertLogM(NewOID,userID,userName,tableName,COID,"修改","修改保存成功"); 32 } 33 }

    2、辅助函数

    //查询当前VC前台显示的字段集合,用作辅助遍历判断是否修改值
    StringBuilder commandText = new StringBuilder(); commandText.Append(" select FieldName,ChineseName from AppletColumn where AppletOID =(select AppletOID from Applet where AppletName = '"+vcname+"')"); SysDBModel.CodeValue Codeobj = new SysDBModel.CodeValue(); DataTable CodeTable = new DataTable(); Codeobj.ExecuteQuery(commandText.ToString(), CodeTable); return CodeTable;
  • 相关阅读:
    前端三剑客之css 后续
    前端三剑客之css
    优酷项目遇到的知识点回顾
    MySQL 里 视图,触发器,事物,存储过程,内置函数,流程控制,索引
    mysql的用户管理
    数据库管理工具 navicat 相关的练习
    MySQL 单表查询,多表查询
    MySQL 外键 表与表的关系 多对一,多对多,一对一,表的修改 与 复制
    ORM基础
    Django路由系统
  • 原文地址:https://www.cnblogs.com/zhipeng007/p/12761272.html
Copyright © 2020-2023  润新知