欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理六(二十四)

程序员文章站 2022-06-12 23:42:57
在上一篇 abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理五 (二十三) 文章中,我们修正了一些BUG,让货物信息管理的前端与后台功能基本实现了我们所要。现在我们运行起应用程序看看新增功能。 ......

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实现仓储管理系统——菜单-上 (十六)

abp(net core)+easyui+efcore实现仓储管理系统——easyui前端页面框架 (十八)

abp(net core)+easyui+efcore实现仓储管理系统——easyui之货物管理一 (十九)

 abp(net core)+easyui+efcore实现仓储管理系统——easyui之货物管理二 (二十)

abp(net core)+easyui+efcore实现仓储管理系统——easyui之货物管理三 (二十一)
abp(net core)+easyui+efcore实现仓储管理系统——easyui之货物管理四 (二十二)
 abp(net core)+easyui+efcore实现仓储管理系统——easyui之货物管理五 (二十三)
 
 

在上一篇 abp(net core)+easyui+efcore实现仓储管理系统——easyui之货物管理五 (二十三) 文章中,我们修正了一些bug,让货物信息管理的前端与后台功能基本实现了我们所要。现在我们运行起应用程序看看新增功能。

 

十五、新增货物信息

     继续来实现我们的货物信息管理功能,之前我们已经实现了列表功能,现在我们来实现货物信息的增加功能。

    1. 在visual studio 2017的“解决方案资源管理器”中,右键单击在领域层“abp.tplms.web.core”项目中的controller目录。 找到tplmscontrollerbase文件,添加一个新的方法jsoneasyuiresult。此方法用来实现当我们完成了增加货物信息之后,返回给前端相关信息。代码如下。

protected dynamic jsoneasyuiresult(int id,string result)
{

    string strid = string.empty;
    if (id>0)
    {
        strid = id.tostring();
    }

        var obj = new
    {
        result = result,
        id = strid
     };
     var json = abp.tplms.helpers.jsonhelper.instance.serialize(obj);
     return json;
}
    2. 在visual studio 2017的“解决方案资源管理器”中,右键单击在展示层“abp.tplms.web.mvc”项目中的controller目录。 找到cargocontroller文件,添加一个新增方法,代码如下。

      

 public actionresult add(cargodto createdto)
        {
            var json = string.empty;
            string result = "no";
            if (createdto == null)
            {
                json = jsoneasyuiresult(0, result);
                return content(json);

            }
            try
            {
                var cargo = objectmapper.map<createupdatecargodto>(createdto);

                // todo: add logic here
                var obj = _cargoappservice.create(cargo);
                int id = obj.getawaiter().getresult().id;
                if (obj != null)
                {
                    json = jsoneasyuiresult(id, "ok");

                }
                else

                {
                    json = jsoneasyuiresult(0,result);

                }
            }
            catch

            {
            }
            return content(json);

        }

     3.在visual studio 2017中按f5运行应用程序。

     4.在浏览器中的地址栏中输入“http://localhost:5000/”,然后输入管理员用户名进行登录。

     5.在主界面的菜单中,选择“business->货物管理”菜单项,浏览器中呈现一个货物信息列表与四个按钮。如下图。关于菜单的生成可以参见文章(与 )。

 abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理六(二十四)

      6.新增货物:点击“添加”按钮,弹出一个“添加货物”的操作界面,如下图中所示。

 abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理六(二十四)

     7.在输入相应的货物信息之后,点击“保存”按钮 。在弹出的确认对话框中点击“确定”按钮。在弹出的“保存成功”确认对话框中点击“确定”按钮。

 abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理六(二十四)

      8.然后系统就没有任何反应,没有弹出任何提示信息,查询数据也没有发现添加新数据。我们在浏览器中按f12,然后发现原来报错了。如下图。

 abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理六(二十四)

具体错误信息如下:

 an unhandled exception occurred while processing the request.

abpvalidationexception: method arguments are not valid! see validationerrors for details.

abp.runtime.validation.interception.methodinvocationvalidator.throwvalidationerror() in methodinvocationvalidator.cs, line 118

        9.原来是abp的一个校验异常。abp的两个特性enablevalidation和disablevalidation 用来控制validation。我们在add方法上面添加两个特性[httppost]与[disablevalidation]。

 

[httppost]
[disablevalidation]
public actionresult add(cargodto createdto)

{… 代码见第2步。}

 

10.重新从第3步到第7步。这次保存成功。见下图。

abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理六(二十四) 


 

上一篇: 买麾托

下一篇: 启蒙教育