C/S开发框架新功能:批量更新业务单据的业务员、制单人制表人
C/S开发框架新功能:批量更新业务单据的业务员、制单人制表人
产品介绍
C/S系统开发框架旗舰版为软件团队提供强大的技术支撑以及快速开发能力,开发框架集成大量的通用开发包与工具实用类,提供丰富的例子,借助技术文档、网站资源、演示源码以及在线技术指导,用户能快速投入研发自己的项目。自2007年首发开发框架以来,我们成功积累了2000多位用户,其中包括数百家软件公司或大型集团企业。经过十年的产品迭代升级,最新旗舰版技术更成熟,性能更稳定,产出效率更高!
配套的代码生成器工具能自动生成界面(FORM)、业务层(BLL)、数据层(DAL)、模型(Model)、报表(Report)以及业务模块(Class Library DLL)的源代码,极大地提高开发效率、节约开发时间、降低项目成本。据多年项目实践统计,开发框架基本能完成项目大概60%以上的工作量。
业务员或系统操作人员(系统登录用户)离职后,需要把相关数据资料移交给其他同事维护,同时将原数据备份好,便于后期查阅历史数据。最近新开发以下两个功能给大家参考:
1. 批量更新用户
批量更新用户信息,对应业务单据的制单人、制表人,同时要更新最后修改人信息。
2. 批量更新业务员
批量更新业务单据的业务员资料,比如《报价单》、《采购单》、《销售单》等关联的业务员信息。
修改业务员:
《业务员管理》界面的扩展按钮:
C# Code:
public override void InitButtons()
{
base.InitButtons();
IButtonInfo btnUpdateSales = this.ToolbarRegister.CreateButton("btnUpdateSales",
"改业务员", ToolBarGroup.数据操作, Globals.LoadBitmap("32_Refresh.png"), new Size(57, 28), true, true, this.UpdateSales);
_buttons.AddButton(btnUpdateSales);
}
public virtual void UpdateSales(IButtonInfo sender)
{
this.AssertFocusedRow();
object sales = gvSummary.GetFocusedRowCellValue(colSalesCode);
frmSalesUpdate.Execute(sales);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
{
base.InitButtons();
IButtonInfo btnUpdateSales = this.ToolbarRegister.CreateButton("btnUpdateSales",
"改业务员", ToolBarGroup.数据操作, Globals.LoadBitmap("32_Refresh.png"), new Size(57, 28), true, true, this.UpdateSales);
_buttons.AddButton(btnUpdateSales);
}
public virtual void UpdateSales(IButtonInfo sender)
{
this.AssertFocusedRow();
object sales = gvSummary.GetFocusedRowCellValue(colSalesCode);
frmSalesUpdate.Execute(sales);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
DAL层:
C# Code:
public int SalesUpdate(string oldSales, string newSales)
{
CommandHelper cmd = _Database.CreateSqlProc("usp_UpdateSales");
cmd.AddParam("@OldSales", DbType.String, oldSales);
cmd.AddParam("@NewSales", DbType.String, newSales);
object o = _Database.ExecuteScalar(cmd.Command);
return ConvertEx.ToInt(o);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
{
CommandHelper cmd = _Database.CreateSqlProc("usp_UpdateSales");
cmd.AddParam("@OldSales", DbType.String, oldSales);
cmd.AddParam("@NewSales", DbType.String, newSales);
object o = _Database.ExecuteScalar(cmd.Command);
return ConvertEx.ToInt(o);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
SQL存储过程:
SQL Code:
USE [NN_OMS_Business]
GO
/****** Object: StoredProcedure [dbo].[usp_UpdateSales] Script Date: 09/16/2020 10:27:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_UpdateSales]
@OldSales VARCHAR(20), --旧业务员
@NewSales VARCHAR(20), --新业务员
@OperateUser VARCHAR(20)='' --当前操作用户,如:admin
AS
BEGIN
/******************************************************
程序说明:更改业务单据的业务员资料
-------------------------------------------------------
SELECT * FROM dbo.dt_Sales
SELECT * FROM NN_System.dbo.sys_LogOperation
-------------------------------------------------------
usp_UpdateSales 'admin','admin'
usp_UpdateSales 'admin','000'
usp_UpdateSales '000','admin'
*******************************************************/
DECLARE @MSG NVARCHAR(200)
--检查数据拥有者是否当前用户
IF ISNULL(@NewSales,'')='' OR @NewSales=@OldSales
BEGIN
SELECT @MSG='新业务员不能为空,并且不能与原有业务员相同!';
RAISERROR (@MSG,16,1);
RETURN;
END;
DECLARE @Count INT
UPDATE dbo.tb_QO SET Sales=@NewSales WHERE Sales=@OldSales
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PI SET Sales=@NewSales WHERE Sales=@OldSales
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_IV SET Sales=@NewSales WHERE Sales=@OldSales
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PF SET Sales=@NewSales WHERE Sales=@OldSales
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
--添加删除日志
INSERT INTO NN_System.dbo.sys_LogOperation(OperationType,OperationTime,Account,MSG)
SELECT 'Update',GETDATE(),@OperateUser,'变更《业务员》,旧:'+@OldSales+'新:'+@NewSales;
SELECT @Count AS UpdatedRows
END;
//来源:C/S框架网 | www.csframework.com | QQ:23404761
GO
/****** Object: StoredProcedure [dbo].[usp_UpdateSales] Script Date: 09/16/2020 10:27:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_UpdateSales]
@OldSales VARCHAR(20), --旧业务员
@NewSales VARCHAR(20), --新业务员
@OperateUser VARCHAR(20)='' --当前操作用户,如:admin
AS
BEGIN
/******************************************************
程序说明:更改业务单据的业务员资料
-------------------------------------------------------
SELECT * FROM dbo.dt_Sales
SELECT * FROM NN_System.dbo.sys_LogOperation
-------------------------------------------------------
usp_UpdateSales 'admin','admin'
usp_UpdateSales 'admin','000'
usp_UpdateSales '000','admin'
*******************************************************/
DECLARE @MSG NVARCHAR(200)
--检查数据拥有者是否当前用户
IF ISNULL(@NewSales,'')='' OR @NewSales=@OldSales
BEGIN
SELECT @MSG='新业务员不能为空,并且不能与原有业务员相同!';
RAISERROR (@MSG,16,1);
RETURN;
END;
DECLARE @Count INT
UPDATE dbo.tb_QO SET Sales=@NewSales WHERE Sales=@OldSales
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PI SET Sales=@NewSales WHERE Sales=@OldSales
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_IV SET Sales=@NewSales WHERE Sales=@OldSales
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PF SET Sales=@NewSales WHERE Sales=@OldSales
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
--添加删除日志
INSERT INTO NN_System.dbo.sys_LogOperation(OperationType,OperationTime,Account,MSG)
SELECT 'Update',GETDATE(),@OperateUser,'变更《业务员》,旧:'+@OldSales+'新:'+@NewSales;
SELECT @Count AS UpdatedRows
END;
//来源:C/S框架网 | www.csframework.com | QQ:23404761
修改用户、制单人、制表人:
《用户管理》界面的扩展按钮:
C# Code:
public override void InitButtons()
{
base.InitButtons();
if (ButtonAuthorized(ButtonAuthority.CLONE))
{
IButtonInfo btnCopyPermission = this.ToolbarRegister.CreateButton("btnCopyPermission", "复制权限", ToolBarGroup.扩展功能1,
Resources._2009011340768021, new Size(57, 28), true, true, this.DoCopyPermission);
_buttons.AddButton(btnCopyPermission);
IButtonInfo btnUpdateUser = this.ToolbarRegister.CreateButton("btnUpdateUser",
"更改用户", ToolBarGroup.数据操作, Globals.LoadBitmap("32_Refresh.png"), new Size(57, 28), true, true, this.UpdateUser);
_buttons.AddButton(btnUpdateUser);
}
}
private void UpdateUser(IButtonInfo sender)
{
this.AssertFocusedRow();
object user = gvSummary.GetFocusedRowCellValue(colAccount);
frmUserUpdate.Execute(user);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
{
base.InitButtons();
if (ButtonAuthorized(ButtonAuthority.CLONE))
{
IButtonInfo btnCopyPermission = this.ToolbarRegister.CreateButton("btnCopyPermission", "复制权限", ToolBarGroup.扩展功能1,
Resources._2009011340768021, new Size(57, 28), true, true, this.DoCopyPermission);
_buttons.AddButton(btnCopyPermission);
IButtonInfo btnUpdateUser = this.ToolbarRegister.CreateButton("btnUpdateUser",
"更改用户", ToolBarGroup.数据操作, Globals.LoadBitmap("32_Refresh.png"), new Size(57, 28), true, true, this.UpdateUser);
_buttons.AddButton(btnUpdateUser);
}
}
private void UpdateUser(IButtonInfo sender)
{
this.AssertFocusedRow();
object user = gvSummary.GetFocusedRowCellValue(colAccount);
frmUserUpdate.Execute(user);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
DAL层:
C# Code:
public int UpdateUser(string oldUser, string newUser)
{
IDatabase db = DatabaseProvider.GetDatabase(Loginer.CurrentUser.DBID);
CommandHelper cmd = db.CreateSqlProc("usp_UpdateCreateBy");
cmd.AddParam("@OldUser", DbType.String, oldUser);
cmd.AddParam("@NewUser", DbType.String, newUser);
cmd.AddParam("@OperateUser", DbType.String, Loginer.CurrentUser.Account);
object o = db.ExecuteScalar(cmd.Command);
return ConvertEx.ToInt(o);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
{
IDatabase db = DatabaseProvider.GetDatabase(Loginer.CurrentUser.DBID);
CommandHelper cmd = db.CreateSqlProc("usp_UpdateCreateBy");
cmd.AddParam("@OldUser", DbType.String, oldUser);
cmd.AddParam("@NewUser", DbType.String, newUser);
cmd.AddParam("@OperateUser", DbType.String, Loginer.CurrentUser.Account);
object o = db.ExecuteScalar(cmd.Command);
return ConvertEx.ToInt(o);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
SQL存储过程:
SQL Code:
USE [NN_OMS_Business]
GO
/****** Object: StoredProcedure [dbo].[usp_UpdateCreateBy] Script Date: 09/16/2020 10:29:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_UpdateCreateBy]
@OldUser VARCHAR(20), --旧用户
@NewUser VARCHAR(20), --新用户
@OperateUser VARCHAR(20)='' --当前操作用户,如:admin
AS
BEGIN
/******************************************************
程序说明:更改业务单据的制单人资料
-------------------------------------------------------
SELECT * FROM dbo.dt_Sales
SELECT * FROM NN_System.dbo.sys_LogOperation
-------------------------------------------------------
usp_UpdateCreateBy 'admin','admin'
usp_UpdateCreateBy '111','000'
usp_UpdateCreateBy '000','111'
*******************************************************/
DECLARE @MSG NVARCHAR(200)
--检查数据拥有者是否当前用户
IF ISNULL(@NewUser,'')='' OR @NewUser=@OldUser
BEGIN
SELECT @MSG='新用户不能为空,并且不能与原有用户相同!';
RAISERROR (@MSG,16,1);
RETURN;
END;
DECLARE @Count INT
--更新主表
UPDATE dbo.tb_QO SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
--更新明细表
UPDATE dbo.tb_QOs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PI SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PIs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_IV SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_IVs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PF SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PFs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PL SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PLs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PM SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PMs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PO SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_POs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
--添加删除日志
INSERT INTO NN_System.dbo.sys_LogOperation(OperationType,OperationTime,Account,MSG)
SELECT 'Update',GETDATE(),@OperateUser,'变更《制单人》,旧:'+@OldUser+'新:'+@NewUser;
SELECT @Count AS UpdatedRows
END;
//来源:C/S框架网 | www.csframework.com | QQ:23404761
GO
/****** Object: StoredProcedure [dbo].[usp_UpdateCreateBy] Script Date: 09/16/2020 10:29:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_UpdateCreateBy]
@OldUser VARCHAR(20), --旧用户
@NewUser VARCHAR(20), --新用户
@OperateUser VARCHAR(20)='' --当前操作用户,如:admin
AS
BEGIN
/******************************************************
程序说明:更改业务单据的制单人资料
-------------------------------------------------------
SELECT * FROM dbo.dt_Sales
SELECT * FROM NN_System.dbo.sys_LogOperation
-------------------------------------------------------
usp_UpdateCreateBy 'admin','admin'
usp_UpdateCreateBy '111','000'
usp_UpdateCreateBy '000','111'
*******************************************************/
DECLARE @MSG NVARCHAR(200)
--检查数据拥有者是否当前用户
IF ISNULL(@NewUser,'')='' OR @NewUser=@OldUser
BEGIN
SELECT @MSG='新用户不能为空,并且不能与原有用户相同!';
RAISERROR (@MSG,16,1);
RETURN;
END;
DECLARE @Count INT
--更新主表
UPDATE dbo.tb_QO SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
--更新明细表
UPDATE dbo.tb_QOs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PI SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PIs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_IV SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_IVs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PF SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PFs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PL SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PLs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PM SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_PMs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
UPDATE dbo.tb_PO SET CreatedBy=@NewUser,LastUpdatedBy=@NewUser WHERE CreatedBy=@OldUser
SELECT @Count=ISNULL(@Count,0)+@@ROWCOUNT;
UPDATE dbo.tb_POs SET LastUpdatedBy=@NewUser WHERE LastUpdatedBy=@OldUser
--添加删除日志
INSERT INTO NN_System.dbo.sys_LogOperation(OperationType,OperationTime,Account,MSG)
SELECT 'Update',GETDATE(),@OperateUser,'变更《制单人》,旧:'+@OldUser+'新:'+@NewUser;
SELECT @Count AS UpdatedRows
END;
//来源:C/S框架网 | www.csframework.com | QQ:23404761
C/S系统快速开发框架旗舰版V5.0(Ultimate Edition)
适用开发:制造、服务、零售、商贸等行业的ERP、MRP、MES、CRM、MIS、HIS、POS数据管理应用系统
运行平台:Windows + .NET Framework 4.5
开发工具:Visual Studio 2015+,C#语言
数据库:Microsoft SQLServer 2008R2+(支持多数据库:Oracle/MySql)
运行平台:Windows + .NET Framework 4.5
开发工具:Visual Studio 2015+,C#语言
数据库:Microsoft SQLServer 2008R2+(支持多数据库:Oracle/MySql)
产品介绍
C/S系统开发框架旗舰版为软件团队提供强大的技术支撑以及快速开发能力,开发框架集成大量的通用开发包与工具实用类,提供丰富的例子,借助技术文档、网站资源、演示源码以及在线技术指导,用户能快速投入研发自己的项目。自2007年首发开发框架以来,我们成功积累了2000多位用户,其中包括数百家软件公司或大型集团企业。经过十年的产品迭代升级,最新旗舰版技术更成熟,性能更稳定,产出效率更高!
配套的代码生成器工具能自动生成界面(FORM)、业务层(BLL)、数据层(DAL)、模型(Model)、报表(Report)以及业务模块(Class Library DLL)的源代码,极大地提高开发效率、节约开发时间、降低项目成本。据多年项目实践统计,开发框架基本能完成项目大概60%以上的工作量。
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网