CSFrameworkV6-主从表基础资料窗体扩展【复制】按钮
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、测试
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网