CSFrameworkV6旗舰版 | 业务单据复制功能,支持复制多级明细表|C/S开发框架
作者:csframework|C/S框架网  发布日期:2023/08/03 12:45:37

CSFrameworkV6旗舰版 | 业务单据复制功能,支持复制多级明细表|C/S开发框架

CSFrameworkV6旗舰版 - 业务单据复制功能,支持复制多级明细表

一、复制多级明细表业务单据

添加一个复制按钮

C# 全选
 public override void InitButtons()
        {
            base.InitButtons();

            //复制单据
            if (this.ButtonAuthorized(ButtonAuthority.ADD))
            {
                IButtonInfo btnClone = this.ToolbarRegister.CreateButton(ButtonNameList.btnClone, "复制单据", ToolBarGroup.扩展功能1,
                  Globals.LoadBitmap("32_Copy.png"), new Size(57, 28), true, true, this.DoClone);
                _buttons.AddButton(btnClone);
            }
        }

复制单据逻辑

C# 全选
        public virtual void DoClone(IButtonInfo sender)
        {
            this.AssertFocusedRow();

            //获取当前单据
            this.DoViewContent(this.Buttons.GetButtonByName(ButtonNameList.btnView));

            Hashtable hash = new Hashtable();

            if (this.IsViewMode)
            {
                //重置主表的数据
                SetEditorBindingValue(txtSONO, "*自动生成*", true);
                _BLL.DataBinder.isid = IdHelper.GetId();
                _BLL.DataBinder.DocDate = DateTime.Today;
                _BLL.DataBinder.FlagApp = "N";
                _BLL.DataBinder.AppUser = "";
                _BLL.DataBinder.AppDate = null;
                _BLL.DataBinder.CreatedBy = Loginer.CurrentUser.Account;
                _BLL.DataBinder.CreationDate = DateTime.Now;

                //重置明细表的数据 - 订单明细表
                foreach (var R in _BLL.CurrentBusiness.SOs)
                {
                    //生成新的isid, 这里需要存起来,因为SOs表的isid作为主键,有多个明细表关联isid
                    hash[R.isid] = IdHelper.GetId();
                    R.isid = hash[R.isid] as String;
                    R.SONO = DBNull.Value.ToString();//清空外键
                    R.CreatedBy = Loginer.CurrentUser.Account;
                    R.CreationDate = DateTime.Now;
                }

                //用料表
                foreach (var R in _BLL.CurrentBusiness.SOsMaterials)
                {
                    R.isid = IdHelper.GetId();
                    R.Detail_isid = hash[R.Detail_isid] as String; //获取最新外键值
                    R.SONO = DBNull.Value.ToString();//清空外键
                    R.CreatedBy = Loginer.CurrentUser.Account;
                    R.CreationDate = DateTime.Now;
                }

                //工序表
                foreach (var R in _BLL.CurrentBusiness.SOsProcess)
                {
                    R.isid = IdHelper.GetId();
                    R.Detail_isid = hash[R.Detail_isid] as String; //获取最新外键值
                    R.SONO = DBNull.Value.ToString();//清空外键
                    R.CreatedBy = Loginer.CurrentUser.Account;
                    R.CreationDate = DateTime.Now;
                }

                //成本表
                foreach (var R in _BLL.CurrentBusiness.SOsCost)
                {
                    R.isid = IdHelper.GetId();
                    R.Detail_isid = hash[R.Detail_isid] as String; //获取最新外键值
                    R.SONO = DBNull.Value.ToString();//清空外键
                    R.CreatedBy = Loginer.CurrentUser.Account;
                    R.CreationDate = DateTime.Now;
                }

                //成本表
                foreach (var R in _BLL.CurrentBusiness.SOsCostCompare)
                {
                    R.isid = IdHelper.GetId();
                    R.Detail_isid = hash[R.Detail_isid] as String; //获取最新外键值
                    R.SONO = DBNull.Value.ToString();//清空外键
                    R.CreatedBy = Loginer.CurrentUser.Account;
                    R.CreationDate = DateTime.Now;
                }

                //唛头图片表
                foreach (var R in _BLL.CurrentBusiness.SOsLogoFiles)
                {
                    R.FileID = IdHelper.GetId();
                    R.DocID = DBNull.Value.ToString();//清空外键                    
                    R.RowISID= hash[R.RowISID] as String; //获取最新外键值
                }

                //以下处理多个明细表
                _UpdateType = UpdateType.Add;
                this.SetEditMode();
                this.ButtonStateChanged(UpdateType.Add);
            }
        }

CSFrameworkV6旗舰版 | 业务单据复制功能,支持复制多级明细表|C/S开发框架

二、复制普通主从表业务单据

添加一个复制按钮

C# 全选
        public override void DoClone(IButtonInfo sender)
        {
            this.AssertFocusedRow();

            //获取当前单据
            this.DoViewContent(this.Buttons.GetButtonByName(ButtonNameList.btnView));

            if (this.IsViewMode)
            {
                //重置主表的数据
                SetEditorBindingValue(txtSONO, "*自动生成*", true);
                _BLL.DataBinder.isid = IdHelper.GetId();
                _BLL.DataBinder.ReceiveDay = DateTime.Today;
                _BLL.DataBinder.FlagApp = "N";
                _BLL.DataBinder.AppUser = "";
                _BLL.DataBinder.AppDate = null;
                _BLL.DataBinder.CreatedBy = Core.Loginer.CurrentUser.Account;
                _BLL.DataBinder.CreationDate = DateTime.Now;

                //重置明细表的数据
                foreach (var R in _BLL.CurrentBusiness.Details)
                {
                    R.isid = IdHelper.GetId();
                    R.SONO = DBNull.Value.ToString();//清空外键
                    R.CreatedBy = Core.Loginer.CurrentUser.Account;
                    R.CreationDate = DateTime.Now;
                }

                //以下处理多个明细表
                _UpdateType = UpdateType.Add;
                this.SetEditMode();
                this.ButtonStateChanged(UpdateType.Add);
            }
        }

C/S框架网|原创精神.创造价值.打造精品


扫一扫加作者微信
C/S框架网作者微信 C/S框架网|原创作品.质量保障.竭诚为您服务
上一篇 下一篇