abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理一 (十九)
abp(net core)+easyui+efcore实现仓储管理系统目录
abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一)
abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二)
abp(net core)+easyui+efcore实现仓储管理系统——领域层创建实体(三)
abp(net core)+easyui+efcore实现仓储管理系统——定义仓储并实现 (四)
abp(net core)+easyui+efcore实现仓储管理系统——创建应用服务(五)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之增删改视图(八)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九)
abp(net core)+easyui+efcore实现仓储管理系统——多语言(十)
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一)
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十二)
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十三)
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十四)
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十五)
abp(net core)+easyui+efcore实现仓储管理系统——菜单-上 (十六)
abp(net core)+easyui+efcore实现仓储管理系统——菜单-下(十七)
通过上一篇(abp(net core)+easyui+efcore实现仓储管理系统——EasyUI前端页面框架 (十八) )文章,我们已经将EasyUI添加到我们的项目中了。下面我们通过EasyUI做为前端页面的UI控件来展现一个货物信息管理的前端功能,并使用创建相应的实体类,服务类等来实现后台功能。
四、创建Cargo实体
1. 在Visual Studio 2017的“解决方案资源管理器”中,右键单击“ABP.TPLMS.Core”项目的“Entitys”文件夹,在弹出菜单中选择“添加” >
> “类”。 将类命名为 Cargo,然后选择“添加”。
2.创建Cargo类继承自Entity<int>,通过实现审计模块中的IHasCreationTime来实现保存创建时间。代码如下:
using Abp.Domain.Entities; using Abp.Domain.Entities.Auditing; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text; namespace ABP.TPLMS.Entitys { public class Cargo : Entity<int>, IHasCreationTime { public Cargo() { this.Id = 0; this.SupplierId = 0; this.CargoCode = string.Empty; this.CargoName = string.Empty; this.Brand = string.Empty; this.Country = string.Empty; this.CreationTime = DateTime.Now; this.Curr = string.Empty; this.GrossWt = 0; this.Height = 0; this.HSCode = string.Empty; this.Length = 0; this.MaxNum = 100; this.MinNum = 0; this.NetWt = 0; this.Package = string.Empty; this.Price = 0; this.Remark = string.Empty; this.Spcf = string.Empty; this.Unit = string.Empty; this.UpdateTime = DateTime.Now; this.UpdOper = string.Empty; this.Vol = 0; this.Width = 0; } public int SupplierId { get; set; } [StringLength(50)] public string CargoCode { get; set; } [StringLength(10)] public string HSCode { get; set; } [StringLength(250)] public string CargoName { get; set; } [StringLength(512)] public string Spcf { get; set; } public string Unit { get; set; } public string Country { get; set; } public string Brand { get; set; } public string Curr { get; set; } public string Package { get; set; } public decimal Length { get; set; } public decimal Width { get; set; } public decimal Height { get; set; } public decimal Vol { get; set; } public decimal MinNum { get; set; } public decimal MaxNum { get; set; } public decimal Price { get; set; } public decimal GrossWt { get; set; } public decimal NetWt { get; set; } public string Remark { get; set; } public DateTime CreationTime { get; set; } public DateTime UpdateTime { get; set; } public string UpdOper { get; set; } } }
3.定义好实体之后,我们去“ABP.TPLMS.EntityFrameworkCore”项目中的“TPLMSDbContext”类中定义实体对应的DbSet,以应用Code First 数据迁移。添加以下代码
using Microsoft.EntityFrameworkCore; using Abp.Zero.EntityFrameworkCore; using ABP.TPLMS.Authorization.Roles; using ABP.TPLMS.Authorization.Users; using ABP.TPLMS.MultiTenancy; using ABP.TPLMS.Entitys; namespace ABP.TPLMS.EntityFrameworkCore { public class TPLMSDbContext : AbpZeroDbContext<Tenant, Role, User, TPLMSDbContext> { /* Define a DbSet for each entity of the application */ public TPLMSDbContext(DbContextOptions<TPLMSDbContext> options) : base(options) { } public DbSet<Module> Modules { get; set; } public DbSet<Supplier> Suppliers { get; set; } public DbSet<Cargo> Cargos { get; set; } } }
4.从菜单中选择“工具->NuGet包管理器器—>程序包管理器控制台”菜单。
5. 在PMC中,默认项目选择EntityframeworkCore对应的项目后。输入以下命令:Add-Migration AddEntityCargo,创建迁移。
6. 在上面的命令执行完毕之后,创建成功后,会在Migrations文件夹下创建时间_AddEntityCargo格式的类文件,这些代码是基于DbContext指定的模型。如下图。
7.在程序包管理器控制台,输入Update-Database,回车执行迁移。执行成功后,如下图。
8. 在SQL Server Management Studio中查看数据库,Cargos表创建成功。
五、定义应用服务接口需要用到的分页类
为了在进行查询时使用, PagedCargoResultRequestDto被用来将货物查询条件的数据传递到给应用层.
1. 在Visual Studio 2017的“解决方案资源管理器”中,右键单击“ABP.TPLMS.Application”项目,在弹出菜单中选择“添加” > “新建文件夹”,并重命名为“Cargos”
2. 使用鼠标右键单击我们刚才创建的“Cargos”文件夹,在弹出菜单中选择“添加” > “新建文件夹”,并重命名为“Dto”。
3.右键单击“Dto”文件夹,然后选择“添加” > “类”。 将类命名为 Paged CargoResultRequestDto,然后选择“添加”。代码如下。
using Abp.Application.Services.Dto; using System; using System.Collections.Generic; using System.Text; namespace ABP.TPLMS.Cargos.Dto { public class PagedCargoResultRequestDto : PagedResultRequestDto { public string Keyword { get; set; } } }
4.右键单击“Dto”文件夹,然后选择“添加” > “类”。 将类命名为 CargoDto,然后选择“添加”。代码如下。
using Abp.Application.Services.Dto; using Abp.AutoMapper; using ABP.TPLMS.Entitys; using System; using System.Collections.Generic; using System.Text; namespace ABP.TPLMS.Cargos.Dto { [AutoMapFrom(typeof(Cargo))] public class CargoDto:EntityDto<int> { public int SupplierId { get; set; } public string CargoCode { get; set; } public string HSCode { get; set; } public string CargoName { get; set; } public string Spcf { get; set; } public string Unit { get; set; } public string Country { get; set; } public string Brand { get; set; } public string Curr { get; set; } public string Package { get; set; } public decimal Length { get; set; } public decimal Width { get; set; } public decimal Height { get; set; } public decimal Vol { get; set; } public decimal MinNum { get; set; } public decimal MaxNum { get; set; } public decimal Price { get; set; } public decimal GrossWt { get; set; } public decimal NetWt { get; set; } public string Remark { get; set; } public DateTime CreationTime { get; set; } public DateTime UpdateTime { get; set; } public string UpdOper { get; set; } } }
5.右键单击“Dto”文件夹,然后选择“添加” > “类”。 将类命名为 CreateUpdateCargoDto,然后选择“添加”。代码如下。
using Abp.Application.Services.Dto; using Abp.AutoMapper; using ABP.TPLMS.Entitys; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Text; namespace ABP.TPLMS.Cargos.Dto { [AutoMapTo(typeof(Cargo))] public class CreateUpdateCargoDto : EntityDto<int> { public int SupplierId { get; set; } [StringLength(50)] public string CargoCode { get; set; } [StringLength(10)] public string HSCode { get; set; } [StringLength(250)] public string CargoName { get; set; } [StringLength(512)] public string Spcf { get; set; } [StringLength(20)] public string Unit { get; set; } [StringLength(20)] public string Country { get; set; } [StringLength(50)] public string Brand { get; set; } [StringLength(20)] public string Curr { get; set; } [StringLength(50)] public string Package { get; set; } public decimal Length { get; set; } public decimal Width { get; set; } public decimal Height { get; set; } public decimal Vol { get; set; } public decimal MinNum { get; set; } public decimal MaxNum { get; set; } public decimal Price { get; set; } public decimal GrossWt { get; set; } public decimal NetWt { get; set; } [StringLength(2048)] public string Remark { get; set; } public DateTime CreationTime { get; set; } public DateTime UpdateTime { get; set; } [StringLength(50)] public string UpdOper { get; set; } } }
原文地址:https://www.cnblogs.com/chillsrc/p/11573043.html
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Python字符串操作大全
- Cypress系列(64)- 数据驱动策略
- 别只会搜日志了,求你懂点原理吧
- Cypress系列(65)- 测试运行失败自动重试
- CentOS7下编译FFMPEG源代码
- Android 的 Presentation 双屏异显,遇到的问题总结
- 音视频相关开发库和资料
- Flink深入浅出: 应用部署与原理图解(v1.11)
- 用 Github Actions 在 K8S 中运行 CI 测试
- 线程池的拒绝策略
- 15 张图带你深入理解浮点数
- 用Python实现坦克大战游戏 | 干货贴
- hexo搭建个人网站博客完全教程
- 快速入门 Python 数据库操作
- Shell脚本管道符与重定向