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/p/17372490.html

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

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

相关文章

  • C# File.OpenWrite(string path):以写模式打开指定文件,并返回FileStream对象

    C# File.OpenWrite()方法 File.OpenWrite(string path)方法可用于在指定路径上创建或重写指定文件,并返回一个可用于写入到文件的FileStream对象。 如果文件已存在,则将替换文件。如果文件不存在,则创建文件。 语法 public static FileStream OpenWrite(string path); …

    C# 2023年4月19日
    00
  • 快速了解c# 结构体

    下面是快速了解C#结构体的完整攻略: 简介 在C#中,结构体是一种轻量级的数据结构,可以用来封装少量相关数据。相比于类(class),结构体的运行效率更高,且占用更少的内存空间。通过使用结构体,可以提高程序的性能和效率。 定义结构体 定义结构体的方式与定义类的方式类似,不同之处在于使用“struct”关键字。例如: struct Point { public…

    C# 2023年6月7日
    00
  • Linux CentOS下docker部署Asp.Net Core(.Net6)

    Linux CentOS下docker部署Asp.Net Core(.Net6)攻略 在本攻略中,我们将深入讲解如何在Linux CentOS下使用docker部署Asp.Net Core(.Net6),并提供两个示例说明。 步骤一:安装docker 在使用docker部署Asp.Net Core(.Net6)之前,我们需要在Linux CentOS上安装d…

    C# 2023年5月17日
    00
  • nodejs中sleep功能实现暂停几秒的方法

    要在Node.js中实现sleep功能即暂停几秒的效果,常用的方法是使用setInterval函数进行定时执行。以下是步骤: 步骤1:编写sleep函数 编写一个sleep函数,该函数接收一个参数(单位为milliseconds),等待给定时间后返回。 function sleep(ms) { return new Promise((resolve) =&g…

    C# 2023年6月6日
    00
  • C#写日志类实例

    下面是C#写日志类实例的攻略。 概述 在开发应用程序时,经常需要记录应用程序的运行日志,以便在程序出现异常等问题时快速定位问题。C#提供了System.Diagnostics命名空间下的Trace和Debug类用于记录日志信息,而自己编写一个日志类可以更加灵活地记录日志信息,并可以根据自己的需求进行扩展和定制。 实现步骤 1. 创建日志类 首先需要创建一个日…

    C# 2023年6月1日
    00
  • C# 没有动态的数组,可以用arraylist或list取代

    首先,需要说明的是C#中的数组属于静态数组,即在声明数组时就必须确定数组的长度,而不能在程序运行时再动态更改数组的大小。但是,C#提供了一些其他的数据结构,例如ArrayList和List,可以实现动态数组的功能。下面是使用ArrayList和List的具体说明: 使用ArrayList ArrayList是可以动态调整存储数据的容器,通过Add方法可以向其…

    C# 2023年6月7日
    00
  • C#连接到sql server2008数据库的实例代码

    下面是连接到SQL Server 2008数据库的C#代码实例。 示例1:使用SQLConnection连接数据库 添加引用:在Visual Studio中,选择“解决方案资源管理器”,右键单击“引用”文件夹,选择“添加引用”,在“添加引用”对话框中选择“System.Data.SqlClient”引用,点击“确定”按钮。 编写C#代码:代码实现步骤如下: …

    C# 2023年6月2日
    00
  • C#基于Socket的网络通信类你了解吗

    C#基于Socket的网络通信类攻略 什么是基于Socket的网络通信? 基于Socket的网络通信是指利用Socket技术实现网络通信的过程。Socket(套接字)是一个通信端点,它包含了IP地址和端口号。在网络通信中,客户端和服务器端都需要创建Socket对象以便建立连接,进行数据传输。 C#实现基于Socket的网络通信的方式 在C#中实现基于Sock…

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