abp(net core)+easyui+efcore实现仓储管理系统——供应商管理升级之上(六十三)

yizhihongxing
abp(net core)+easyui+efcore实现仓储管理系统目录

 
 
    有了前面两篇关于升级的文章,组织管理和模块管理,并在升级过程中解决了一些升级中出现的问题。我们对供应商管理这个模块进行升级,这次的升级涉及到前端页面的一些问题。
 

1.在Visual Studio 2022的解决方案资源管理器中,选中“ABP.TPLMS.Web.Mvc”项目,然后单击鼠标右键,在弹出菜单中选中“设为启动项目”。按F5运行应用程序。

2.在浏览器将呈现登录页面,然后输入管理员用户名进行登录。浏览器跳转到首页面。如下图。

 abp(net core)+easyui+efcore实现仓储管理系统——供应商管理升级之上(六十三)

 

3.在主界面的菜单中,选择“Business->供应商管理”菜单项,浏览器立即报了一个错误。如下图。

abp(net core)+easyui+efcore实现仓储管理系统——供应商管理升级之上(六十三)

 

4.这是AutoMapper.Mapper方法造成的。这是由于在升级的时候,AutoMapper也升级了。由于NET模型映射器AutoMapper 9.0之后,官方宣称不再支持静态方法调用,之前直接升级编译报错无法使用。我简单的在代码的构造函数中使用注入方式,注入Mapper。现在实际运行时,发现这种方式,如果没有在startup.cs代码中预先注册,是无法使用的。原先的代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using Abp.Auditing;
using Abp.Runtime.Validation;
using ABP.TPLMS.Controllers;
using ABP.TPLMS.Suppliers;
using ABP.TPLMS.Suppliers.Dto;
using ABP.TPLMS.Web.Models.Supplier;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
 
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
 
namespace ABP.TPLMS.Web.Controllers
{
    [AbpMvcAuthorize]
    [Audited]
    public class SupplierController : TPLMSControllerBase
    {
        const int MaxNum= 10;
        // GET: /<controller>/
        [DisableAuditing]
        public async Task<IActionResult> Index()
        {
 
            SupplierDto cuModule=null;

            var module = (await _supplierAppService.GetAllAsync(new PagedSupplierResultRequestDto { MaxResultCount = MaxNum })).Items; // Paging not implemented yet
            if (module.Count>0)
            {
                cuModule = module.First();
            }
           
            var model = new SupplierListViewModel
            {
                Supplier = cuModule,
                Suppliers=module
            };
          
            return View(model);
        }
 
        private readonly ISupplierAppService _supplierAppService;
        AutoMapper.Mapper m_map;

        public SupplierController(ISupplierAppService supplierAppService,AutoMapper.Mapper map)
        {
            _supplierAppService = supplierAppService;

            m_map = map;
        }

        public async Task<ActionResult> EditSupplierModal(int supplierId)
        {
           
            var module = await _supplierAppService.GetAsync(new EntityDto<int>(supplierId));
            CreateUpdateSupplierDto cuSupplier = m_map.Map<CreateUpdateSupplierDto>(module);

            var model = new EditSupplierModalViewModel
            {
                Supplier = cuSupplier
            };
            return View("_EditSupplierModal", model);
        }
    }
}

 

 5.幸好发现有一个ABP.ObjectMapper.Map方法可以使用,我们将代码修改为:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using Abp.Auditing;
using Abp.Runtime.Validation;
using ABP.TPLMS.Controllers;
using ABP.TPLMS.Suppliers;
using ABP.TPLMS.Suppliers.Dto;
using ABP.TPLMS.Web.Models.Supplier;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
 
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
 
namespace ABP.TPLMS.Web.Controllers
{
    [AbpMvcAuthorize]
    [Audited]
    public class SupplierController : TPLMSControllerBase
    {
        const int MaxNum= 10;
        // GET: /<controller>/
        [DisableAuditing]
        public async Task<IActionResult> Index()
        {
 
            SupplierDto cuModule=null;

            var module = (await _supplierAppService.GetAllAsync(new PagedSupplierResultRequestDto { MaxResultCount = MaxNum })).Items; // Paging not implemented yet
            if (module.Count>0)
            {
                cuModule = module.First();
            }
           

            var model = new SupplierListViewModel
            {
                Supplier = cuModule,
                Suppliers=module
            };
          
            return View(model);
        }
 
        private readonly ISupplierAppService _supplierAppService;

        public SupplierController(ISupplierAppService supplierAppService)
        {
            _supplierAppService = supplierAppService;
           
        }

        public async Task<ActionResult> EditSupplierModal(int supplierId)
        {
            
            var module = await _supplierAppService.GetAsync(new EntityDto<int>(supplierId));

            CreateUpdateSupplierDto cuSupplier = ObjectMapper.Map<CreateUpdateSupplierDto>(module);
            var model = new EditSupplierModalViewModel
            {
                Supplier = cuSupplier
 
            };
           return View("_EditSupplierModal", model);

        }
}
}

 

6.在Visual Studio 2022的解决方案资源管理器,按F5运行应用程序。

7.在浏览器将呈现登录页面,然后输入管理员用户名进行登录。浏览器跳转到首页面,在主界面的菜单中,选择“Business->供应商管理”菜单项,浏览器中呈现一个供应商信息列表页面,我们发现此页面的顶部与右边的菜单部分缺失css,样式不好看。如下图。

abp(net core)+easyui+efcore实现仓储管理系统——供应商管理升级之上(六十三)

8. 在Visual Studio 2017的“解决方案资源管理器”中,右键单击在领域层“ABP.TPLMS.Web.Mvc”项目中的Views\Supplier目录。 找到Index.cshmtl文件,修改顶部的代码与按钮的代码。具体代码如下:

 

@using ABP.TPLMS.Web.Startup
@model ABP.TPLMS.Web.Models.Supplier.SupplierListViewModel
 

@{
    ViewData["Title"] = PageNames.Supplier;
}

@section scripts
    {
    <script src="~/view-resources/Views/Supplier/Index.js" asp-append-version="true"></script>

}
<section class="content-header">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6">
                <h1>@L("Supplier")</h1>
            </div>
            <div class="col-sm-4 text-sm-right">
                <a id="RefreshButton" href="javascript:void(0);"><i class="fas fa-redo-alt"></i></a>
            </div>
            <div class="col-sm-2">
                <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right"
data-toggle="modal" data-target="#SupplierCreateModal"> <i class="fa fa-plus-square">Add</i> </button> </div> </div> </div> </section> <div class="row clearfix"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="card"> <div class="body table-responsive"> <table class="table"> <thead> <tr> <th> @Html.DisplayNameFor(model => model.Supplier.Code) </th> <th> @Html.DisplayNameFor(model => model.Supplier.Name) </th> <th> @Html.DisplayNameFor(model => model.Supplier.LinkName) </th> <th> @Html.DisplayNameFor(model => model.Supplier.Mobile) </th> <th> @Html.DisplayNameFor(model => model.Supplier.Address) </th> <th> @Html.DisplayNameFor(model => model.Supplier.Tel) </th> <th> @Html.DisplayNameFor(model => model.Supplier.Status) </th> <th></th> </tr> </thead> <tbody> @foreach (var item in Model.Suppliers) { <tr> <td> @Html.DisplayFor(modelItem => item.Code) </td> <td> @Html.DisplayFor(modelItem => item.Name) </td> <td> @Html.DisplayFor(modelItem => item.LinkName) </td> <td> @Html.DisplayFor(modelItem => item.Mobile) </td> <td> @Html.DisplayFor(modelItem => item.Address) </td> <td> @Html.DisplayFor(modelItem => item.Tel) </td> <td> @Html.DisplayFor(modelItem => item.Status) </td> <td > <a href="#" class="btn btn-sm bg-secondary edit-supplier" data-supplier-id="@item.Id"
data-toggle
="modal" data-target="#SupplierEditModal"><i class="fas fa-pencil-alt"></i>@L("Edit")</a> <a href="#" class="btn btn-sm bg-danger delete-supplier" data-supplier-id="@item.Id"
data-supplier-name
="@item.Name"><i class="fas fa-trash"></i>@L("Delete")</a> </td> </tr> } </tbody> </table> </div> </div> </div> </div> <div class="modal fade" id="SupplierCreateModal" tabindex="-1" role="dialog" aria-labelledby="SupplierCreateModalLabel"
data-backdrop
="static"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title"> <span>@L("CreateNewSupplier")</span> </h4> </div> <div class="modal-body"> <form name="SupplierCreateForm" role="form" class="form-validation"> <div> <div class="row clearfix"> <div class="col-sm-6"> <div class="form-group form-float"> <div class="form-line"> <label asp-for="@Model.Supplier.Code" class="form-label"></label> <input type="text" name="Code" class="form-control" required maxlength="50" /> </div> </div> </div> <div class="col-sm-6"> <div class="form-group form-float"> <div class="form-line"> <label asp-for="@Model.Supplier.Name" class="form-label"></label> <input type="text" name="Name" class="form-control" required maxlength="50" /> </div> </div> </div> </div> <div class="row clearfix"> <div class="col-sm-12"> <div class="form-group form-float"> <div class="form-line"> <label asp-for="@Model.Supplier.Address" class="form-label"></label> <input type="text" name="Address" class="form-control" required maxlength="255" /> </div> </div> </div> </div> <div class="row clearfix"> <div class="col-sm-6"> <div class="form-group form-float"> <div class="form-line"> <label asp-for="@Model.Supplier.LinkName" class="form-label"></label> <input type="text" name="LinkName" class="form-control" /> </div> </div> </div> <div class="col-sm-6"> <div class="form-group form-float"> <div class="form-line"> <label asp-for="@Model.Supplier.Mobile" class="form-label"></label> <input type="text" name="Mobile" class="form-control" /> </div> </div> </div> </div> <div class="row clearfix"> <div class="col-sm-6"> <div class="form-group form-float"> <div class="form-line"> <label asp-for="@Model.Supplier.Tel" class="form-label"></label> <input type="text" name="Tel" class="form-control" required maxlength="255" /> </div> </div> </div> <div class="col-sm-6"> <div class="form-group form-float"> <div class="form-line"> <label asp-for="@Model.Supplier.Status" class="form-label"></label> <input type="text" name="Status" class="form-control" /> </div> </div> </div> </div> <div class="row clearfix"> <div class="col-sm-6"> <div class="form-line"> <label asp-for="@Model.Supplier.Sex"></label> <input name="Sex" type="text" class="form-control" /> </div> </div> <div class="col-sm-6"> <div class="form-line"> <label asp-for="@Model.Supplier.Email"></label> <input name="Email" type="text" class="form-control" /> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button> <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button> </div> </form> </div> </div> </div> </div> <div class="modal fade" id="SupplierEditModal" tabindex="-1" role="dialog" aria-labelledby="SupplierEditModalLabel"
data-backdrop
="static"> <div class="modal-dialog" role="document"> <div class="modal-content"> </div> </div> </div>

 

原文链接:https://www.cnblogs.com/chillsrc/archive/2023/05/04/17372490.html

本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:abp(net core)+easyui+efcore实现仓储管理系统——供应商管理升级之上(六十三) - Python技术站

(0)
上一篇 2023年5月4日
下一篇 2023年5月4日

相关文章

  • c# socket编程udp客户端实现代码分享

    下面是“c# socket编程udp客户端实现代码分享”的完整攻略: 一、前置知识 在进行c# socket编程udp客户端实现之前,你需要掌握以下知识: c#语言基础 socket编程基础 udp协议基础 二、实现步骤 1. 创建udp客户端 使用c#中的Socket类创建udp客户端: Socket client = new Socket(Address…

    C# 2023年5月31日
    00
  • 利用C#编写一个Windows服务程序的方法详解

    Title: 利用C#编写一个Windows服务程序的方法详解 介绍 Windows服务是在后台运行的程序,可以在计算机启动时自动启动,不需要用户登陆即可运行。本文将详细讲解如何利用C#编写一个Windows服务程序。 步骤 1.创建Windows服务项目 打开Microsoft Visual Studio,选择“新建项目”,在左侧菜单中选择“Visual.…

    C# 2023年6月1日
    00
  • stringstream操纵string的方法总结

    下面是详细讲解“stringstream操纵string的方法总结”的完整攻略: 1. stringstream 简介 stringstream 是 C++ 中很重要的一个类。它继承自 istream 和 ostream,可以方便地进行输入输出操作。 我们可以通过在stringstream 中写入不同类型的数据,并使用它的读取方法来统一获得这些数据。这种方法…

    C# 2023年6月8日
    00
  • 详解PID控制器原理

    详解PID控制器原理 什么是PID控制器? PID控制器是一种常用的控制器,可以用于自动控制系统中。它的全称是Proportional-Integral-Derivative Controller(比例-积分-微分控制器),它主要根据误差信号调整控制量,从而稳定系统的输出。 PID控制器的组成 PID控制器由三部分组成: 比例控制器 比例控制器根据误差信号调…

    C# 2023年6月8日
    00
  • C#常用目录文件操作类实例

    C#常用目录文件操作类实例 在C#的编程过程中,我们需要对文件和目录进行操作。为了方便开发,C#提供了一些常用的目录文件操作类。本文将详细介绍这些类的使用方法,并给出两个实例。 目录操作类 Directory类 Directory类提供了很多操作目录的方法,例如创建、删除、复制和移动目录等。 创建目录 创建目录的方法为: Directory.CreateDi…

    C# 2023年5月15日
    00
  • C#如何在窗体程序中操作数据库数据

    你好,操作数据库是窗体程序的一个关键功能之一,C#通过ADO.NET技术来实现数据库连接,并且提供了丰富的工具和类实现数据的访问、读写和更新等操作。下面是C#在窗体程序中操作数据库数据的完整攻略。 步骤一:创建数据库连接 连接数据库是操作数据库的第一步,C#通过SqlConnection类来创建数据库连接,构造方法的参数是连接字符串,其中包含数据库的地址、用…

    C# 2023年5月15日
    00
  • ASP.NET Core应用错误处理之DeveloperExceptionPageMiddleware中间件呈现“开发者异常页面”

    ASP.NET Core是一种使用C#语言的典型Web应用程序开发框架,它默认提供了DeveloperExceptionPageMiddleware中间件用于处理应用程序中的异常并呈现相应的错误页面。以下是实现开发者异常页面的步骤。 1. 安装Microsoft.AspNetCore.Diagnostics包 DeveloperExceptionPageMi…

    C# 2023年5月15日
    00
  • C# 无限级分类的实现

    C# 无限级分类的实现 什么是无限级分类? 无限级分类又称为多级分类,是指一种基于树状结构的数据分类方法。其特点是可以不断的按照需求无限拓展分类层级。 实现无限级分类的步骤 第一步:建立分类表 首先我们需要建立一个分类表,在分类表中应包含以下几个重要字段: 字段 类型 描述 id int 分类编号,主键 name nvarchar 分类名称 parent_i…

    C# 2023年5月31日
    00
合作推广
合作推广
分享本页
返回顶部