使用ASP.NET MVC局部视图避免JS拼接HTML,编写易于维护的HTML页面

    以前使用ASP.NET WebForm开发时,喜欢使用Repeater控件嵌套的方式开发前台页面,这样就不用JS拼接HTML或者后台拼接HTML了,写出的HTML页面美观、简捷、易于维护,由于不用JS拼接HTML,所以JS写的也很少。

    最近使用ASP.NET MVC开发,前台页面的功能比较复杂,每次刷新整个页面的话体验会很差,所以通过JS控制页面元素,实现局部刷新。刚开始使用的方法是通过JS在前台拼接HTML,结果JS写的很长,要命的事,每增加一个新功能,都要拼接很长的HTML,结果页面的JS越写越多。考虑到后期可能难以维护,所以花了半天的时间,对页面进行了大改,把这一个页面拆分成了四个页面,通过jQuery的load方法实现局部更新,修改之后页面清爽多了。

    本来想使用ASP.NET MVC的PartialView实现,结果路由的问题遇到点麻烦。最后发现直接使用View也可以,就用View实现了,效果是一样的,不必太钻牛角尖。

模板页面代码(用了两层Layout嵌套):

Layout.cshtml页面代码:

@{
    ViewBag.Title = "货机管理";
}

<!DOCTYPE html>
<htmlhead>
    title>@ViewBag.Title</style type="text/css">
        body
        {
            font-size: 12px;
            padding 0
            margin
            background-color #666;
        }

        .ul-menu
        
            float left
            margin-left 3px

            .ul-menu li
            
                float
                list-style none
                margin
                padding
                width 45px
                height 25px
                line-height
                text-align center
                margin-right 20px
                border solid 1px #999
                cursor pointer;
            }
    stylescript ="text/javascript" src="~/Scripts/jquery-1.8.2.js"></script="text/javascript">
        function gotourl(url) {
            window.location = url;
        }
    >

bodydiv ="width: 960px; margin: auto; background-color: #fff; padding: 7px;">
        ="height: 110px; border: solid 1px #999;">
            ="float: left; width: 105px; height: 65px; margin: 3px; text-align: center; border: solid 1px #999;">
                ="font-size: 16px; margin-top: 12px;">
                    IMU
                    br />
                    120×90
                div="float: right; padding: 5px; margin-top: 5px;"="float: left;"
                    欢迎您,span>XXX 【退出】
                ="float: left; margin-left: 50px;"
                    @{
                        string[] weekDays = { "星期天","星期一","星期二","星期三","星期四","星期五","星期六" };
                    }
                    当前时间 @DateTime.Now.ToString("yyyy-MM-dd(" + weekDays[(int)DateTime.Now.DayOfWeek] + ")HH:mm")
                ="float: left; margin-left: 50px; margin-right: 5px;"
                    帮助中心
                ="margin-top: 76px;"ul class="ul-menu">
                    li onclick="gotourl('@Url.Content("~/Backstage/MachineMng/MachineInfo/Index")')">货机li~/Backstage/MachineMng/StartCargo/Index")')">运营>交易>系统ul>

        
        @RenderBody()
    >
View Code

RoadSetLayout.cshtml页面代码:

@{
    ViewBag.Title = "货道设置";
    Layout = Url.Content("~/Views/Backstage/MachineMng/Layout.cshtml");
}


        .div-button1
        
            width 120px
            height 35px
            border 18px
            line-height
            text-align
            cursor

        .div-button2
         30px 14px

        .div-arrow
         55px
            padding-top 5px

        .div-arrow2
         22px 6px 10px="~/Scripts/My97DatePicker/WdatePicker.js"
        $( () {

        });

    ="height: 200px; border: solid 1px #999; border-top: 0;"="float: left; width: 200px; height: 150px; border: solid 1px #999; margin: 20px; padding: 5px;"="text-align: center; font-size: 18px; line-height: 25px; padding-top: 10px;"
                货机现在运行正常
                
                连续运行3天 72小时
            ="padding-top: 10px; line-height: 20px;"
                货机数据已经与平台数据同步,无需插数据盘。
                请插入数据盘完成数据同步更新/数据盘已插入,数据传输完成10%
            ="float: right; width: 600px; height: 160px; margin: 20px; margin-right: 50px;"="div-button1" style="margin-left: 100px; cursor: default; background-color: #eee;"
                暂停货机
            ~/Backstage/MachineMng/StartCargo/Index")')" class="margin-left: 50px;"
                启动货机
            ="float: left; width: 100%; height: 33px; line-height: 33px; text-align: center;"="float: left; margin-left: 100px;"
                    货机暂停才可以进行以下操作:以下操作完成须启动货机
                ="float: left; width: 100%; height: 60px; line-height: 60px; text-align: center;"="div-arrow"="margin-left: 150px;"img  alt=""="@Url.Content("~/Images/Cargo/roadset_arrow_down.png")" />
                ="margin-left: 160px;"img ~/Images/Cargo/roadset_arrow_up.png")" ="div-button2" onclick~/Backstage/MachineMng/RoadSet/Index")')" style
                商品货道设置
            ="div-arrow2"=""~/Images/Cargo/roadset_arrow_right.png")" />
            ="margin-left: 5px;"
                现金管理理
            
                货机运维
            
    @RenderBody()
>
View Code

Index.cshtml页面代码:

@{
    ViewBag.Title = "货道设置";
    Layout = Url.Content("~/Views/Backstage/MachineMng/RoadSetLayout.cshtml");
}

link ="text/css" href="~/Scripts/jquery-easyui-1.4.1/themes/default/easyui.css" rel="stylesheet" />
    

        .div-box
         solid 1px #f5f5f5 148px 97px #f5f5f5 default

            .div-box div
            
                margin-top 15px
                margin-left 9px 80px
                font-size 16px
                font-family 黑体

        .ul-instructions
         200px
            margin-top
            margin-bottom

            .ul-instructions li
            

                .ul-instructions li div
                
                    float;
                

        .div-road
         130px 100px

        .table-road
         #ffff00

        .div-highlight
         solid 1px #6dbde4 !important #dceaf2 !important

        .img-btn
        

        .img-btn2
        

        .table-addroads
         100%

            .table-addroads tr td:first-child
             right

            .table-addroads tr td
            

        .input-green
         green="~/Scripts/jquery-easyui-1.4.1/jquery.easyui.min.js"="~/Scripts/SimpoWindow.js" () {
            $("#tdboxs).load(Boxs?cargoCode=" + '@ViewBag.cargoCode' &t=new Date().valueOf(), (data) {
                $(.div-box:first).click();
            });
        });

        //显示货柜的货道
         showBox(obj,boxId) {
            $(.div-box).removeClass(div-highlight);
            $(obj).addClass();

            $(#divfloorsFloors?boxId=+ boxId  Date().valueOf());
        }

        添加货柜
         addbox(addType) {
            if (confirm(确定添加?)) {
                var cargoCode = ;
                 floorType  $(input[name='floorType']:checked).val();
                $.ajax({
                    type: POST,url: @Url.Content(~/BackstageMachineMngRoadSetAddBox)addType: addType,1)">cargoCode: cargoCode,1)">floorType: floorType },success:  (d) {
                         data  eval(( d );
                         (data.ok) {
                            $( (data) {
                                 (addType == 1) {
                                    $().click();
                                } else {
                                    $(.div-box:last).click();
                                }
                            });
                        }  {
                            alert(添加失败: data.msg);
                        }
                    },error:  () {
                        alert(添加失败);
                    }
                });
            }
        }

        删除货柜
         delbox(addType) {
            确定删除?;
                $.ajax({
                    type: DelBox: cargoCode },1)"> (data) {
                         (data ok) {
                            ) {
                                $().remove();
                            }
                             {
                                $().remove();
                            }
                            $().click();
                        }
                        删除失败 data);
                        }
                    },1)">添加货道
         addroad(obj,boxId,floor) {
            $.ajax({
                type: AddRoadboxId: boxId,1)">floor: floor },1)"> (d) {
                    );

                     (data.ok) {
                         td  $(obj).parent().parent().parent().parent().find(td:first);
                        td.find(#divroads_ floor).load(Roads?boxId=&floor= floor  Date().valueOf());

                         roadNum  parseInt(td.find(.span-roadNum).text(),1)">10).html((roadNum ).toString());
                    }  {
                        alert( data.msg);
                    }
                },1)"> () {
                    alert();
                }
            });
        }

        删除货道
         delroad(obj,floor) {
            )) {
                $.ajax({
                    type: DelRoad);
                            td.find(.div-road:last).remove();

                            );
                             (roadNum > 0) {
                                td.find(- ).toString());
                            }
                        }
                        添加货道层
         addfloor(obj,boxId) {
            $.ajax({
                type: AddFloor: boxId },1)"> (data.ok) {
                        $( div  $(obj).parent().parent();
                         floorNum  parseInt(div.find(.span-floorNum);
                        div.find().html((floorNum 删除货道层
         delfloor(obj,boxId) {
             $(obj).parent().parent().parent();
             (div.find(.table-floor).length < 2) return;

            DelFloor);

                         (data.ok) {
                            div.find(.table-floor:last);
                            div.find().toString());
                        } 删除失败:批量添加货道
         addroads(obj,floor) {
            SimpoWin.showWin2(更换货箱addroads240170);

             windiv #addroads);
             btnOK  windiv.find(input[type='button']);
            btnOK.bind(click () {
                select[name='roadNum']).find(option:selected).val();
                 roadSpec select[name='roadSpec']).val();

                $.ajax({
                    type: AddRoads: floor,1)">roadNum: roadNum,1)">roadSpec: roadSpec },1)"> (data.ok) {
                             $(obj).parent().parent();
                            td.find( Date().valueOf());
                            td.find().html(data.roadNum.toString());
                        } );
                    }
                });

                btnOK.unbind();
                SimpoWin.closeWin2();
            });
        }
    ="height: 30px; line-height: 30px; padding-top: 5px; border-left: solid 1px #999; border-right: solid 1px #999; text-align: center;"
        客户喜好
        ~/Images/Cargo/roadset_arrow_longright.png")" 
        商品
        
        选择货道
        
        摆放商品
        
        完成货道商品绑定
    id="divbox"="border: solid 1px #999; border-top: 0; border-bottom: none;"table cellpadding="0" cellspacing="border-collapse: collapse; width: 100%;"trtd ="width: 260px;"="ul-instructions">
                        >
                            ="height: 25px; width: 25px; background-color: yellow;"="height: 25px; margin-left: 10px;">黄色:表示更换货道="height: 25px; width: 25px; background-color: green;">绿色:表示上货数量="height: 25px; width: 25px; background-color: red;">红色:表示现有商品数="height: 25px; width: 25px; background-color: gray;">灰色:表示最大商品数="height: 23px; width: 23px; border: solid 1px #000; text-align: center;">>调:表示调换本商品>>换:表示更换商品种类td="text-align: center; margin-top: 25px;"="addbox(1)" alt class="img-btn"~/Images/Cargo/roadset_add.png")" />
                        ="margin-top: 50px; text-align: center;"="delbox(1)"~/Images/Cargo/roadset_Del.png")"  <!--货柜-->
                ="tdboxs">&nbsp;
                ="addbox(2)"="delbox(2)"&nbsp;="text-align: right;"input name="floorType" value="1" type="radio" checked="checked" />横箱="radio" />竖箱table货道层-->
    ="divfloors" 分隔线 ------------------------------------------------------------------------------------更换货箱="addroads"="display: none;"="padding: 10px;"="table-addroads" cellpadding="border-collapse: collapse;"="width: 80px;">货道数:select ="roadNum"option value="4">4货道option="6">6货道="8">8货道="10">10货道select>货道型号:="roadSpec"="C25/80">C25/80="C10/50">C10/50="C30/85">C30/85="C15/75">C15/75colspan="2"="text-align: center;"="button"="确定" />
                    批量更换货道="replaceRoadSpec"更换单个货道="replaceRoadSpecSingle">当前货道:="currentRoadSpec">
View Code

Index.cshtml页面中有两个局部页面Boxs.cshtml和Floors.cshtml,Floors.cshtml页面中有一个局部页面Roads.cshtml,代码如下:

Boxs.cshtml页面代码:

@using System.Data;
@using DAL;

@{
    BoxInfoDal boxInfoDal = new BoxInfoDal();
    string cargoCode = ViewBag.cargoCode;
    DataTable dtLeftBox = boxInfoDal.GetListByBoxCodeDesc(cargoCode,1);
    DataTable dtRightBox = boxInfoDal.GetList(cargoCode,2);
}

@foreach (System.Data.DataRow dr in dtLeftBox.Rows)
{
    ="div-box"="showBox(this,'@dr["id"].ToString()')"="background: url(@Url.Content("~/Images/Cargo/yougui.png")) no-repeat;"
            @boxInfoDal.GetName(dr["cargoCode"].ToString())
         
}
="divMainBox"="float: left; height: 150px; width: 99px;"~/Images/Cargo/zhugui.png")" />

@foreach (System.Data.DataRow dr in dtRightBox.Rows)
{
     
}
View Code

Floors.cshtml页面代码:

@using System.Data;
@using DAL;

@{
    BoxInfoDal boxInfoDal = new BoxInfoDal();
    string boxId = ViewBag.boxId;
    DataRow drBox = boxInfoDal.Get(boxId).Rows[0];
    string boxCode = drBox["cargoCode"].ToString();
    string floorNum = drBox["floorNum"].ToString();
    string floorType = drBox["floorType"].ToString();
}

    $( () {
        $(input[name='floorType'][value=' @floorType ']).attr(checked);

        for ( i ; i <= parseInt(@floorNum) ; i++) {
            $( i).load(@boxId批量操作
        $(#batchoperation).change( () {
             ($(this).val() 更换货道) {
                SimpoWin.showWin2(批量更换货道replaceRoadSpec140);

                #replaceRoadSpec);
                );
                btnOK.bind( () {
                    ).val();
                    ;

                    $.ajax({
                        type: ReplaceRoadSpec (d) {
                            );

                             (data.ok) {
                                 Date().valueOf());
                                }
                            }  {
                                alert( data.msg);
                            }

                            setbatchsel();还原批量操作下拉框
                        },1)"> () {
                            setbatchsel();                            alert();
                        }
                    });

                    btnOK.unbind();
                    SimpoWin.closeWin2();
                });
            }

            批量更换货箱ReplaceRoads);
                });
            }
        });
    });

    还原批量操作下拉框
     setbatchsel() {
        $(option[value='批量操作']selected);
    }

    确定上货
     addgoods(obj,boxId) {
         $(obj).parent().parent().parent();
         inputs  div.find(.addgoods);
        "";
        inputs.each( input  (parseInt(input.val(),1)">) {
                data += input.attr(roadid input.val() ;
            }
        });

        ) {
            alert(请填写上货数量;
        }
        data  data.substr(确定上货吗?)) {
            $.ajax({
                type: AddGoodsdata: data },1)">) {
                            $( Date().valueOf());
                        }
                        alert(上货成功);
                    } 上货失败: data.msg);
                    }

                    setbatchsel();                },1)"> () {
                    setbatchsel();                    alert(上货失败);
                }
            });
        }
    }
="border-left: solid 1px #999; border-right: solid 1px #999; border-top: 0;"="padding: 10px; height: 20px; border-bottom: solid 1px #000;"="float: left; height: 20px; line-height: 20px;"
            设置 @boxInfoDal.GetName(boxCode) 货道层数: span ="span-floorNum">@floorNum="float: left; height: 20px;"="addfloor(this,'@boxId')"="img-btn2"="delfloor(this,1)">/>
        ="float: left; height: 20px; padding-left: 15px;"="batchoperation"="批量操作">批量操作="更换货道">更换货道="更换货箱">更换货箱button ="addgoods(this,1)">="margin-left: 10px;">确定上货button
    @for (int i = 1; i = int.Parse(floorNum); i++)
    {
        DataTable dtRoadList = boxInfoDal.GetRoadList(boxId,i);
        <table class="table-floor"="border-collapse: collapse; border-bottom: solid 1px #999; width: 100%;"="padding: 10px; padding-bottom: 20px; vertical-align: top;"
                        设置第 @i 层货道数:  ="span-roadNum">@dtRoadList.Rows.Count="addroads(this,'@boxId',@i)"="margin-left: 20px;" 货道-->
                    ="divroads_@i"="float: right;"="text-align: center; margin-top: 15px;"="addroad(this,1)">="delroad(this,1)">       
    }
>
View Code

Roads.cshtml页面代码:

@using System.Data;
@using DAL;

@{
    BoxInfoDal boxInfoDal = new BoxInfoDal();
    string boxId = ViewBag.boxId;
    int floor = ViewBag.floor;
    DataTable dtRoadList = boxInfoDal.GetRoadList(boxId,floor);
    int j = 0;
}

 () {
        );
        inputs.bind(keyup input.parent().parent().parent();

            调整输入值
             num  parseInt(input.val(),1)"> currentNum .currentNum).val(),1)"> maxNum .maxNum (num  maxNum) {
                input.val(maxNum - currentNum);
            }

            背景色
             (input.val() != ) {
                input.addClass(input-green);
            }
             {
                input.removeClass();
            }
        });
    });

    更换单个货道
     replaceRoad(currentRoadSpec,roadId,floor) {
        SimpoWin.showWin2(replaceRoadSpecSingle#replaceRoadSpecSingle);
        windiv.find(#currentRoadSpec).html(currentRoadSpec);
        );
        btnOK.bind().val();

            $.ajax({
                type: ReplaceRoadroadId: roadId,1)"> Date().valueOf());
                    } );
                }
            });

            btnOK.unbind();
            SimpoWin.closeWin2();
        });
    }


@foreach (System.Data.DataRow drRoad in dtRoadList.Rows)
{
    j++;                    
    ="div-road"="table-road"="margin: 2px;">@boxInfoDal.NumToABCD(floor)@j.ToString()="replaceRoad('@drRoad["roadSpec"].ToString()','@drRoad["id"].ToString()','@floor')" style="cursor: pointer" title="点击更换货道">货道 @drRoad["roadSpec"].ToString()tr ="line-height: 11px;"="addgoods" roadid="@drRoad["id"].ToString()" value="text"="height: 17px; width: 25px; text-align: center;" ="currentNum"existProductNum"].ToString()" type="height: 19px; width: 25px; border: 0; background-color: red; text-align: center;" readonly="readonly" /><input  ="maxNum"maxProductNum"].ToString()" type="height: 19px; width: 25px; border: 0; background-color: gray; text-align: center;"="text-align: center; font-weight: bold; cursor: pointer;"="点击选择商品"="margin-top: 5px;">@drRoad["productName"].ToString()="position: relative; float: right; margin-right: -1px; margin-bottom: -1px; border: solid 1px #000; padding: 3px; cursor: pointer; background-color: white;"
}
View Code

控制器代码:

using System;
 System.Collections.Generic;
 System.Data;
 System.Linq;
 System.Text;
 System.Web.Mvc;
 DAL;
 Newtonsoft.Json;

namespace Controllers.Backstage.MachineMng
{
    /// <summary>
    /// 货道设置
    </summary>
    public  RoadSetController : AdminBaseController
    {
        #region 构造函数及变量
        private SQLiteHelper.SQLiteHelper sqliteHelper;
         BoxInfoDal boxInfoDal;
         CargoInformationDal cargoInformationDal;

        public RoadSetController()
        {
            sqliteHelper = new SQLiteHelper.SQLiteHelper();
            boxInfoDal =  BoxInfoDal();
            cargoInformationDal =  CargoInformationDal();
        }
        #endregion

        #region Index页面
         ActionResult Index()
        {
            ViewBag.cargoCode = "112";

            return View();
        }
        #region Boxs页面
        public ActionResult Boxs(string cargoCode)
        {
            ViewBag.cargoCode = cargoCode;

            #region Floors页面
        public ActionResult Floors( boxId)
        {
            ViewBag.boxId = boxId;

            #region Roads页面
        public ActionResult Roads(string boxId,int floor)
        {
            ViewBag.boxId = boxId;
            ViewBag.floor = floor;

            #region 添加贷柜
        public ActionResult AddBox(int addType,1)">string cargoCode,1)"> floorType)
        {
            DataTable dtCargo = cargoInformationDal.Get(cargoCode);
            DataRow drCargo = dtCargo.Rows[0];
            string boxId = Guid.NewGuid().ToString();
            string positionNum = null;
            string boxCode = null; //货柜编号
            DataTable dtLeftBoxList = boxInfoDal.GetList(cargoCode,addType);
            boxCode = addType.ToString() + (dtLeftBoxList.Rows.Count + 1).ToString(00);
            positionNum = addType.ToString() + (dtLeftBoxList.Rows.Count + );

            StringBuilder sql =  StringBuilder();
            插入货柜表
            sql.AppendFormat(@"
                insert into 
                mas_box_info(id,shopId,positionNum,cargoCode,floorType,floorNum,delFlag,addTime,addUserId,addMark)
                values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}');shopId"].ToString(),boxCode,1,1)">0,DateTime.Now.ToString(yyyy-MM-dd HH:mm:ss"),-1);

            插入关联表
            sql.AppendFormat(
                insert into 
                mas_cargo_container(id,positionDescription,xCoordinate,yCoordinate,'{9}','{10}');",Guid.NewGuid().ToString(),1)">"",1)">);

            sqliteHelper.BeginTransaction();
            try
            {
                sqliteHelper.Execute(sql.ToString());
                sqliteHelper.Commit();

                Dictionary<string,1)">object> dic = new Dictionary<object>();
                dic[ok"] = true;
                dic[id"] = boxId;
                dic[name"] = (addType == 1 ? " : ") + (dtLeftBoxList.Rows.Count + 1) + ;
                 Content(JsonConvert.SerializeObject(dic));
            }
            catch (Exception ex)
            {
                sqliteHelper.Rollback();

                Dictionary<falsemsg ex.Message;
                 Content(JsonConvert.SerializeObject(dic));
            }
        }
        #region 删除贷柜
        public ActionResult DelBox( cargoCode)
        {
            DataTable dtCargo =string boxId = );
            foreach (DataRow dr in dtLeftBoxList.Rows)
            {
                if (dr[cargoCode"].ToString() == boxCode)
                {
                    boxId = dr[].ToString();
                }
            }
            if (boxId == )
            {
                return Content("");
            }

            StringBuilder sql = 删除货柜
            sql.AppendFormat(
                delete from mas_box_info
                where id='{0}';删除货机货柜关联
            sql.AppendFormat(
                delete from mas_cargo_container
                where boxid='{0}';删除货道
            sql.AppendFormat(
                delete from mas_box_road_info
                where id in 
                (select roadId from mas_container_cargo_road
                where containerId='{0}');删除货柜货道关联
            sql.AppendFormat(
                delete from mas_container_cargo_road
                where containerId='{0}';
            {
                sqliteHelper.Execute(sql.ToString());
                sqliteHelper.Commit();
                );
            }
             (Exception ex)
            {
                sqliteHelper.Rollback();

                错误:" + ex.Message);
            }
        }
        #region 添加货道
        public ActionResult AddRoad( floor)
        {
            string roadId = Guid.NewGuid().ToString();
            DataTable dtRoadList = boxInfoDal.GetRoadList(boxId,floor);
            string roadNo = boxInfoDal.NumToABCD(floor) + (dtRoadList.Rows.Count + ).ToString();

            StringBuilder sql = 插入货道表
            sql.AppendFormat(
                insert into 
                mas_box_road_info(id,roadNO,roadSpec,existProductNum,maxProductNum,productID,roadNo,C20/7510,1)">
                insert into 
                mas_container_cargo_road(id,containerId,layerNo,sort,'{8}'); roadId;
                dic[roadNo roadNo;
                dic[roadSpec"] = maxProductNum10#region 删除货道
        public ActionResult DelRoad( floor)
        {
            DataTable dtRoad = boxInfoDal.GetRoadLast(boxId,floor);

            if (dtRoad.Rows.Count > string roadId = dtRoad.Rows[0][].ToString();
                StringBuilder sql =  StringBuilder();
                删除货道
                sql.AppendFormat(
                    delete from mas_box_road_info
                    where id='{0}';删除货柜货道关联
                sql.AppendFormat(
                    delete from mas_container_cargo_road
                    where roadId='{0}';
                {
                    sqliteHelper.Execute(sql.ToString());
                    sqliteHelper.Commit();
                    );
                }
                 (Exception ex)
                {
                    sqliteHelper.Rollback();

                     ex.Message);
                }
            }
            else
            {
                );
            }
        }
        #region 添加货道层
        public ActionResult AddFloor( boxId)
        {
            DataTable dtBox = boxInfoDal.Get(boxId);
            int floorNum = int.Parse(dtBox.Rows[floorNum].ToString());

            StringBuilder sql = 修改货柜信息
            sql.AppendFormat(
                update mas_box_info 
                set floorNum={1}
                where id='{0}';"] = boxInfoDal.GetName(dtBox.Rows[].ToString());
                dic["] = floorNum + #region 删除货道层
        public ActionResult DelFloor(
                    delete from mas_box_road_info
                    where id in
                    (select road.id
                    from mas_box_road_info road
                    left join mas_container_cargo_road ccr on ccr.roadId=road.id
                    where ccr.layerNo={0}
                    and ccr.containerId='{1}');
                    delete from mas_container_cargo_road
                    where roadId in
                    (select road.id
                    from mas_box_road_info road
                    left join mas_container_cargo_road ccr on ccr.roadId=road.id
                    where ccr.layerNo={0}
                    and ccr.containerId='{1}');if (floorNum > )
                {
                    sqliteHelper.Execute(sql.ToString());
                    sqliteHelper.Commit();
                }

                Dictionary<#region 更换货箱
        public ActionResult AddRoads(int floor,1)">int roadNum,1)"> roadSpec)
        {
            StringBuilder sql =  StringBuilder();

            for (int i = 1; i <= roadNum; i++ Guid.NewGuid().ToString();

                插入货道表
                sql.AppendFormat(
                    insert into 
                    mas_box_road_info(id,addMark)
                    values('{0}',i,1)">);

                插入关联表
                sql.AppendFormat(
                    insert into 
                    mas_container_cargo_road(id,1)">);
            }

            sqliteHelper.BeginTransaction();
             boxInfoDal.NumToABCD(floor);
                dic[roadNum roadNum;
                dic[#region 批量更换货道
        public ActionResult ReplaceRoadSpec(批量更换货道
            sql.AppendFormat(
                    update mas_box_road_info
                    set roadSpec='{1}'
                    where id in
                    (select road.id
                    from mas_box_road_info road
                    left join mas_container_cargo_road ccr on ccr.roadId=road.id
                    where ccr.containerId='{0}');#region 批量更换货箱
        public ActionResult ReplaceRoads( roadSpec)
        {
            DataTable dtBox =].ToString());
            StringBuilder sql = 
                    delete from mas_box_road_info
                    where id in
                    (select road.id
                    from mas_box_road_info road
                    left join mas_container_cargo_road ccr on ccr.roadId=road.id
                    where ccr.containerId='{0}');
                    delete from mas_container_cargo_road
                    where roadId in
                    (select road.id
                    from mas_box_road_info road
                    left join mas_container_cargo_road ccr on ccr.roadId=road.id
                    where ccr.containerId='{0}');int floor = 1; floor <= floorNum; floor++)
                {
                     Guid.NewGuid().ToString();

                    插入货道表
                    sql.AppendFormat(
                        insert into 
                        mas_box_road_info(id,addMark)
                        values('{0}',1)">);

                    插入关联表
                    sql.AppendFormat(
                        insert into 
                        mas_container_cargo_road(id,1)">);
                }
            }

            sqliteHelper.BeginTransaction();
            #region 更换单个货道
        public ActionResult ReplaceRoad(string roadId,1)">
                update mas_box_road_info
                set roadSpec='{1}'
                where id='{0}';#region 上货
        public ActionResult AddGoods( data)
        {
            string[] array = data.Split('');
            StringBuilder sql = foreach (string str  array)
            {
                string[] val = str.Split(:);
                string roadId = val[];
                string num = val[];

                上货
                sql.AppendFormat(
                    update mas_box_road_info
                    set existProductNum=existProductNum+{1}
                    where id='{0}';#endregion

    }
}
View Code

效果图:

原文地址:https://www.cnblogs.com/s0611163

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


引言 本文从Linux小白的视角, 在CentOS 7.x服务器上搭建一个Nginx-Powered AspNet Core Web准生产应用。 在开始之前,我们还是重温一下部署原理,正如你所常见的.Net Core 部署图: 在Linux上部署.Net Core App最好的方式是在Linux机器
引言: 多线程编程/异步编程非常复杂,有很多概念和工具需要去学习,贴心的.NET提供Task线程包装类和await/async异步编程语法糖简化了异步编程方式。 相信很多开发者都看到如下异步编程实践原则: 遵守以上冷冰冰的②③条的原则,可保证异步程序按照预期状态正常运作;我们在各大编程论坛常看到违背
一. 宏观概念 ASP.NET Core Middleware是在应用程序处理管道pipeline中用于处理请求和操作响应的组件。 每个组件是pipeline 中的一环。 自行决定是否将请求传递给下一个组件 在处理管道的下个组件执行之前和之后执行业务逻辑 二. 特性和行为 ASP.NET Core处
背景 在.Net和C#中运行异步代码相当简单,因为我们有时候需要取消正在进行的异步操作,通过本文,可以掌握 通过CancellationToken取消任务(包括non-cancellable任务)。 Task&#160;表示无返回值的异步操作, 泛型版本Task&lt;TResult&gt;表示有返
HTTP基本认证 在HTTP中,HTTP基本认证(Basic Authentication)是一种允许网页浏览器或其他客户端程序以(用户名:口令) 请求资源的身份验证方式,不要求cookie,session identifier、login page等标记或载体。 - 所有浏览器据支持HTTP基本认
1.Linq 执行多列排序 OrderBy的意义是按照指定顺序排序,连续两次OrderBy,后面一个有可能会打乱前面一个的排序顺序,可能与预期不符。 要实现sql中的order by word,name类似效果; LINQ 有ThenBy可以紧接使用, ThenBy记住原本排序的值,然后再排其他值,
ASP.NET Core 核心特性:开源、跨平台、高性能是其决战JAVA的必胜法宝,最引人关注的跨平台特性 到底是怎么实现? &#xA; 本文分Unix、Windows剖析跨平台内幕,读完让你大呼过瘾。
前导 Asynchronous programming Model(APM)异步编程模型以BeginMethod(...) 和 EndMethod(...)结对出现。 IAsyncResult BeginGetResponse(AsyncCallback callback, object state
引言 最近在公司开发了一个项目,项目部署架构图如下: 思路 如图中文本所述,公司大数据集群不允许直接访问外网,需要一个网关服务器代理请求,本处服务器A就是边缘代理服务器的作用。 通常技术人员最快捷的思路是在服务器A上部署IISʺpplication Request Routing Module组件
作为一枚后端程序狗,项目实践常遇到定时任务的工作,最容易想到的的思路就是利用Windows计划任务/wndows service程序/Crontab程序等主机方法在主机上部署定时任务程序/脚本。 但是很多时候,若使用的是共享主机或者受控主机,这些主机不允许你私自安装exe程序、Windows服务程序
引言 熟悉TPL Dataflow博文的朋友可能记得这是个单体程序,使用TPL Dataflow 处理工作流任务, 在使用Docker部署的过程中, 有一个问题一直无法回避: 在单体程序部署的瞬间(服务不可用)会有少量流量无法处理;更糟糕的情况下,迭代部署的这个版本有问题,上线后无法运作, 更多的流
合格的web后端程序员,除搬砖技能,还必须会给各种web服务器配置Https,本文结合ASP.NET Core部署模型聊一聊启用Https的方式。 温故知新 目前常见的Http请求明文传输,请求可能被篡改,访问的站点可能被伪造。 HTTPS是HTTP加上TLS/SSL协议构建的可进行加密传输、身份认
长话短说 前文《解剖HttpClientFactory,自由扩展HttpMessageHandler》主要讲如何为HttpClientFactory自定义HttpMessageHandler组件, 现在来完成课后的小作业: 将重点日志字段显示到Nlog的LayoutRenderer上。 本文实现一个
引言问题 作为资深老鸟,有事没事,出去面试;找准差距、定位价值。 面试必谈哈希, Q1:什么是哈希? Q2:哈希为什么快? Q3:你是怎么理解哈希算法利用空间换取时间的? Q4:你是怎么解决哈希冲突的? Q5:你有实际用写过哈希算法吗? 知识储备 哈希(也叫散列)是一种查找算法(可用于插入),哈希算
前言 如题,有感于博客园最近多次翻车,感觉像胡子眉毛一把抓, 定位不了生产环境的问题。 抛开流程问题,思考在生产环境中如何做故障排除,&#160;发现博客园里面这方面的文章比较少。 .Net 本身是提供了sos.dll工具帮助我们在生产中故障排除,通过提供有关内部公共语言运行时(CLR)环境的信息,
.NET程序是基于.NET Framework、.NET Core、Mono、【.NET实现】开发和运行的 ,定义以上【.NET实现】的标准规范称为.NET Standard .NET Standard .NET标准是一组API集合,由上层三种【.NET实现】的Basic Class Library
长话短说 上个月公司上线了一个物联网数据科学项目,我主要负责前端接受物联网事件,并提供 参数下载。 webapp 部署在Azure云上,参数使用Azure SQL Server存储。 最近从灰度测试转向全量部署之后,日志时常收到: SQL Session超限报错。 排查 我在Azure上使用的是 S
临近年关,搜狗,360浏览器出现页面无法成功跳转,同域Cookie丢失? 也许是服务端 SameSite惹的祸。&#xA;本文揭示由于Chrome低版本内核不识别 SameSite= None, 引发的单点登录故障。
本文聊一聊TraceID的作用和一般组成,衍生出ASP. NETCore 单体和分布式程序中 TraceId 的使用方式
通过给 HttpClint请求的日志增加 TraceId,解锁自定义扩展 HttpClientFacroty 的姿势