CSFrameworkV6|主从表基础资料窗体扩展【复制】按钮|C/S开发框架
作者:csframework|C/S框架网  发布日期:2023/08/03 12:44:24

1、增加【复制】按钮

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

            //_buttons.RemoveButton(ButtonNameList.btnRefreshDataDict);

            if (this.ButtonAuthorized(ButtonAuthority.CLONE))
            {
                var button = this.ToolbarRegister.CreateButton(ButtonNameList.btnClone,
                     "复制", ToolBarGroup.审核功能, Globals.LoadBitmap("32_Clone.png"),
                     new Size(57, 28), true, true, this.DoClone);
                _buttons.AddButton(button);
            }

        }

2、实现DoClone 事件

C# 全选
        /// <summary>
        /// 复制、克隆
        /// </summary>
        /// <param name="sender"></param>
        public void DoClone(IButtonInfo sender)
        {
            this.AssertFocusedRow();

            //获取最新数据
            this.DoViewContent(_buttons.GetButtonByName(ButtonNameList.btnView));

            //清空主表主键
            this.SetEditorBindingValue(txtCartonCode, null, true);
            _BLL.DataBinder.CartonCode = string.Empty;
            _BLL.DataBinder.isid = Globals.NewSnowflakeID();//新的主键id

            //重置图片主外键
            if (_CurrentImageData != null)
            {
                _CurrentImageData.isid = string.Empty;//产品图片,置空值为新增图片
                _CurrentImageData.DocNo = string.Empty;
                _CurrentImageData.MasterDocNo = string.Empty;
            }

            //重置明细表的主外键
            gvMaterialsFormula.GetDataSource<dt_CartonMaterialsFormula>()
                .ForEach(i =>
                {
                    i.isid = string.Empty;
                    i.CartonCode = string.Empty;
                });

            gvProcessSettings.GetDataSource<dt_CartonProcessSettings>()
                .ForEach(i =>
                {
                    i.isid = string.Empty;
                    i.CartonCode = string.Empty;
                });

            gvSpecConvert.GetDataSource<dt_CartonSpecConvert>()
                .ForEach(i =>
                {
                    i.isid = string.Empty;
                    i.CartonCode = string.Empty;
                });

            gvWrapQtySettings.GetDataSource<dt_CartonWrapQtySettings>()
            .ForEach(i =>
            {
                i.isid = string.Empty;
                i.CartonCode = string.Empty;
            });

            //设置为新增状态
            this._UpdateType = UpdateType.Add;
            this.SetEditMode();
            this.ButtonStateChanged(_UpdateType);
            this.ShowDetailPage(true);

            Msg.ShowInformation("复制资料成功,请补充资料后保存!");
        }

3、测试

CSFrameworkV6|主从表基础资料窗体扩展【复制】按钮|C/S开发框架

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


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