北京络捷斯特第三方物流信息系统技术解析(五) 订单录入-配送订单
2.1.4 配送订单
配送订单有订单信息和订单货品两个标签需要用户编写信息。
订单信息截图:
2.1(图1)
货品信息截图:
2.1(图2)
配送订单功能实现:
第一步:数据库
1、 表和关系:
表1:订单配送信息表(PW_OrdersDistributionInformationTable)
列名 |
数据类型 |
主键/外键 |
说明 |
OrdersDistributionInformationID |
int |
主键 |
订单配送信息ID |
OrdersNumber |
nchar(50) |
|
订单号 |
OrdersTypeID |
int |
外键 |
订单类型ID |
UrgencyConditionID |
int |
外键 |
紧急情度ID |
ShipmentTime |
date |
|
起运时间 |
EstimatedArriveTime |
date |
|
预计到达时间 |
TransportationWayID |
int |
外键 |
运输方式ID |
DistributionAreaID |
int |
外键 |
配送区域ID |
ShipperName |
nchar(50) |
|
托运人姓名 |
ShipperPhone |
nchar(50) |
|
托运人电话 |
ShipperUnit |
nchar(50) |
|
托运人单位 |
ShipperAddress |
nchar(50) |
|
托运人地址 |
ConsigneeName |
nchar(50) |
|
收货人姓名 |
ConsigneePhone |
nchar(50) |
|
收货人电话 |
ConsigneeUnitID |
int |
外键 |
收货人单位ID |
ConsigneeAddress |
nchar(50) |
|
收货人地址 |
ClientPaymentWayID |
int |
外键 |
客户付款方式ID |
ClientPrepaidMoney |
decimal(18, 2) |
|
客户预付金额 |
Freight |
decimal(18, 2) |
|
运费 |
Premium |
decimal(18, 2) |
|
保险费 |
OtherCost |
decimal(18, 2) |
|
其它费用 |
InsuredMoney |
decimal(18, 2) |
|
投保金额 |
ReceivableCostNote |
nchar(50) |
|
应收费用备注 |
表2:订单配送明细表(PW_OrdersDistributionDetailedTable)
列名 |
数据类型 |
主键/外键 |
说明 |
OrdersDistributionDetailedID |
int |
主键 |
订单配送明细ID |
OrdersDistributionInformationID |
int |
外键 |
订单配送信息ID |
GoodsID |
int |
外键 |
货品ID |
Volume |
decimal(18, 2) |
|
体积 |
Quantity |
decimal(18, 2) |
|
数量 |
Note |
nchar(50) |
|
备注 |
第二步:控制器(Controllers)
2.1(图5)
Contrlles(控制器)代码:
/// <summary>
/// 接受界面传过来的参数,新增配送订单表的数据
/// </summary>
/// <param name="OrdersNumber">订单号</param>
/// <param name="OrdersTypeID">订单类型ID</param>
/// <param name="UrgencyConditionID">紧急情度ID</param>
/// <param name="ShipmentTime">起运时间</param>
/// <param name="EstimatedArriveTime">预计到达时间</param>
/// <param name="TransportationWayID">运输方式ID</param>
/// <param name="DistributionAreaID">配送区域ID</param>
/// <param name="ShipperName">托运人姓名</param>
/// <param name="ShipperPhone">托运人电话</param>
/// <param name="ShipperUnit">托运人单位</param>
/// <param name="ShipperAddress">托运人地址</param>
/// <param name="ConsigneeName">收货人姓名</param>
/// <param name="ConsigneePhone">收货人电话</param>
/// <param name="ConsigneeUnitID">收货人单位ID</param>
/// <param name="ConsigneeAddress">收货人地址</param>
/// <param name="ClientPaymentWayID">客户付款方式ID</param>
/// <param name="ClientPrepaidMoney">客户预付金额</param>
/// <param name="Freight">运费</param>
/// <param name="Premium">保险费</param>
/// <param name="OtherCost">其它费用</param>
/// <param name="InsuredMoney">投保金额</param>
/// <param name="ReceivableCostNote">应收费用备注</param>
/// <returns>int</returns>
#region 新增订单配送信息
public int InsertOrdersDistributionInformation(string OrdersNumber,string OrdersTypeID,string UrgencyConditionID, string ShipmentTime,string EstimatedArriveTime,string TransportationWayID,
string DistributionAreaID,string ShipperName,string ShipperPhone,string ShipperUnit,
string ShipperAddress,string ConsigneeName,string ConsigneePhone,string ConsigneeUnitID,
string ConsigneeAddress,string ClientPaymentWayID,string ClientPrepaidMoney,string Freight,
string Premium, string OtherCost, string InsuredMoney, string ReceivableCostNote)
{
//实例化配送订单表,对该表进行一一赋值
Models.PW_OrdersDistributionInformationTable myOrdersDistributionInformation = new Models.PW_OrdersDistributionInformationTable();
myOrdersDistributionInformation.OrdersNumber = OrdersNumber;
myOrdersDistributionInformation.OrdersTypeID = Convert.ToInt32(OrdersTypeID);
myOrdersDistributionInformation.UrgencyConditionID = Convert.ToInt32(UrgencyConditionID);
myOrdersDistributionInformation.ShipmentTime = Convert.ToDateTime(ShipmentTime);
myOrdersDistributionInformation.EstimatedArriveTime = Convert.ToDateTime(EstimatedArriveTime);
myOrdersDistributionInformation.TransportationWayID = Convert.ToInt32(TransportationWayID);
myOrdersDistributionInformation.DistributionAreaID = Convert.ToInt32(DistributionAreaID);
myOrdersDistributionInformation.ShipperName = ShipperName;
myOrdersDistributionInformation.ShipperPhone = ShipperPhone;
myOrdersDistributionInformation.ShipperUnit = ShipperUnit;
myOrdersDistributionInformation.ShipperAddress = ShipperAddress;
myOrdersDistributionInformation.ConsigneeName = ConsigneeName;
myOrdersDistributionInformation.ConsigneePhone = ConsigneePhone;
myOrdersDistributionInformation.ConsigneeUnitID = Convert.ToInt32(ConsigneeUnitID);
myOrdersDistributionInformation.ConsigneeAddress = ConsigneeAddress;
myOrdersDistributionInformation.ClientPaymentWayID = Convert.ToInt32(ClientPaymentWayID);
myOrdersDistributionInformation.ClientPrepaidMoney = ClientPrepaidMoney;
myOrdersDistributionInformation.Freight = Freight;
myOrdersDistributionInformation.Premium = Premium;
myOrdersDistributionInformation.OtherCost = OtherCost;
myOrdersDistributionInformation.InsuredMoney = InsuredMoney;
myOrdersDistributionInformation.ReceivableCostNote = ReceivableCostNote;
myDDGL.PW_OrdersDistributionInformationTable.AddObject(myOrdersDistributionInformation);//保存以上参数到数据库表
int i = myDDGL.SaveChanges();//保存该表的改变,改变成功时,i会大于0
if (i > 0)
{
int OrdersDistributionInformationID = (from tbOrdersInformation in myDDGL.PW_OrdersDistributionInformationTable select tbOrdersInformation.OrdersDistributionInformationID).Max();
return OrdersDistributionInformationID; //返回该数据的主键ID
}
else
{
return 0;
}
}
#endregion
/// <summary>
/// 接受界面层传过来的参数,新增配送的货品信息
/// </summary>
/// <param name="OrdersDistributionInformationID">订单配送信息ID</param>
/// <param name="GoodsID">货品ID</param>
/// <param name="Volume">体积</param>
/// <param name="Quantity">数量</param>
/// <param name="Note">备注</param>
/// <returns>Json</returns>
#region 新增配送明细
public ActionResult InsertOrdersDistributionDetailed(int OrdersDistributionInformationID,int GoodsID,
decimal Volume,decimal Quantity,string Note)
{
Models.PW_OrdersDistributionDetailedTable myOrdersDistributionDetailed = new Models.PW_OrdersDistributionDetailedTable();
myOrdersDistributionDetailed.OrdersDistributionInformationID = OrdersDistributionInformationID;
myOrdersDistributionDetailed.GoodsID = GoodsID;
myOrdersDistributionDetailed.Volume = Volume;
myOrdersDistributionDetailed.Quantity = Quantity;
myOrdersDistributionDetailed.Note = Note;
myDDGL.PW_OrdersDistributionDetailedTable.AddObject(myOrdersDistributionDetailed);//保存以上参数到数据库表
int i = myDDGL.SaveChanges(); //保存该表的改变,改变成功时,i会大于0
if (i > 0)
{
return Json("true", JsonRequestBehavior.AllowGet);
}
else
{
return Json("false", JsonRequestBehavior.AllowGet);
}
}
#endregion
#region 查询收货人信息
/// <summary>
/// 查询数据库,查询收货人信息,将查询出来的信息传去界面层
/// </summary>
/// <returns>Json</returns>
public ActionResult SelectClientConsigneeInformationTable()
{
var dtClientConsignee = from tbClientConsignee in myDDGL.SYS_ClientConsigneeInformationTable
join tbClient in myDDGL.SYS_ClientTable on tbClientConsignee.ClientID equals tbClient.ClientID
select new
{
ClientConsigneeInformationID = tbClientConsignee.ClientConsigneeInformationID,
ClientConsigneeName = tbClientConsignee.ClientConsigneeName,
ClientConsigneeAddress = tbClientConsignee.ClientConsigneeAddress,
ClientConsigneeNumber = tbClientConsignee.ClientConsigneeNumber,
ClientUnitName = tbClient.ClientUnitName,
};
List<Dictionary<string, object>> ListReturn = new List<Dictionary<string, object>>();
foreach (var item in dtClientConsignee)//循环数据库表,将该表的数据查询出来,转换为列表形式
{
Dictionary<string, object> itemClientConsignee = new Dictionary<string, object>();
foreach (System.Reflection.PropertyInfo p in item.GetType().GetProperties())
{
itemClientConsignee.Add(p.Name, p.GetValue(item, null));//数据库表的数控查询出来后,循环变成(键名,键值)形式
}
ListReturn.Add(itemClientConsignee);
}
return Json(ListReturn, JsonRequestBehavior.AllowGet);//返回Json格式
}
#endregion
第三步:视图层(Views)
配送订单界面效果截图:
HTML代码:
<!DOCTYPE html>
<html>
<head>
<meta content="text/javascript;charset=utf-8"/> //<head>标签里的是jQuery包的引用
<link rel="stylesheet" type="text/css" href="../../Content/themes/jquery-easyui-1.3.3/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="../../Content/themes/jquery-easyui-1.3.3/themes/icon.css"/>
<link rel="stylesheet" type="text/css" href="../../Content/themes/jquery-easyui-1.3.3/demo/demo.css"/>
<script type="text/javascript" src="../../Content/themes/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="../../Content/themes/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
</head>
<body>
<div class="easyui-tabs" style="border-style: none; margin-top: -18px; margin-left: -17px; margin-right: -18px;">
<div title="运 输 订 单">
<div class="easyui-tabs" style="border-width: thick; border-style: none;">
<div title="订单信息">
<div class="easyui-panel" style="border-style: none; width:auto; height:auto; border-radius:15px 15px 0px 0px;">
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">订单号:</strong></td>
<td><input type="text" id="txtDDH" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">业务类型:</strong></td>
<td><input class="easyui-combobox" id="cboYWLX" style="border-style: hidden hidden outset hidden; border-width: thin; width:150px; height:30px; " /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">起发站:</strong></td>
<td><input type="text" id="txtQFZ" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td><input type="button" onclick="OpenQiShiDi()" value="••" style="font-size: 13px;width:30px;height:30px; font-family: 楷体; color: #000000; font-weight: bold;" /></td>
<td align="right"><strong style="font-size: medium">目的站:</strong></td>
<td><input type="text" id="txtMDZ" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td><input type="button" onclick="OpenMuDiDi()" value="••" style="font-size: 13px;width:30px;height:30px; font-family: 楷体; color: #000000; font-weight: bold;" /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">取货时间:</strong></td>
<td><input class="easyui-datebox" id="datQHSJ" data-options="formatter:myformatter" style="border-style: hidden hidden outset hidden; border-width: thin; width:200px; height:30px; " /></td>
<td> </td> //formatter属性要在jQuery里写方法代码,不然界面会报错
<td align="right"><strong style="font-size: medium">到货时间:</strong></td>
<td><input class="easyui-datebox" id="datDHSJ" data-options="formatter:myformatter" style="border-style: hidden hidden outset hidden; border-width: thin; width:200px; height:30px; " /></td>
</tr> //formatter属性要在jQuery里写方法代码,不然界面会报错
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">是否取送:</strong></td>
<td><input type="checkbox" id="ckQuHuo"/></td>
<td><strong style="font-size: medium">取货</strong></td>
<td><input type="checkbox" id="ckSiongHuo"/></td>
<td><strong style="font-size: medium">送货</strong></td>
<td> </td><td> </td>
<td align="right"><strong style="font-size: medium">签单返回:</strong></td>
<td><input type="checkbox" id="ckYunDan"/></td>
<td><strong style="font-size: medium">运单</strong></td>
<td><input type="checkbox" id="ckKeDan"/></td>
<td><strong style="font-size: medium">客户单据</strong></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">托运人姓名:</strong></td>
<td><input type="text" id="txtXM" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">托运人电话:</strong></td>
<td><input type="text" id="txtDH" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">托运人单位:</strong></td>
<td><input type="text" id="txtDW" style="border-style: hidden hidden outset hidden; border-width: thin; width:550px; height:30px; " /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">托运人地址:</strong></td>
<td><input type="text" id="txtDZ" style="border-style: hidden hidden outset hidden; border-width: thin; width:550px; height:30px; " /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">托运人账号:</strong></td>
<td><input type="text" id="txtZH" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td><input type="button" value="••" style="font-size: 13px;width:30px;height:30px; font-family: 楷体; color: #000000; font-weight: bold;" /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">托运人邮编:</strong></td>
<td><input type="text" id="txtYB" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">客户经理:</strong></td>
<td><input type="text" id="txtJL" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">取货联系人:</strong></td>
<td><input type="text" id="txtQHLZR" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td><input type="button" value="••" style="font-size: 13px;width:30px;height:30px; font-family: 楷体; color: #000000; font-weight: bold;" /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">取货联系人电话:</strong></td>
<td><input type="text" id="txtLXRDH" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">取货地址:</strong></td>
<td><input type="text" id="txtQHDZ" style="border-style: hidden hidden outset hidden; border-width: thin; width:550px; height:30px; " /></td>
</tr>
<tr>
<td><input type="button" value="保存为客户" style="font-size: 18px;width:100px; font-family: 楷体; color: #CC33FF" /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">项目名称:</strong></td>
<td><input class="easyui-combobox" id="cboXMMC" style="border-style: hidden hidden outset hidden; border-width: thin; width:150px; height:30px; " /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">收货人姓名:</strong></td>
<td><input type="text" id="txtSHR" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">收货人电话:</strong></td>
<td><input type="text" id="txtSHRDH" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">收货人单位:</strong></td>
<td><input type="text" id="txtSHRDW" style="border-style: hidden hidden outset hidden; border-width: thin; width:550px; height:30px; " /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">收货人地址:</strong></td>
<td><input type="text" id="txtSHRDZ" style="border-style: hidden hidden outset hidden; border-width: thin; width:550px; height:30px; " /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">收货人账号:</strong></td>
<td><input type="text" id="txtSHRZH" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td><input type="button" value="••" style="font-size: 13px;width:30px;height:30px; font-family: 楷体; color: #000000; font-weight: bold;" /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">收货人邮编:</strong></td>
<td><input type="text" id="txtSHRYB" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
<tr>
<td><input type="button" value="保存收货人" style="font-size: 18px;width:100px; font-family: 楷体; color: #CC33FF" /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">运费:</strong></td>
<td><input type="text" id="txtYF" style="border-style: hidden hidden outset hidden; border-width: thin; width:150px; height:30px; " /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">杂费:</strong></td>
<td><input type="text" id="txtZF" style="border-style: hidden hidden outset hidden; border-width: thin; width:150px; height:30px; " /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">费用小计:</strong></td>
<td><input type="text" id="txtXJ" onclick="YunFeiXiaoJi()" style="border-style: hidden hidden outset hidden; border-width: thin; width:150px; height:30px; " /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">投保声明:</strong></td>
<td><select id="cboTBSM" style="border-width: thin; width:150px; height:30px; ">
<option value="true">是</option>
<option value="false">否</option></select></td>
<td> </td>
<td align="right"><strong style="font-size: medium">投保金额:</strong></td>
<td><input type="text" id="txtTBJE" style="border-style: hidden hidden outset hidden; border-width: thin; width:150px; height:30px; " /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">保险费:</strong></td>
<td><input type="text" id="txtBXF" style="border-style: hidden hidden outset hidden; border-width: thin; width:150px; height:30px; " /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">运杂费合计:</strong></td>
<td><input type="text" id="txtHJ" onclick="FeiYongHeJi()" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
<tr><td><input type="button" onclick="AnHeTongJiSuan()" value="按合同计算费用" style="font-size: 18px;width:100px; font-family: 楷体; color: #CC33FF" /></td></tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td><strong style="font-size: medium">结算方式:</strong></td>
<td><input type="radio" name="JS" id="TYRXianJie" /></td><td><strong style="font-size: medium">托运人现结</strong></td>
<td><input type="radio" name="JS" id="TYRYueJie" /></td><td><strong style="font-size: medium">托运人月结</strong></td>
<td><input type="radio" name="JS" id="SHRXianJie" /></td><td><strong style="font-size: medium">收货人现结</strong></td>
<td><input type="radio" name="JS" id="SHRYueJiee" /></td><td><strong style="font-size: medium">收货人月结</strong></td>
<td><input type="radio" name="JS" id="DSFFuFei" /></td><td><strong style="font-size: medium">第三方付费</strong></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">预收款:</strong></td>
<td><input type="text" id="txtYSK" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">付费账号:</strong></td>
<td><input type="text" id="txtFFZH" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
</table>
<table style="margin-left: 50px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">备注:</strong></td>
<td><input type="text" id="txtBZ" style="border-style: hidden hidden outset hidden; border-width: thin; width:550px; height:30px; " /></td>
</tr>
</table>
<table style="margin-left: 30px; margin-top: 10px;">
<tr>
<td align="right"><strong style="font-size: medium">制单人:</strong></td>
<td><input type="text" id="txtZDR" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
<tr>
<td align="right"><strong style="font-size: medium">受理日期:</strong></td>
<td><input class="easyui-datebox" id="txtSLRQ" data-options="formatter:myformatter" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
<td> </td>
<td align="right"><strong style="font-size: medium">受理单位:</strong></td>
<td><input type="text" id="txtSLDW" style="border-style: hidden hidden outset hidden; border-width: thin; width:300px; height:30px; " /></td>
</tr>
</table>
</div>
</div>
<div title="订单货品">
<div class="easyui-panel" style="border-style: none; width:auto; height:auto; border-radius:15px 15px 0px 0px;">
<table>
<tr>
<td><input type="button" onclick="SelectYunShuGoodsTable()" value="添加货品" style="font-size: 18px;width:100px; font-family: 楷体; color: #CC33FF" /></td>
</tr>
</table>
<table id="tb运输订单货品" class="easyui-datagrid" style="width:auto; height:200px;" data-options="singleSelect:true,scrolling:true,onClickRow:onClickRowQiYongEdit,onAfterEdit:onYunShuAfterEdit">
<thead>
<tr>
<th data-options="field:'GoodsID',width:50,align:'center',formatter:returnBtnYS"><img src="../../Content/图片/删除.jpg" /></th>
<th data-options="field:'GoodsCoding',width:100,editor:'true',align:'center'">货品编码</th>
<th data-options="field:'GoodsName',width:100,editor:'true',align:'center'">货品名称</th>
<th data-options="field:'Unit',width:100,editor:'combobox',align:'center'">单位</th>
<th data-options="field:'Volume',width:100,editor:'numberbox',align:'center'">体积</th>
<th data-options="field:'Quantity',width:100,editor:'numberbox',align:'center'">数量</th>
<th data-options="field:'Note',width:100,editor:'text',align:'center'">备注</th>
</tr>
</thead>
</table>
<table id="tb运输订单货品信息" class="easyui-datagrid" style="width:auto; height:200px;" data-options="singleSelect:true,scrolling:true,onDblClickRow:DblYunShuHuoPinDatagrid">
<thead>
<tr>
<th data-options="field:'GoodsID',width:100,hidden:true,align:'center'">货品ID</th>
<th data-options="field:'GoodsCoding',width:100,align:'center'">货品编码</th>
<th data-options="field:'GoodsName',width:100,align:'center'">货品名称</th>
<th data-options="field:'BarCode',width:100,align:'center'">条形码</th>
<th data-options="field:'SpellCode',width:100,align:'center'">拼音码</th>
<th data-options="field:'Standard',width:100,align:'center'">规格</th>
<th data-options="field:'UnitID',width:100,hidden:true,align:'center'">单位ID</th>
<th data-options="field:'Unit',width:100,align:'center'">单位</th>
<th data-options="field:'QualityID',width:100,hidden:true,align:'center'">质量ID</th>
<th data-options="field:'Quality',width:100,align:'center'">质量</th>
<th data-options="field:'Weight',width:100,align:'center'">重量</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<table style="margin-left: 400px;">
<tr>
<td><input type="button" onclick="InsertOrdersTransportationInformation()" value="提 交" style="font-size: 18px;width:100px; font-family: 楷体; color: #CC33FF" /></td>
</tr>
</table>
</div>
</div>
<div class="easyui-window" id="ShouHuoRenXinXi" title="收货人信息" style="border-style: none; width:400px; height:250px; border-radius:15px 15px 0px 0px;"
data-options="draggable:false,resizable:false,collapsible:false,minimizable:false,maximizable:false,closed:true">
<table id="tb收货人信息" class="easyui-datagrid" style="width:auto; height:auto;"
data-options="scrolling:true,singleSelect:true,onDblClickRow:DblShouHuoRen">
<thead>
<tr>
<th data-options="field:'ClientConsigneeInformationID',width:80,hidden:true,align:'center'">收货人ID</th>
<th data-options="field:'ClientConsigneeName',width:100,align:'center'">收货人姓名</th>
<th data-options="field:'ClientConsigneeAddress',width:100,align:'center'">收货人地址</th>
<th data-options="field:'ClientUnitName',width:80,align:'center'">收货人单位</th>
<th data-options="field:'ClientConsigneeNumber',width:80,align:'center'">收货人邮编</th>
</tr>
</thead>
</table>
</div>
</body>
</html>
jQuery代码:
<script type="text/javascript">
$(document).ready(function () {
cboBinDing();//HTML加载时,预先执行下拉框绑定方法
});
function returnBtnPS(GoodsID, row, rowIndex) {
return "<a href='javascript:PSShanChu(" + GoodsID + "," + rowIndex + ")'>" + '<img src="../../Content/图片/删除.jpg" />' + "</a>";//订单货品数据表格datagrid里添加删除按钮,点击删除图标执行下面删除方法
}
function PSShanChu(GoodsID, rowIndex) { //删除配送明细
$('#tb配送订单货品').datagrid('cancelEdit', editIndex)
.datagrid('deleteRow', editIndex);
}
function cboBinDing() { //配送订单各种下拉框的绑定
$.getJSON("/DingDanLuRu/cboBinDing?AttributeAssembleID=22",
function (data) {
$("#cboddlx").combobox({ data: data, valueField: 'AttributeDetailedID',
textField: 'AttributeDetailedName'
});
$("#cboddlx").combobox('select', 84); //默认选项
});
$.getJSON("/DingDanLuRu/cboBinDing?AttributeAssembleID=23",
function (data) {
$("#cbojjcd").combobox({ data: data, valueField: 'AttributeDetailedID',
textField: 'AttributeDetailedName'
});
});
$.getJSON("/DingDanLuRu/cboAreaTable", //区域绑定
function (data) {
$("#cbopsqy").combobox({ data: data, valueField: 'AreaID',
textField: 'AreaName'
});
});
}
//定义一个全局变量,并把它赋值为未定义
var editIndex = undefined;
//启用单元格编辑状态
function onClickRowQiYongEdit(index) {
if (editIndex != index) {
$('#tb配送订单货品').datagrid('beginEdit', index);
$('#tb配送订单货品').datagrid('endEdit', editIndex);
editIndex = index;
}
}
function SelectPeiSongGoodsTable() { //配送时单击添加货品,查询货品
$("#tb配送订单货品信息").datagrid({ url: "/DingDanLuRu/SelectGoodsTable" });
}
function DblPeiSongHuoPinDatagrid() { //双击事件,将货品信息更新到配送订单货品
var rowHuoPinDatagrid = $('#tb配送订单货品信息').datagrid('getSelected');
var rowMingXi = $('#tb配送订单货品').datagrid('getSelected');
$('#tb配送订单货品').datagrid('appendRow',
{ GoodsID: rowHuoPinDatagrid.GoodsID,
GoodsCoding: rowHuoPinDatagrid.GoodsCoding,
GoodsName: rowHuoPinDatagrid.GoodsName,
Standard: rowHuoPinDatagrid.Standard,
Volume: "0.00",
UnitID: rowHuoPinDatagrid.UnitID,
Unit: rowHuoPinDatagrid.Unit,
QualityID: rowHuoPinDatagrid.QualityID,
Quality: rowHuoPinDatagrid.Quality,
Quantity: "0.00"
});
editIndex = $('#tb配送订单货品').datagrid('getRows').length - 1;
$('#tb配送订单货品').datagrid('selectRow', editIndex);
$('#tb配送订单货品').datagrid('beginEdit', editIndex).datagrid('endEdit', editIndex - 1);
}
function onPeiSongAfterEdit(rowIndex, rowData, changes) { //当用户编辑完成时触发事件,获取编辑行的数据,在返回改变显示值
var dataMingXi = $('#tb配送订单货品').datagrid('getData');
var Batch = dataMingXi.rows[rowIndex].Batch;
var Quantity = dataMingXi.rows[rowIndex].Quantity;
var Note = dataMingXi.rows[rowIndex].Note;
$('#tb配送订单货品').datagrid('refreshRow', rowIndex); //refreshRow:刷新一行
}
OrdersDistributionInformationID = 0; //声明全局变量
function InsertOrdersDistributionInformation() { //新增配送订单信息
if (confirm("是否添加?")) {
try {
if (document.getElementById("Zhengche").checked) { //单选框的判断
TransportationWayID = 62;
} else if (document.getElementById("Lingdan").checked) {
TransportationWayID = 63;
} else if (document.getElementById("Peisong").checked) {
TransportationWayID = 64;
} else if (document.getElementById("Tielu").checked) {
TransportationWayID = 75;
} else if (document.getElementById("Kongyun").checked) {
TransportationWayID = 66;
}
if (document.getElementById("Daofu").checked) {
ClientPaymentWayID = 106;
} else if (document.getElementById("Qianfan").checked) {
ClientPaymentWayID = 107;
} else if (document.getElementById("Xianfu").checked) {
ClientPaymentWayID = 108;
} else if (document.getElementById("Yuejie").checked) {
ClientPaymentWayID = 109;
}
} catch (e) {
return null;
}
$.getJSON("/DingDanLuRu/InsertOrdersDistributionInformation?OrdersNumber=" + $('#txtddh').val() +
"&OrdersTypeID=" + $('#cboddlx').combobox('getValue') +
"&UrgencyConditionID=" + $('#cbojjcd').combobox('getValue') +
"&ShipmentTime=" + $('#datqysj').datebox('getValue') +
"&EstimatedArriveTime=" + $('#datyjddsj').datebox('getValue') +
"&TransportationWayID=" + TransportationWayID + //运输方式ID
"&DistributionAreaID=" + $('#cbopsqy').combobox('getValue') +
"&ShipperName=" + $('#txtxm').val() +
"&ShipperPhone=" + $('#txtdh').val() +
"&ShipperUnit=" + $('#txtdw').val() +
"&ShipperAddress=" + $('#txtdz').val() +
"&ConsigneeName=" + $('#txtshr').val() +
"&ConsigneePhone=" + $('#txtshrdh').val() +
"&ConsigneeUnitID=" + ClientConsigneeInformationID +
"&ConsigneeAddress=" + $('#txtshrdz').val() +
"&ClientPaymentWayID=" + ClientPaymentWayID + //付款方式
"&ClientPrepaidMoney=" + $('#txtyfje').val() +
"&Freight=" + $('#txtyf').val() +
"&Premium=" + $('#txtbxf').val() +
"&OtherCost=" + $('#txtqtfy').val() +
"&InsuredMoney=" + $('#txttbje').val() +
"&ReceivableCostNote=" + $('#txtysfybz').val(),
function (data) {
OrdersDistributionInformationID = data; //返回新增最大主键ID
if (data != null) {
InsertOrdersDistributionDetailed();//条件满足执行该方法
alert("添加成功!");
} else {
alert("添加失败!");
}
});
} else {
return null;
}
}
function InsertOrdersDistributionDetailed() { //新增配送明细
var dataMingXi = $('#tb配送订单货品').datagrid('getData');
for (var i = 0; i < dataMingXi.rows.length; i++) {
$.getJSON("/DingDanLuRu/InsertOrdersDistributionDetailed?OrdersDistributionInformationID=" + OrdersDistributionInformationID +
"&GoodsID=" + dataMingXi.rows[i].GoodsID +
"&Volume=" + dataMingXi.rows[i].Volume +
"&Quantity=" + dataMingXi.rows[i].Quantity +
"&Note=" + dataMingXi.rows[i].Note,
function (data) {
if (data == "false") {
alert("新增失败!");
}
});
}
}
function JiSuanZongJinE() { //计算总金额
var Freight = parseInt($('#txtyf').val());
var Premium = parseInt($('#txtbxf').val());
var OtherCost = parseInt($('#txtqtfy').val());
var InsuredMoney = parseInt($('#txttbje').val());
var ZongJinE = Freight + Premium + OtherCost + InsuredMoney;
$('#txtzje').val(ZongJinE);
}
function OpenShouHuoRen() { //打开收货人信息
$("#tb收货人信息").datagrid({ url: "/DingDanLuRu/SelectClientConsigneeInformationTable" });
$("#ShouHuoRenXinXi").window('open');
}
ClientConsigneeInformationID = 0;
function DblShouHuoRen() { //datagrid的双击事件
var row = $("#tb收货人信息").datagrid('getSelected');
if (row) {
ClientConsigneeInformationID = row.ClientConsigneeInformationID;
$('#txtshrdw').val(row.ClientUnitName);
$('#txtshrdz').val(row.ClientConsigneeAddress);
$("#ShouHuoRenXinXi").window('close');
}
}
</script>
仅供学习,禁止用于商业用途