WinFramework轻量级开发框架 - 主从表窗体开发指南-采购订单
C/S结构快速开发框架/软件快速开发平台
WinFrameworkV2.1轻量级框架
原创软件@csframework.com
目录
一、数据库新建表
- 主表:tb_PO
- 明细表:tb_PODetail
1.1 tb_PO主表SQL脚本
CREATE TABLE [dbo].[tb_PO](
[isid] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[DocNo] [varchar](20) NOT NULL,
[DocDate] [date] NULL,
[SupplierID] [varchar](20) NULL,
[SupplierName] [nvarchar](50) NULL,
[SupplierAddress] [nvarchar](200) NULL,
[SupplierPhone] [varchar](50) NULL,
[FromAddress] [nvarchar](200) NULL,
[TotalAmount] [decimal](18, 2) NULL,
[PayType] [varchar](10) NULL,
[Remark] [nvarchar](200) NULL,
[DocType] [int] NULL,
[CreateUser] [varchar](20) NULL,
[CreateDate] [datetime] NULL,
[LastUpdateUser] [varchar](20) NULL,
[LastUpdateDate] [datetime] NULL,
CONSTRAINT [PK_TB_PO] PRIMARY KEY CLUSTERED
(
[DocNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自增列' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'isid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单据编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'DocNo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单据日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'DocDate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'供应商编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'SupplierID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'供应商名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'SupplierName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'供应商地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'SupplierAddress'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'SupplierPhone'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提货地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'FromAddress'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'总金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'TotalAmount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'结算方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'PayType'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'Remark'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态 0:挂起 1:提交 -1:废弃' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'DocType'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'CreateUser'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'CreateDate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后修改人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'LastUpdateUser'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后修改时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO', @level2type=N'COLUMN',@level2name=N'LastUpdateDate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采购入库单' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PO'
GO
1.2 tb_PODetail明细表SQL脚本
CREATE TABLE [dbo].[tb_PODetail](
[isid] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[DocNo] [varchar](20) NULL,
[ProductID] [varchar](20) NULL,
[JZS] [int] NULL,
[Unit] [varchar](10) NULL,
[SPID] [varchar](20) NULL,
[Qty] [decimal](18, 2) NULL,
[Price] [decimal](18, 2) NULL,
[Amount] [decimal](18, 2) NULL,
[Remark] [nvarchar](200) NULL,
[CreateUser] [varchar](20) NULL,
[CreateDate] [datetime] NULL,
[LastUpdateUser] [varchar](20) NULL,
[LastUpdateDate] [datetime] NULL,
CONSTRAINT [PK_TB_PODETAIL] PRIMARY KEY CLUSTERED
(
[isid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自增列' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'isid'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单据编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'DocNo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'产品编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'ProductID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'件/支数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'JZS'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'Unit'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仓位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'SPID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'Qty'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单价' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'Price'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'Amount'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'Remark'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'CreateUser'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'CreateDate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后修改人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'LastUpdateUser'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后修改时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail', @level2type=N'COLUMN',@level2name=N'LastUpdateDate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采购入库明细' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_PODetail'
GO
二、代码生成器生成代码
选中要生成Model的表,然后点击下方的 添加 按钮,就能标记表为生成状态(打勾)。
若选错或要取消表:右键表,弹出菜单中选择排除即可。
2.1 生成主表Model代码
选择tb_PO表,点【添加】按钮,具体设置如下,主键:DocNo
2.2 生成明细表Model代码
选择tb_PODetail表,点【添加】按钮,具体设置如下,主键:isid,外键:DocNo
生成的Model层代码2个cs文件:
2.3 复制cs文件到项目Model层
2.4 生成窗体
选择主表 tb_PO,配置参考,注意主表的主键【仅新增编辑】打勾。
添加明细表 选择 tb_PODetail ,然后选择添加明细按钮
明细表配置如下:
BLL/Form体信息配置如下:
生成后得到3个文件:
BLLDemo_PO.cs源码为窗体业务bll层代码。
复制bll层代码到项目 WinFrameworkDemo.Business 中。
复制窗体代码:frmPO.cs 和 frmPO.designer.cs 到项目 WinframeworkDemo.Test 中。
若出现报错,添加缺失的命名空间即可:
三、功能注册
3.1 修改Management.cs 文件
打开 WinframeworkDemo.Test.Management.cs 文件,添加新窗体 frmPO :
namespace WinframeworkDemo.Test
{
public class Management : WinFramework.Library.Module
{
public Management() : base("开发演示模块", "Module_Dictionary")
{
// 注册功能
FunctionCollection.AddFunction(typeof(frmPO), "采购单", "Function_PO");
}
}
}
四、运行项目,导入模块
现在运行项目,在业务模块中是看不到我们添加的功能的,需要导入。
操作:运行程序,系统管理 → 模块维护:
看到我们新增的功能后,点击操作区域中的保存按钮:
更新模块信息后,要 重新登录 系统,重新登录后,就看到了我们添加的功能:
五、调整界面UI
5.1 调整【数据查询】页面的表格布局
5.2 调整【数据编辑】页面的表格布局
代码生成器生成的界面比较乱,特别是编辑页面,这样我们要调整界面的布局:
我们需要手动调整,调整后:
<本文完>
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
WinFramework C/S框架网