예제 #1
0
        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.AssetsName       = DataConvert.ToString(dr["assetsName"]);
                assetsMerge.AssetsValue      = DataConvert.ToString(dr["assetsValue"]);
                assetsMerge.OriginalAssetsId = DataConvert.ToString(dr["originalAssetsId"]);
                if (rowIndex == 0)
                {
                    AddNewAssets(assetsMerge, sysUser, viewTitle);
                }
                UpdateAssetsState(assetsMerge.OriginalAssetsId, "M", sysUser.UserId, viewTitle);
                rowIndex++;
            }
            return(1);
        }
예제 #2
0
        protected int AddNewAssets(AssetsMerge assetsMerge, UserInfo 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];
            }
            double assetsValueOri    = DataConvert.ToDouble(dtAssets.Rows[0]["assetsValue"]);
            double assetsNetValueOri = DataConvert.ToDouble(dtAssets.Rows[0]["assetsNetValue"]);

            drNew["assetsId"]       = assetsMerge.AssetsId;
            drNew["assetsNo"]       = assetsMerge.AssetsNo;
            drNew["assetsName"]     = assetsMerge.AssetsName;
            drNew["assetsValue"]    = assetsMerge.AssetsValue;
            drNew["assetsNetValue"] = assetsValueOri == 0 ? 0 : DataConvert.ToDouble(assetsMerge.AssetsValue) * assetsNetValueOri / assetsValueOri;
            drNew["remark"]         = assetsMerge.Remark;
            drNew["assetsState"]    = "A";
            drNew["setBooksId"]     = sysUser.MySetBooks.SetBooksId;
            drNew["addDate"]        = IdGenerator.GetServerDate();
            drNew["smDate"]         = DBNull.Value;
            dtAssets.Rows.Add(drNew);
            Create5Field(dtAssets, sysUser.UserId, viewTitle);
            return(DbUpdate.Update(dtAssets));
        }
예제 #3
0
        protected override int Add(EntryViewModel model, 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, "", sysUser.UserId);
            EntryModel myModel       = model as EntryModel;

            dr["assetsMergeNo"]   = myModel.AssetsMergeNo;
            dr["assetsMergeName"] = myModel.AssetsMergeName;
            string updateType = "Add";

            if (retApprove != 0)
            {
                dr["approveState"] = "O";
                updateType         = "ApproveAdd";
            }
            dr["AssetsMergeId"] = assetsMergeId;
            dr["setBooksId"]    = sysUser.MySetBooks.SetBooksId;
            dt.Rows.Add(dr);
            Create5Field(dt, sysUser.UserId, viewTitle);
            DbUpdate.Update(dt);
            List <AssetsMerge> gridData    = JsonHelper.JSONStringToList <AssetsMerge>(DataConvert.ToString(myModel.EntryGridString));
            AssetsMerge        assetsMerge = gridData[0];

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

            foreach (AssetsMerge originalAssetsMerge in upGridData)
            {
                AddDetail(assetsMerge, originalAssetsMerge, assetsMergeId, sysUser, viewTitle, updateType);
                if (retApprove == 0)
                {
                    UpdateAssetsState(originalAssetsMerge.AssetsId, "M", sysUser.UserId, viewTitle);
                }
                else
                {
                    UpdateAssetsState(originalAssetsMerge.AssetsId, "MI", sysUser.UserId, viewTitle);
                }
            }
            if (retApprove == 0)
            {
                AddNewAssets(assetsMerge, sysUser, viewTitle);
            }
            return(1);
        }
예제 #4
0
        protected int AddDetail(AssetsMerge AssetsMerge, AssetsMerge OriginalAssetsMerge, string AssetsMergeId, UserInfo sysUser, string viewTitle, string updateType)
        {
            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;
            dr["setBooksId"]       = sysUser.MySetBooks.SetBooksId;
            dt.Rows.Add(dr);
            if (DataConvert.ToString(OriginalAssetsMerge.CreateId) != "")
            {
                if (updateType == "Reapply")
                {
                    dr["approveState"] = "O";
                }
                else
                {
                    dr["approveState"] = OriginalAssetsMerge.ApproveState;
                }
                dr["createId"]   = OriginalAssetsMerge.CreateId;
                dr["createTime"] = OriginalAssetsMerge.CreateTime;
                Update5Field(dt, sysUser.UserId, viewTitle);
            }
            else
            {
                if (updateType == "ApproveAdd")
                {
                    dr["approveState"] = "O";
                }
                Create5Field(dt, sysUser.UserId, viewTitle);
            }
            return(DbUpdate.Update(dt));
        }
예제 #5
0
        protected override int Modified(EntryViewModel model, 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"]);
            EntryModel myModel       = model as EntryModel;

            dt.Rows[0]["assetsMergeNo"]   = myModel.AssetsMergeNo;
            dt.Rows[0]["assetsMergeName"] = myModel.AssetsMergeName;
            string updateType = "Modified";

            if (formMode == "reapply")
            {
                dt.Rows[0]["approveState"] = "O";
                updateType = "Reapply";
            }
            Update5Field(dt, sysUser.UserId, viewTitle);
            DbUpdate.Update(dt);
            DeleteDetail(pkValue, sysUser, viewTitle);
            List <AssetsMerge> gridData    = JsonHelper.JSONStringToList <AssetsMerge>(DataConvert.ToString(myModel.EntryGridString));
            AssetsMerge        AssetsMerge = gridData[0];
            List <AssetsMerge> upGridData  = JsonHelper.JSONStringToList <AssetsMerge>(DataConvert.ToString(myModel.UpEntryGridString));

            foreach (AssetsMerge OriginalAssetsMerge in upGridData)
            {
                AddDetail(AssetsMerge, OriginalAssetsMerge, pkValue, sysUser, viewTitle, updateType);
            }
            if (formMode == "reapply")
            {
                InitFirstApproveTask("AssetsMerge", "AssetsMergeId", AssetsMergeId, viewTitle, formMode, sysUser.UserId);
            }
            return(1);
        }