复制单据及扩展按钮功能
作者:C/S框架网  发布日期:2016-10-23 16:28:52
  复制单据及扩展按钮功能




1. 扩展功能按钮

2. 复制单据


在模块主窗体给菜单添加扩展权限,如: ButtonAuthority.EX_01。
给扩展权限定义名称:如:复制单据。

调试完毕,在系统管理的《菜单管理》导入菜单权限!!!!

参考下面的代码:

C# Code:

menuSalesOrder.Tag = new MenuItemTag(MenuType.DataForm, (int)CSFrameworkV5.Interfaces.ModuleID.SalesModule, AuthorityCategory.BUSINESS_ACTION_VALUE + ButtonAuthority.EX_01);

C/S框架网 www.cscode.net 2018/7/19 13:51:47
(menuSalesOrder.Tag as MenuItemTag).SetActionName(ButtonAuthority.EX_01, "复制单据");


//来源:C/S框架网(www.csframework.com) QQ:23404761




C# Code:


protected override void SetViewMode()
{
   base.SetViewMode();
   this.Buttons.GetButtonByName("btnClone").Enable = true;
}

protected override void SetEditMode()
{
   base.SetEditMode();
   this.Buttons.GetButtonByName("btnClone").Enable = false;
}

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

public void DoClone(IButtonInfo sender)
{
   this.AssertFocusedRow();
   
   if (Msg.AskQuestion("确定要复制单据吗?"))
   {
      //获取当前单据
      this.DoViewContent(this.Buttons.GetButtonByName(ButtonNameList.btnView));
      
      if (this.IsViewMode)
      {
         //重置主表的数据
         _BLLInstance.DataBindRow.SetAdded();//改为新增状态
         
         SetEditorBindingValue(txtSONO, "*自动生成*", true);
         _BLLInstance.DataBindRow[tb_SO.CreatedBy] = Loginer.CurrentUser.Account;
         _BLLInstance.DataBindRow[tb_SO.CreationDate] = DateTime.Now;
         
         //重置明细表的数据
         foreach (DataRow R in _BLLInstance.CurrentBusiness.Tables[tb_SOs.__TableName].Rows)
         {
            R.SetAdded();//改为新增状态
            
            R[tb_SOs.SONO] = DBNull.Value;//清空外键
            R[tb_SOs.CreatedBy] = Loginer.CurrentUser.Account;
            R[tb_SOs.CreationDate] = DateTime.Now;
         }
         
         //
         //以下处理多个明细表
         //
         _UpdateType = UpdateType.Add;
         this.SetEditMode();
         this.ButtonStateChanged(UpdateType.Add);
      }
   }
}

//来源:C/S框架网(www.csframework.com) QQ:1980854898





贴图图片
上一篇 下一篇