abp (net core) + easyui + efcore implement warehouse management system --ABP WebAPI one of CRUD (xxvii) in conjunction with EasyUI

abp (net core) + easyui + efcore implement warehouse management system directory

abp (net core) + easyui + efcore implement warehouse management system --ABP general introduction (a)

abp (net core) + easyui + efcore implement Warehouse Management System - Solutions Introduction (b)

abp (net core) + easyui + efcore implement warehouse management system - the domain layer created entity (c)

 abp (net core) + easyui + efcore implement warehouse management system - Define and implement storage (IV)

abp (net core) + easyui + efcore implement Warehouse Management System - Create application services (five)

abp (net core) + easyui + efcore implemented warehouse management system - to achieve the presentation layer of the CRUD controller (vi)

abp (net core) + easyui + efcore implement Warehouse Management System - the presentation layer to achieve CRUD the list view (seven)

abp (net core) + easyui + efcore implement Warehouse Management System - the presentation layer to achieve the CRUD CRUD view (eight)

abp (net core) + easyui + efcore implement Warehouse Management System - Multilingual (X)

abp (net core) + easyui + efcore implemented Warehouse Management System - WEBAPI implemented CURD (XI)

abp (net core) + easyui + efcore implement Warehouse Management System - menu - on (XVI)

abp (net core) + easyui + efcore implement warehouse management system --EasyUI front page frame (XVIII)

Cargo abp (net core) + easyui + efcore implement Warehouse Management System --EasyUI of a management (XIX)

 

I. Introduction

       By previous article goods abp (net core) + easyui + efcore implement Warehouse Management System --EasyUI of a management (XIX) to goods abp (net core) + easyui + efcore implement Warehouse Management System --EasyUI management of eight ( 26) study, we have realized the traditional ASP.NET Core MVC + EasyUI CRUD functionality. In this article we want to achieve the use of ABP provides WebAPI + EasyUI way to implement CRUD functionality. In this article we will not use the DataGrid control table, but the use of a tree form (TreeGrid) controls.

Second, the tree form (TreeGrid) Introduction

       I was first on the map, let us look at the organization and management information list page after the function is completed. As shown below.

       The organization and management of a list of pages using TreeGrid to achieve. We then introduce TreeGrid.

     First, when there are two attributes must be defined TreeGrid one idField, this should be unique; treeField other is defined, which is the value of the tree nodes, must have. 

     Secondly, easyui loaded treegrid json data format of three, I will introduce my favorite this. The other two methods, see easyui documentation.

  {"total":7,"rows":[

           {"id":1,"name":"All Tasks","begin":"3/4/2010","end":"3/20/2010","progress":60,"iconCls":"icon-ok"},      
{"id":2,"name":"Designing","begin":"3/4/2010","end":"3/10/2010","progress":100,"_parentId":1,"state":"closed"},
{"id":21,"name":"Database","persons":2,"begin":"3/4/2010","end":"3/6/2010","progress":100,"_parentId":2},
{"id":22,"name":"UML","persons":1,"begin":"3/7/2010","end":"3/8/2010","progress":100,"_parentId":2}, {"id":23,"name":"Export Document","persons":1,"begin":"3/9/2010","end":"3/10/2010","progress":100,"_parentId":2},
{"id":3,"name":"Coding","persons":2,"begin":"3/11/2010","end":"3/18/2010","progress":80},
{"id":4,"name":"Testing","persons":1,"begin":"3/19/2010","end":"3/20/2010","progress":20} ],"footer":[ {"name":"Total Persons:","persons":7,"iconCls":"icon-sum"} ]}

     Here's what a few important attributes above data:

     1) _parentId: field _parentId essential and unique name. Remember preceded by "_", he is used to record the parent node, do not have this property, there is no way to show the parent node followed by the parent node must exist, otherwise the information is not showing up in the background when traversing combination, If the parent node does not exist or is 0, then _parentId should not be assigned, or set to "." If the assignment "0" data does not appear in the table.

    2) state: whether to expand

     3) checked: if selected (for box)

    4) iconCls: in front of the Options icon, and if they do not set the parent node for the default folder icon, the icon for the file child node

 

    Let's start the relevant functions the organization and management of the page. First, we want to create an information entity organization.

Third, create Org entity

       1. In Visual Studio 2017's "Solution Explorer", right-click "ABP.TPLMS.Core" project "Entitys" folder, the pop-up menu, select "Add">

 > "Class." Name the class Org, then select "Add."

      2. Create Org class inherits from Entity <int>, save to achieve by implementing the audit module IHasCreationTime created. The data format required TreeGrid requirements. code show as below:

using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
 

namespace ABP.TPLMS.Entitys
{

   public partial class Org : Entity<int>, IHasCreationTime
{
      int m_parentId = 0;
        public Org()
        {

            this.Id = 0;
            this.Name = string.Empty;
            this.HotKey = string.Empty;
            this.ParentId = 0;
            this.ParentName = string.Empty;

            this.IconName = string.Empty;

            this.Status = 0;

            this.Type = 0;

            this.BizCode = string.Empty;
            this.CustomCode = string.Empty;
            this.CreationTime = DateTime.Now;
            this.UpdateTime = DateTime.Now;
            this.CreateId = 0;

            this.SortNo = 0;

        }

        [Required]
        [StringLength(255)]
        public string Name { get; set; }

        [StringLength(255)]
        public string HotKey { get; set; }

        public int ParentId { get { return m_parentId; } set { m_parentId = value; } }

        [Required]
        [StringLength(255)]
        public string ParentName { get; set; }

        public bool IsLeaf { get; set; }

        public bool IsAutoExpand { get; set; }

        [StringLength(255)]
        public string IconName { get; set; } 

        public int Status { get; set; }

        public int Type { get; set; }

        [StringLength(255)]
        public string BizCode { get; set; }

        [StringLength(100)]
        public string CustomCode { get; set; }

        public DateTime CreationTime { get; set; }
        public DateTime UpdateTime { get; set; }
        public int CreateId { get; set; }

        public int SortNo { get; set; }
public int? _parentId {
            get {
                if (m_parentId == 0)                

                {
                    return null;
                }

                return m_parentId;
            }           

        }
    }
}
      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; }
          public DbSet<Org> Orgs { get; set; }

    }
}

 

 

 

      4.从菜单中选择“工具->NuGet包管理器器—>程序包管理器控制台”菜单。

     5. 在PMC中,默认项目选择EntityframeworkCore对应的项目后。输入以下命令:Add-Migration AddEntityOrg,创建迁移。如下图。

 

       6. 在上面的命令执行完毕之后,创建成功后,会在Migrations文件夹下创建时间_AddEntityOrg格式的类文件,这些代码是基于DbContext指定的模型。如下图。

 

     7.在程序包管理器控制台,输入Update-Database,回车执行迁移。执行成功后,如下图。

 

     8. 在SQL Server Management Studio中查看数据库,Orgs表创建成功。

 

 

 

 

Guess you like

Origin www.cnblogs.com/chillsrc/p/11899403.html