public override int DealEndApprove(string approvePkValue, UserInfo sysUser, string viewTitle)
        {
            Dictionary <string, object> paras = new Dictionary <string, object>();

            paras.Add("assetsMergeId", approvePkValue);
            string    sql      = @"select * from AssetsMergeDetail where assetsMergeId=@assetsMergeId";
            DataTable dtAssets = AppMember.DbHelper.GetDataSet(sql, paras, dbUpdate.cmd).Tables[0];
            int       rowIndex = 0;

            foreach (DataRow dr in dtAssets.Rows)
            {
                AssetsMerge assetsMerge = new AssetsMerge();
                assetsMerge.AssetsId         = DataConvert.ToString(dr["newAssetsId"]);
                assetsMerge.AssetsNo         = DataConvert.ToString(dr["assetsNo"]);
                assetsMerge.AssetsValue      = DataConvert.ToString(dr["assetsValue"]);
                assetsMerge.OriginalAssetsId = DataConvert.ToString(dr["originalAssetsId"]);
                if (rowIndex == 0)
                {
                    AddNewAssets(assetsMerge, sysUser.UserId, viewTitle);
                }
                UpdateAssetsState(assetsMerge.OriginalAssetsId, "M", sysUser.UserId, viewTitle);
                rowIndex++;
            }
            return(1);
        }
        protected override int AddData(Dictionary <string, object> objs, UserInfo sysUser, string viewTitle)
        {
            string    sql = @"select * from AssetsMerge where 1<>1 ";
            DataTable dt  = AppMember.DbHelper.GetDataSet(sql, dbUpdate.cmd).Tables[0];

            dt.TableName = "AssetsMerge";
            DataRow dr            = dt.NewRow();
            string  assetsMergeId = IdGenerator.GetMaxId(dt.TableName);
            int     retApprove    = InitFirstApproveTask("AssetsMerge", "AssetsMergeId", assetsMergeId, viewTitle);

            foreach (KeyValuePair <string, object> kv in objs)
            {
                if (kv.Key != "gridData" && kv.Key != "upGridData")
                {
                    dr[kv.Key] = kv.Value;
                }
            }
            if (retApprove != 0)
            {
                dr["approveState"] = "O";
            }
            dr["AssetsMergeId"] = assetsMergeId;
            Create5Field(dr, sysUser.UserId, viewTitle);
            dt.Rows.Add(dr);
            dbUpdate.Update(dt);
            List <AssetsMerge> gridData    = JsonHelper.JSONStringToList <AssetsMerge>(DataConvert.ToString(objs["gridData"]));
            AssetsMerge        assetsMerge = gridData[0];

            assetsMerge.AssetsId = IdGenerator.GetMaxId("Assets");
            List <AssetsMerge> upGridData = JsonHelper.JSONStringToList <AssetsMerge>(DataConvert.ToString(objs["upGridData"]));

            foreach (AssetsMerge originalAssetsMerge in upGridData)
            {
                AddDetail(assetsMerge, originalAssetsMerge, assetsMergeId, sysUser.UserId, viewTitle);
                if (retApprove == 0)
                {
                    UpdateAssetsState(originalAssetsMerge.AssetsId, "M", sysUser.UserId, viewTitle);
                }
                else
                {
                    UpdateAssetsState(originalAssetsMerge.AssetsId, "MI", sysUser.UserId, viewTitle);
                }
            }
            if (retApprove == 0)
            {
                AddNewAssets(assetsMerge, sysUser.UserId, viewTitle);
            }
            return(1);
        }
        protected int AddDetail(AssetsMerge AssetsMerge, AssetsMerge OriginalAssetsMerge, string AssetsMergeId, string sysUser, string viewTitle)
        {
            string    sql = @"select * from AssetsMergeDetail where 1<>1 ";
            DataTable dt  = AppMember.DbHelper.GetDataSet(sql).Tables[0];

            dt.TableName = "AssetsMergeDetail";
            DataRow dr = dt.NewRow();

            dr["AssetsMergeId"]    = AssetsMergeId;
            dr["originalAssetsId"] = OriginalAssetsMerge.AssetsId;
            dr["newAssetsId"]      = AssetsMerge.AssetsId;
            dr["assetsNo"]         = AssetsMerge.AssetsNo;
            dr["assetsName"]       = AssetsMerge.AssetsName;
            dr["assetsValue"]      = AssetsMerge.AssetsValue;
            dr["remark"]           = AssetsMerge.Remark;
            dt.Rows.Add(dr);
            return(dbUpdate.Update(dt));
        }
        protected override int EditData(Dictionary <string, object> objs, UserInfo sysUser, string pkValue, string viewTitle, string formMode)
        {
            Dictionary <string, object> paras = new Dictionary <string, object>();

            paras.Add("AssetsMergeId", pkValue);
            string    sql = @"select * from AssetsMerge where AssetsMergeId=@AssetsMergeId";
            DataTable dt  = AppMember.DbHelper.GetDataSet(sql, paras, dbUpdate.cmd).Tables[0];

            dt.TableName = "AssetsMerge";
            string AssetsMergeId = DataConvert.ToString(dt.Rows[0]["AssetsMergeId"]);

            foreach (KeyValuePair <string, object> kv in objs)
            {
                if (kv.Key != "gridData" && kv.Key != "upGridData")
                {
                    dt.Rows[0][kv.Key] = kv.Value;
                }
            }
            if (formMode == "reapply")
            {
                dt.Rows[0]["approveState"] = "O";
            }
            Update5Field(dt, sysUser.UserId, viewTitle);
            dbUpdate.Update(dt);
            DeleteDetail(pkValue);
            List <AssetsMerge> gridData    = JsonHelper.JSONStringToList <AssetsMerge>(DataConvert.ToString(objs["gridData"]));
            AssetsMerge        AssetsMerge = gridData[0];
            List <AssetsMerge> upGridData  = JsonHelper.JSONStringToList <AssetsMerge>(DataConvert.ToString(objs["upGridData"]));

            foreach (AssetsMerge OriginalAssetsMerge in upGridData)
            {
                AddDetail(AssetsMerge, OriginalAssetsMerge, pkValue, sysUser.UserId, viewTitle);
            }
            if (formMode == "reapply")
            {
                InitFirstApproveTask("AssetsMerge", "AssetsMergeId", AssetsMergeId, viewTitle, formMode, sysUser.UserId);
            }
            return(1);
        }
        //protected int UpdateOriginalAssets(AssetsMerge assetsMerge, string sysUser, string viewTitle)
        //{
        //    Dictionary<string, object> paras = new Dictionary<string, object>();
        //    paras.Add("assetsId", assetsMerge.OriginalAssetsId);
        //    string sql = @"select * from Assets where assetsId=@assetsId";
        //    DataTable dtAssets = AppMember.DbHelper.GetDataSet(sql, paras, dbUpdate.cmd).Tables[0];
        //    dtAssets.TableName = "Assets";
        //    dtAssets.Rows[0]["assetsState"] = "M";
        //    Update5Field(dtAssets, sysUser, viewTitle);
        //    return dbUpdate.Update(dtAssets);
        //}

        protected int AddNewAssets(AssetsMerge assetsMerge, string sysUser, string viewTitle)
        {
            Dictionary <string, object> paras = new Dictionary <string, object>();

            paras.Add("assetsId", assetsMerge.OriginalAssetsId);
            string    sql      = @"select * from Assets where assetsId=@assetsId ";
            DataTable dtAssets = AppMember.DbHelper.GetDataSet(sql, paras, dbUpdate.cmd).Tables[0];

            dtAssets.TableName = "Assets";
            DataRow drNew = dtAssets.NewRow();

            for (int i = 0; i < dtAssets.Columns.Count; i++)
            {
                drNew[i] = dtAssets.Rows[0][i];
            }
            drNew["assetsId"]    = assetsMerge.AssetsId;
            drNew["assetsNo"]    = assetsMerge.AssetsNo;
            drNew["assetsValue"] = assetsMerge.AssetsValue;
            drNew["remark"]      = assetsMerge.Remark;
            Create5Field(drNew, sysUser, viewTitle);
            dtAssets.Rows.Add(drNew);
            return(dbUpdate.Update(dtAssets));
        }