配送领域属性维护
配送领域属性维护。主要是对本物流地点相关联领域进行新增/修改/删除,其他领域的属性只能查询。在本物流地点新增一个领域时,需要这里设置配送属性、配送方式、配送等级等,当开单人员新增货运单时会从这查询领域代码所对应的默认配送方式、和预计送达天数显示货运单开单界面提示开单人员选用。修改是对本物流地点相关联领域的配送属性、配送方式、配送等级、预计送达天数进行修改。
领域属性维护界面:
从界面上可以看到我们这里用到的控件有
控件名称 | 说明 |
单行文本控件(easyui-textbox) | 第一要设置每个控件的id,第二设置大小不设置也有默认 |
按钮(easyui-linkbutton) | |
数据列表(easyui-datagrid) |
|
下拉框(easyui-combobox) |
|
普通下拉框的加载:
脚本代码:
<pre class="javascript" name="code"> $.getJSON("/DeliveryFieldAddress/LogisticsPlace",// DeliveryFieldAddress是控//制器名称LogisticsPlace是控制器中的方法名
function (data) {
$("#cbo_LogisticsPlace").combobox({ data: data, valueField: 'LogisticsPlaceID', textField: 'LogisticsPlaceName' });
$("#cbo_SelectLogisticsPlace").combobox({ data: data, valueField: 'LogisticsPlaceID', textField: 'LogisticsPlaceName' });
}
);
界面html代码:
<pre class="html" name="code"><td align="right"">物流地点:</td><td> <input id="cbo_SelectLogisticsPlace" class="easyui-combobox" style="width:140px;font-family: 宋体, Arial, Helvetica, sans-serif; font-size: 15px;"></input></td><td style="width:40px;height:20px"></td>
Datagrid中下拉框的加载:
界面html代码:
<th data-options="field:'DeliveryWayID',formatter:myFormatterDeliveryWay,width:130,align:'center',editor:{
type:'combobox',
options:{
valueField:'MX_AttributeDetailedID',
textField:'AttributeDetailedName',
url:'/DeliveryFieldAddress/SelectAttributeGather?AttributeGatherID=1'
}
}" >配送方式</th>
在datagrid中获取下拉框的值或文本值的脚本中的代码:
var edPeiSongFangShi = $('#dgrd_DeliveryCarTimesReceipts').datagrid('getEditor', { index: EdIndex, field: 'SendWay' });
// EdIndex是行索引
$( edPeiSongFangShi.target).combobox("getText");//获取下拉框文本值
$( edPeiSongFangShi.target).combobox("getValue");//获取下拉框ID
领域属性维护用到的表有:领域属性维护表(DeliveryFieldServiceList)、物流地点表(LogisticsPlaceList)、属性明细表、地址领域表(FieldAddressList)、客户领域表(ClientFieldList)
领域属性维护表的字段:配送领域维护ID、物流地点ID、领域代码、配送属性ID、配送等级ID、配送方式ID、默认否、预计送达天数、删除否
列名 | 数据类型 | 主键/外键 | 说明 |
DeliveryFieldServiceID | Int | 主键 | 配送领域维护ID |
LogisticsPlaceID | Int | 外键 | 物流地点ID |
FieldWord | Char |
| 领域代码 |
SXMX_AttributeID | Int | 外键 | 配送属性ID |
DeliveryGradeID | Int | 外键 | 配送等级ID |
DeliveryWayID | Int | 外键 | 配送方式ID |
AdmitNO | Bit | 外键 | 默认否 |
PredictServiceDay | Char |
| 预计送达天数 |
DeleteNo | Bit |
| 删除否 |
关系图:
模块功能的具体实现
界面层功能的实现
//下面就是生成这个界面的Html代码:
<body>
<div class="easyui-window" title="领域属性维护" data-options="maximized:true,iconCls:'icon-采购'" style="width:300px;height:435px;padding:10px; top: 1px; left: 1px; background-color: #CCCCFF;">
<table >
<tr>
<td align="right">领域代码:</td><td> <input id="cbo_SelectFieldWord" style="width:140px"></input></td><td style="width:40px;height:20px"></td>
<td align="right"">物流地点:</td><td> <input id="cbo_SelectLogisticsPlace" class="easyui-combobox" style="width:140px;font-family: 宋体, Arial, Helvetica, sans-serif; font-size: 15px;"></input></td><td style="width:40px;height:20px"></td>
<td align="right">配送属性 :</td><td> <input id="cbo_SelectAttribute" class="easyui-combobox" style="width:140px; font-family: 宋体, Arial, Helvetica, sans-serif; font-size: 15px;"></input></td><td style="width:40px;height:20px"></td>
<td align="right">配送等级:</td><td><input id="cbo_SelectDeliveryGrade" class="easyui-combobox" style="width:140px; font-family: 宋体, Arial, Helvetica, sans-serif; font-size: 15px;"></input></td><td style="width:20px;height:10px"></td>
<td ><input " type="submit" οnclick="btn_Select()" value="查询" style="width:60px;color: #FF0000; font-size: 17px" /></td>
<td > <input " type="submit" οnclick="btn_Delete()" value="删除" style="width:60px;color: #FF0000; font-size: 17px" /></td>
</tr>
<tr style="height:10px"> </tr>
</table>
<table id="dgrd_DeliveryFieldService" class="easyui-datagrid" title="领域属性维护" style="width:1155px;height:370px;background-color: #CCCCCC;""
data-options="onClickRow:myonClickRow,rownumbers:true,singleSelect:true,onAfterEdit:onAfterEditXiuGai
,rowStyler:function(index,row){
if (index%2==0){
return 'background-color:#D1EEEE';
}
} " frame="border">
<thead>
<tr align="center">
<th data-options="field:'DeliveryFieldServiceID',width:8,hidden:true, align:'center'" bgcolor="#3333CC">配送领域维护ID</th>
<th data-options="field:'LogisticsPlaceName',width:130,align:'center'">物流地点</th>
<th data-options="field:'FieldWord',width:200,align:'center'">领域代码</th>
<th data-options="field:'SXMX_AttributeID',formatter:myFormatterAttribute, width:130,align:'center',editor:{
type:'combobox',
options:{
valueField:'MX_AttributeDetailedID',
textField:'AttributeDetailedName',
url:'/DeliveryFieldAddress/SelectAttributeGather?AttributeGatherID=2'
}
}">配送属性</th>
<th data-options="field:'DeliveryGradeID',formatter:myFormatterDeliveryGrade, width:130,align:'center',editor:{ @*datagrid中下拉框的绑定*@
type:'combobox',
options:{
valueField:'MX_AttributeDetailedID',
textField:'AttributeDetailedName',
url:'/DeliveryFieldAddress/SelectAttributeGather?AttributeGatherID=3'
}
}">配送等级</th>
<th data-options="field:'DeliveryWayID',formatter:myFormatterDeliveryWay,width:130,align:'center',editor:{
type:'combobox',
options:{
valueField:'MX_AttributeDetailedID',
textField:'AttributeDetailedName',
url:'/DeliveryFieldAddress/SelectAttributeGather?AttributeGatherID=1'
}
}" >配送方式</th>
<th data-options="field:'AdmitNO',width:138,align:'center',formatter:myFormatter">是否默认</th>
<th data-options="field:'PredictServiceDay',width:130,editor:{type:'numberbox'},align:'center'">预计送达天数</th>
<th data-options="field:'XianTiao',width:130,align:'center',formatter:myFormatterDelete">删除</th>
</tr>
</thead>
</table>
<table >
<tr style="width:10px;height:5px"> </tr>
<tr>
<td align="right">物流地点:</td><td><input readonly class="easyui-combobox" id="cbo_LogisticsPlace" style="width:140px;"></input></td> <td style="width:40px;height:20px"></td>
<td align="right">配送方式:</td><td> <input class="easyui-combobox" id="cbo_DeliveryWay" style="width:140px;"></input></td><td style="width:40px;height:20px"></td>
<td align="right">配送属性:</td><td><input class="easyui-combobox" id="cbo_AttributeDetailed" style="width:140px;"></input> </td><td style="width:40px;height:20px"></td>
<td align="right"> 配送等级:</td><td><input class="easyui-combobox" id="cbo_DeliveryGrade" style="width:140px;"></input></td>
<td> <input οnclick="btn_ClearAway()" type="submit" value="重填" style="width:60px;color: #FF0000; font-size: 17px" /></td>
</tr>
<tr style="width:140px;height:15px" ></tr>
<tr>
<td align="right"">选择方式:</td><td>
<select style="width:140px;" id="Select2">
<option value="1">依地址领域</option>
<option value="2">依客户领域</option>
</select></td> <td style="width:40px;height:20px"></td>
<td align="right"> 领域代码:</td><td><input readonly οnclick="txt_FieldAddress()" id="XingZengLingYuDaiMa"style="width:140px;"></input> </td><td style="width:40px;height:20px"></td>
<td align="right"> 是否默认:</td><td> <select id="Select1"style="width:140px;" >
<option value="true">是</option>
<option value="false">否</option>
</select> </td><td style="width:40px;height:20px"></td>
<td align="right"> 预计送达天数:</td><td> <input id="XinZengYuJiSongDaShiJian" style="width:140px;"></input></td>
<td> <input type="submit"οnclick="btn_InsertDeliveryFieldServiceInformation()" value="新增" style="width:60px;color: #FF0000; font-size: 17px" /></td>
</tr>
</table>
</div>
<div class="easyui-window" id="Wnd_FieldAddress" style="width:500px; height:300px; top:190px; left:2px; background-color: #9999FF;" title="领域代码">
<table class="easyui-datagrid" id="dgrd_FieldAddress" style="width:500px; height:300px" title="地址领域" data-options="onDblClickRow:youronDblClick,
singleSelect: true
">
<thead>
<tr>
<th data-options="field:'FieldID',width:130,hidden:true,align:'center'">ID</th>
<th data-options="field:'FieldWord',width:120,align:'center'">领域代码</th>
<th data-options="field:'Province',width:120,align:'center'">省份</th>
<th data-options="field:'City',width:120,align:'center'">城市</th>
<th data-options="field:'County',width:120,align:'center'">县区</th>
</tr>
</thead>
</table>
</div>
<div class="easyui-window" id="Wnd_ClientAddress" style="width:500px; height:300px; top:190px; left:2px; background-color: #9999FF;" title="领域代码">
<table class="easyui-datagrid" id="dgrd_ClientAddress" style="width:500px; height:300px" title="客户领域" data-options="
singleSelect: true,onDblClickRow:myonDblClick
">
<thead>
<tr>
<th data-options="field:'AddressID',width:130,hidden:true,align:'center'">ID</th>
<th data-options="field:'FieldWord',width:120,align:'center'">领域代码</th>
<th data-options="field:'AddressName',width:120,align:'center'">客户地址</th>
<th data-options="field:'ClientName',width:120,align:'center'">客户名称</th>
<th data-options="field:'ClientAbbreviation',width:120,align:'center'">客户简称</th>
</tr>
</thead>
</table>
</div>
</body>
//整个界面中脚本的代码:
<script type="text/javascript">
$(document).ready(function () {//执行完html代码后就执行此方法
CBO_BinDing();//在ready方法里调用下拉框绑定的方法
BinDingDatagrid();//在ready方法里调用datagrid加载的方法
$("#Wnd_FieldAddress").window("close");
//关闭地址领域窗体,Wnd_FieldAddress是窗体控件的id
$("#Wnd_ClientAddress").window("close");//关闭客户领域窗体
});
//领域地点信息的加载
function BinDingDatagrid(){
$.getJSON("/SettingDeliveryAttribute/SelectDeliveryFieldService",
// SettingDeliveryAttribute是控制器名SelectDeliveryFieldService是//SettingDeliveryAttribute控制器里的方法
function (data) {
//data是控制器返回的值,data是个参数可以随便写(如写dt、dn等)
// loadData是将参数data的值加载到datagrid里面
$("#dgrd_DeliveryFieldService").datagrid('loadData', data);
if (MyIndex != "") {
//判断全局变量MyIndex是否为空,如果不为空就执行下面开始编辑的方法
$('#dgrd_DeliveryFieldService').datagrid('beginEdit', MyIndex); }// MyIndex是行索引
}
);
}
function CBO_BinDing() {
$.getJSON("/DeliveryFieldAddress/SelectAttributeGather?AttributeGatherID=1",
function (data) {
$("#cbo_DeliveryWay").combobox({ data: data, valueField: 'MX_AttributeDetailedID', textField: 'AttributeDetailedName' });
// MX_AttributeDetailedID、AttributeDetailedName要以数据库查出来的列名保持一致
}
);
$.getJSON("/DeliveryFieldAddress/LogisticsPlace",
function (data) {
$("#cbo_LogisticsPlace").combobox({ data: data, valueField: 'LogisticsPlaceID', textField: 'LogisticsPlaceName' });
$("#cbo_SelectLogisticsPlace").combobox({ data: data, valueField: 'LogisticsPlaceID', textField: 'LogisticsPlaceName' });
//valueField是下拉框隐藏的值,textField是下拉框的文本值(显示出来能看得见的)
$("#cbo_LogisticsPlace").combobox("setValue",@Session["物流地点ID"]);//Session["物流地点ID"]是登陆时从控制器中传过来的值
}
);
$.getJSON("/DeliveryFieldAddress/SelectAttributeGather?AttributeGatherID=2",
//?后的是以控制器参数一致的参数(AttributeGatherID是以控制器参数一致的参数)
function (data) {
$("#cbo_AttributeDetailed").combobox({ data: data, valueField: 'MX_AttributeDetailedID', textField: 'AttributeDetailedName' });
$("#cbo_SelectAttribute").combobox({ data: data, valueField: 'MX_AttributeDetailedID', textField: 'AttributeDetailedName' });
}
);
$.getJSON("/DeliveryFieldAddress/SelectAttributeGather?AttributeGatherID=3",
function (data) {
$("#cbo_DeliveryGrade").combobox({ data: data, valueField: 'MX_AttributeDetailedID', textField: 'AttributeDetailedName' });
$("#cbo_SelectDeliveryGrade").combobox({ data: data, valueField: 'MX_AttributeDetailedID', textField: 'AttributeDetailedName' });
}
);
}
function myFormatterDelete(data, row, Index) {
//row参数为的值为一行数据,Index为行索引
if(row.LogisticsPlaceID==@Session["物流地点ID"]){
//判断一行数据是否属于本物流地点数据如果是就放回一个允许编辑的选择框否则返回一个不能编//辑的文本框
return '<input style="width:20px;height:20px" id="' + Index + '" type="checkbox" />';
}else{return '<input disabled style="width:20px;height:20px" id="' + Index + '" type="checkbox" />';}
}
var EdIndex = 0;
var MyIndex ="";
function myonClickRow(index, row) {
if (row.LogisticsPlaceID==@Session["物流地点ID"]) {
//判断点击的那一行数据是否属于本物流地点数据如果是就允许开始和结束编辑这一行数据否则不//能开始和结束编辑点击的那一行数据
MyIndex = index;
if (EdIndex != index) { $('#dgrd_DeliveryFieldService').datagrid('endEdit', EdIndex); }
$('#dgrd_DeliveryFieldService').datagrid('beginEdit', index);
EdIndex = index;
}
}
function btn_Delete() {
var Data = $("#dgrd_DeliveryFieldService").datagrid('getData');
//getData是获取datagrid的所有数据
for (i = 0; i < Data.rows.length; i++) {//遍历datagrid的数据
if (document.getElementById(i).checked == true) {
//如果删除的选择框被选中就执行下面删除一行数据的方法
$('#dgrd_DeliveryFieldService').datagrid('endEdit', EdIndex);
if (confirm("是否确定删除!")){
$.getJSON("/SettingDeliveryAttribute/DeleteDeliveryFieldServiceInformation?DeliveryFieldServiceID=" + Data.rows[i].DeliveryFieldServiceID, function (data) {
if (data ==1) { alert("删除成功!");
BinDingDatagrid(); //删除成功后重新加载数据给datagrid
}
else { alert("删除失败!"); }
}
);
}
}
}
}
//返回配送属性文本值
function myFormatterAttribute(index, row) {
return row.AttributeDetailedName;
}
//返回配送方式文本值
function myFormatterDeliveryWay(index, row) {
return row.DeliveryWay;
}
//返回配送等级文本值
function myFormatterDeliveryGrade(index, row) {
return row.DeliveryGrade;
}
//默认否
function myFormatter(bool) {
if (bool == true) {//如果参数bool等于true就返回‘是’给datagrid
return "是";
}
else {/如果参数bool不等于true就返回‘否’给datagrid
return "否";
}
}
//清空/重填
function btn_ClearAway() {
var ll = "";
$('#XingZengLingYuDaiMa').val("");//清空文本框的值
$('#XinZengYuJiSongDaShiJian').val("");
$('#cbo_LogisticsPlace').combobox("setValue", "");
$('#cbo_DeliveryWay').combobox("setValue", "");//清空下拉框的值
$('#cbo_AttributeDetailed').combobox("setValue", "");
$('#cbo_DeliveryGrade').combobox("setValue", "");
}
//点击新增按钮时触发此方法
function btn_InsertDeliveryFieldServiceInformation() {
//判断是否重复
$.getJSON("/SettingDeliveryAttribute/SelectLingYuShuXing?intLogisticsPlaceID=" + $('#cbo_LogisticsPlace').combobox("getValue") + "&strFieldWord=" + $('#XingZengLingYuDaiMa').val()
+ "&intSXMX_AttributeID=" + $('#cbo_AttributeDetailed').combobox("getValue") + "&intDeliveryWayID=" + $('#cbo_DeliveryWay').combobox("getValue"), function (data1) {
if (data1.length == 0) {
$.getJSON("/SettingDeliveryAttribute/SelectMoRenFanShi?strFieldWord=" + $('#XingZengLingYuDaiMa').val(), function (dt) {
if (dt.length > 0 && $('#Select1').val()=="true") {
//判断是否存在默认的配送方式,如果存在就提示‘该领域已存在默认配送方式’否则执行新增
alert("该领域已存在默认配送方式,请在’是默认否‘中选择否"); } else {
$.getJSON("/SettingDeliveryAttribute/InsertDeliveryFieldServiceInformation?LogisticsPlaceID=" + $('#cbo_LogisticsPlace').combobox("getValue") + "&FieldWord=" + $('#XingZengLingYuDaiMa').val()
+ "&AdmitNO=" + $('#Select1').val() + "&SXMX_AttributeID=" + $('#cbo_AttributeDetailed').combobox("getValue") + "&DeliveryGradeID=" + $('#cbo_DeliveryGrade').combobox("getValue") +
"&DeliveryWayID=" + $('#cbo_DeliveryWay').combobox("getValue") + "&PredictServiceDay=" + $('#XinZengYuJiSongDaShiJian').val() + "&", function (data) {
if (data == 1) { alert("新增成功!");
BinDingDatagrid();//新增成功后重新加载数据到datagrid中
}
else { alert("新增失败!"); }
});
}
});
}
else { alert("该领域属性已存在,不能进行新增"); }
});
}
var LogisticsPlaceID = 0;
var AttributeID = 0;
var DeliveryGradeID = 0;
//多条件查询
function btn_Select() {
if ($('#cbo_SelectLogisticsPlace').combobox("getValue") != "") {
LogisticsPlaceID = $('#cbo_SelectLogisticsPlace').combobox("getValue");
}
if ($('#cbo_SelectAttribute').combobox("getValue") != "") {
AttributeID = $('#cbo_SelectAttribute').combobox("getValue");
}
if ($('#cbo_SelectDeliveryGrade').combobox("getValue") != "") {
DeliveryGradeID = $('#cbo_SelectDeliveryGrade').combobox("getValue");
}
$.getJSON("/SettingDeliveryAttribute/MuchConditionSelectDeliveryFieldService?FieldWord=" + $('#cbo_SelectFieldWord').val() + "&LogisticsPlaceID=" + LogisticsPlaceID+ "&SXMX_AttributeID=" +
AttributeID+ "&DeliveryGradeID="+ DeliveryGradeID + "&", function (data) {
$("#dgrd_DeliveryFieldService").datagrid('loadData', data);
});
}
//点击修改按钮时触发此方法
function onAfterEditXiuGai(){
var Rows = $("#dgrd_DeliveryFieldService").datagrid('getChanges', 'updated');
//获取修改过的行数据
if (Rows.length > 0) {
if(confirm("是否确认修改")){
$.getJSON("/SettingDeliveryAttribute/UpdateDeliveryFieldServiceInformation?DeliveryFieldServiceID=" + Rows[0].DeliveryFieldServiceID + "&SXMX_AttributeID=" + Rows[0].SXMX_AttributeID + "&DeliveryGradeID="
+ Rows[0].DeliveryGradeID + "&DeliveryWayID=" + Rows[0].DeliveryWayID + "&PredictServiceDay=" + Rows[0].PredictServiceDay + "&", function (data) {
if (data == 1) {
alert("修改成功!");
BinDingDatagrid();
}
});
}
}
}
function txt_FieldAddress() {
$("#Select2").val();
if ($("#Select2").val() == "1") {
$("#Wnd_FieldAddress").window("open");
$("#Wnd_ClientAddress").window("close");
$.getJSON("/FreightReceiptsManage/SelectAddressFiled?FieldWord=" + "",
function (data) {
$("#dgrd_FieldAddress").datagrid('loadData', data);
});
}
if ($("#Select2").val() == "2") {
$("#Wnd_ClientAddress").window("open");
$("#Wnd_FieldAddress").window("close");
$.getJSON("/FreightReceiptsManage/SelectClientFiled",
function (data) {
$("#dgrd_ClientAddress").datagrid('loadData', data);
});
}
}
//双击地址领域窗体时触发此方法
function myonDblClick(index, Row) {
// index为双击那一行的索引Row为双击那一行的行数据
$("#XingZengLingYuDaiMa").val(Row.FieldWord);//文本框的赋值
$("#Wnd_ClientAddress").window("close");
}
function youronDblClick(index, Row) {
$("#XingZengLingYuDaiMa").val(Row.FieldWord);
$("#Wnd_FieldAddress").window("close");//关闭窗体
}
//下面是传值给界面的控制器的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
namespace 物流运交系统.Controllers//命名空间
{
public class SettingDeliveryAttributeController : Controller
{
BLLDeliveryFieldService.SettingDeliveryAttribute mySettingDeliveryAttribute = new BLLDeliveryFieldService.SettingDeliveryAttribute();//实例化逻辑层
//查询配送领域信息
public ActionResult SelectDeliveryFieldService()
{
DataTable dt = mySettingDeliveryAttribute.DeliveryFieldService();
// DeliveryFieldService方法是调用逻辑层的方法
List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
return Json(listReturn, JsonRequestBehavior.AllowGet);
// listReturn是数据列表,放回数据列表给界面
}
//删除配送领域信息
public ActionResult DeleteDeliveryFieldServiceInformation(int DeliveryFieldServiceID)
// DeliveryFieldServiceID是整形参数,ActionResult是返回值的类型
{
int i = mySettingDeliveryAttribute.DeleteDeliveryFieldServiceInformation(DeliveryFieldServiceID
// DeleteDeliveryFieldServiceInformation方法是调用逻辑层的方法
);
return Json(i, JsonRequestBehavior.AllowGet);
}
//新增配送领域信息
public ActionResult InsertDeliveryFieldServiceInformation(int LogisticsPlaceID, string FieldWord, string AdmitNO, int SXMX_AttributeID, int DeliveryGradeID, int DeliveryWayID, string PredictServiceDay)
//LogisticsPlaceID、FieldWord这些参数以界面传过来的参数一致
{
var AdmitNO1 = Convert.ToBoolean(AdmitNO);//将参数AdmitNO强制转换为布尔值
int i = mySettingDeliveryAttribute.InsertDeliveryFieldServiceInformation(LogisticsPlaceID, FieldWord, AdmitNO1, SXMX_AttributeID, DeliveryGradeID, DeliveryWayID, PredictServiceDay);
return Json(i, JsonRequestBehavior.AllowGet);
}
//修改配送领域信息
public ActionResult UpdateDeliveryFieldServiceInformation(int DeliveryFieldServiceID, int SXMX_AttributeID, int DeliveryGradeID, int DeliveryWayID, string PredictServiceDay)
{
int i = mySettingDeliveryAttribute.UpdateDeliveryFieldServiceInformation(DeliveryFieldServiceID, SXMX_AttributeID, DeliveryGradeID, DeliveryWayID, PredictServiceDay);
return Json(i, JsonRequestBehavior.AllowGet); //JsonRequestBehavior.AllowGet允许界面获取控制器传的值
}
//多条件查询配送领域信息
public ActionResult MuchConditionSelectDeliveryFieldService(string FieldWord, int LogisticsPlaceID, int SXMX_AttributeID, int DeliveryGradeID)
{
DataTable dt = mySettingDeliveryAttribute.MuchConditionSelectDeliveryFieldService(FieldWord, LogisticsPlaceID, SXMX_AttributeID, DeliveryGradeID);
List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
return Json(listReturn, JsonRequestBehavior.AllowGet);
}
// --查询是否有相同的领域属性
public ActionResult SelectLingYuShuXing(int intLogisticsPlaceID, string strFieldWord, int intSXMX_AttributeID, int intDeliveryWayID)
{
DataTable dt = mySettingDeliveryAttribute.SelectLingYuShuXing(intLogisticsPlaceID,strFieldWord,intSXMX_AttributeID,intDeliveryWayID);
List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
return Json(listReturn, JsonRequestBehavior.AllowGet);
}
// --查询是否存在相同的默认配送方式
public ActionResult SelectMoRenFanShi(string strFieldWord)
// strFieldWord参数是从界面传过来的领域代码
{
DataTable dt = mySettingDeliveryAttribute.SelectMoRenFanShi(strFieldWord);
List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
return Json(listReturn, JsonRequestBehavior.AllowGet);
}
//视图
public ActionResult SettingDeliveryAttribute()
{
return View();
}
}
}
//下面是传值给控制器的逻辑层的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace BLLDeliveryFieldService
{
public class SettingDeliveryAttribute
{
DALPublic.DALMethod myDALMethod = new DALPublic.DALMethod();//实例化数据层
//查询配送领域信息
public DataTable DeliveryFieldService()
{
SqlParameter[] SQL ={// SqlParameter[]为参数数组将所有参数放到数据里面
new SqlParameter("@type",SqlDbType.Char),
};
SQL[0].Value = "ChaXunPeiSongLingYuWeiHuXingXi";
DataTable dt = myDALMethod.DAL_SelectDB_Par("DeliveryFeild", SQL);
return dt;
}
//删除配送领域信息
public int DeleteDeliveryFieldServiceInformation(int DeliveryFieldServiceID)
{
SqlParameter[] SQL ={// SqlParameter[]是参数数组将参数传给数据库的存储过程
new SqlParameter("@type",SqlDbType.Char),
new SqlParameter("@DeliveryFieldServiceID",SqlDbType.Int),
};
SQL[0].Value = "ShanChuLingYuWeiHuXingXi";
SQL[1].Value = DeliveryFieldServiceID;
int i = myDALMethod.DAL_OPTableDB_Par("DeliveryFeild", SQL);
return i;
}
//新增配送领域信息
public int InsertDeliveryFieldServiceInformation(int LogisticsPlaceID, string FieldWord, bool AdmitNO, int SXMX_AttributeID, int DeliveryGradeID, int DeliveryWayID, string PredictServiceDay)
{
SqlParameter[] SQL ={ new SqlParameter("@type",SqlDbType.Char),
new SqlParameter("@LogisticsPlaceID",SqlDbType.Int),
new SqlParameter("@FieldWord",SqlDbType.Char),
new SqlParameter("@AdmitNO",SqlDbType.Bit),
new SqlParameter("@SXMX_AttributeID",SqlDbType.Int),
new SqlParameter("@DeliveryGradeID",SqlDbType.Int),
new SqlParameter("@DeliveryWayID",SqlDbType.Int),
new SqlParameter("@PredictServiceDay",SqlDbType.Char),
};
SQL[0].Value = "XinZengPeiSongLingYuWeiHu";
SQL[1].Value = LogisticsPlaceID;
SQL[2].Value = FieldWord;
SQL[3].Value = AdmitNO;
SQL[4].Value = SXMX_AttributeID;
SQL[5].Value = DeliveryGradeID;
SQL[6].Value = DeliveryWayID;
SQL[7].Value = PredictServiceDay;
int i = myDALMethod.DAL_OPTableDB_Par("DeliveryFeild", SQL);
// DeliveryFeild是存储过程名称
return i;
}
//修改配送领域信息
public int UpdateDeliveryFieldServiceInformation(int DeliveryFieldServiceID, int SXMX_AttributeID, int DeliveryGradeID, int DeliveryWayID, string PredictServiceDay)
{
SqlParameter[] SQL ={ new SqlParameter("@type",SqlDbType.Char),
new SqlParameter("@SXMX_AttributeID",SqlDbType.Int),
new SqlParameter("@DeliveryGradeID",SqlDbType.Int),
new SqlParameter("@DeliveryWayID",SqlDbType.Int),
new SqlParameter("@PredictServiceDay",SqlDbType.Char),
new SqlParameter("@DeliveryFieldServiceID",SqlDbType.Int),
};
SQL[0].Value = "XiuGaiPeiSongLingYuXinXi";
SQL[1].Value = SXMX_AttributeID;
SQL[2].Value = DeliveryGradeID;
SQL[3].Value = DeliveryWayID;
SQL[4].Value = PredictServiceDay;
SQL[5].Value = DeliveryFieldServiceID;
int i = myDALMethod.DAL_OPTableDB_Par("DeliveryFeild", SQL);
return i;
}
public DataTable MuchConditionSelectDeliveryFieldService(string FieldWord, int LogisticsPlaceID, int SXMX_AttributeID, int DeliveryGradeID)
{
SqlParameter[] SQL ={ new SqlParameter("@type",SqlDbType.Char),
new SqlParameter("@FieldWord",SqlDbType.Char),
new SqlParameter("@LogisticsPlaceID",SqlDbType.Int),
new SqlParameter("@SXMX_AttributeID",SqlDbType.Int),
new SqlParameter("@DeliveryGradeID",SqlDbType.Int),
};
SQL[0].Value = "MuchConditionSelectDeliveryFieldService";
SQL[1].Value = FieldWord;
SQL[2].Value = LogisticsPlaceID;
SQL[3].Value = SXMX_AttributeID;
SQL[4].Value = DeliveryGradeID;
DataTable dt = myDALMethod.DAL_SelectDB_Par("DeliveryFeild", SQL);
// DAL_SelectDB_Par是数据层的方法此方法的返回值是DataTable
return dt;
}
// --查询是否有相同的领域属性
public DataTable SelectLingYuShuXing(int intLogisticsPlaceID, string strFieldWord, int intSXMX_AttributeID, int intDeliveryWayID)
{
SqlParameter[] SQL ={ new SqlParameter("@type",SqlDbType.Char),
new SqlParameter("@LogisticsPlaceID",SqlDbType.Int),
new SqlParameter("@FieldWord",SqlDbType.Char),
new SqlParameter("@SXMX_AttributeID",SqlDbType.Int),
new SqlParameter("@DeliveryWayID",SqlDbType.Int),
};
SQL[0].Value = "SelectLingYuShuXing";
SQL[1].Value = intLogisticsPlaceID;
SQL[2].Value = strFieldWord;
SQL[3].Value = intSXMX_AttributeID;
SQL[4].Value = intDeliveryWayID;
DataTable dt = myDALMethod.DAL_SelectDB_Par("DeliveryFeild", SQL);
return dt;
}
// --查询是否存在相同的默认配送方式
public DataTable SelectMoRenFanShi(string strFieldWord)
{
SqlParameter[] SQL ={ new SqlParameter("@type",SqlDbType.Char),
new SqlParameter("@FieldWord",SqlDbType.Char),
};
SQL[0].Value = "SelectMoRenFanShi";
SQL[1].Value = strFieldWord;
DataTable dt = myDALMethod.DAL_SelectDB_Par("DeliveryFeild", SQL);
return dt;
}
}
}
//下面传值给逻辑层的存储过程的代码:
--多条件模糊查询配送领域维护
If @type='MuchConditionSelectDeliveryFieldService'
begin
if @FieldWord!=''
begin
set @sql=' where FieldWord like ''%'+LTRIM(RTRIM(@FieldWord))+'%'''
end
if @LogisticsPlaceID !=''
begin
if @sql !=''
set @sql=@sql+' and LogisticsPlaceList.LogisticsPlaceID like ''%'+LTRIM(RTRIM(@LogisticsPlaceID))+'%'''
else set @sql=' where LogisticsPlaceList.LogisticsPlaceID like ''%'+LTRIM(RTRIM(@LogisticsPlaceID))+'%'''
end
if @SXMX_AttributeID !=''
begin
if @sql !=''
set @sql=@sql+' and SXMX_AttributeID like ''%'+LTRIM(RTRIM(@SXMX_AttributeID))+'%'''
else set @sql=' where SXMX_AttributeID like ''%'+LTRIM(RTRIM(@SXMX_AttributeID))+'%'''
end
if @DeliveryGradeID !=''
begin
if @sql !=''
set @sql=@sql+' and DeliveryGradeID like ''%'+LTRIM(RTRIM(@DeliveryGradeID))+'%'''
else set @sql=' where DeliveryGradeID like ''%'+LTRIM(RTRIM(@DeliveryGradeID))+'%'''
end
exec('SELECT LogisticsPlaceList.LogisticsPlaceID,LogisticsPlaceList.LogisticsPlaceName, MX_AttributeDetailedList.AttributeDetailedName, MX_AttributeDetailedList_1.AttributeDetailedName AS DeliveryGrade,
MX_AttributeDetailedList_2.AttributeDetailedName AS DeliveryWay, DeliveryFieldServiceList.DeliveryFieldServiceID, DeliveryFieldServiceList.LogisticsPlaceID, DeliveryFieldServiceList.FieldWord,
RTRIM(DeliveryFieldServiceList.SXMX_AttributeID) as SXMX_AttributeID, RTRIM(DeliveryFieldServiceList.DeliveryGradeID)as DeliveryGradeID, DeliveryFieldServiceList.AdmitNO, RTRIM(DeliveryFieldServiceList.PredictServiceDay)as PredictServiceDay,
RTRIM(DeliveryFieldServiceList.DeliveryWayID)as DeliveryWayID
FROM MX_AttributeDetailedList AS MX_AttributeDetailedList_2 INNER JOIN
MX_AttributeDetailedList INNER JOIN
LogisticsPlaceList INNER JOIN
DeliveryFieldServiceList ON LogisticsPlaceList.LogisticsPlaceID = DeliveryFieldServiceList.LogisticsPlaceID ON MX_AttributeDetailedList.MX_AttributeDetailedID = DeliveryFieldServiceList.SXMX_AttributeID INNER JOIN
MX_AttributeDetailedList AS MX_AttributeDetailedList_1 ON DeliveryFieldServiceList.DeliveryGradeID = MX_AttributeDetailedList_1.MX_AttributeDetailedID ON MX_AttributeDetailedList_2.MX_AttributeDetailedID = DeliveryFieldServiceList.DeliveryWayID
'+@sql)
return
end
--查询配送领域维护
if @type='ChaXunPeiSongLingYuWeiHuXingXi'
begin
SELECT DeliveryFieldServiceList.DeleteNo,LogisticsPlaceList.LogisticsPlaceName, MX_AttributeDetailedList.AttributeDetailedName, MX_AttributeDetailedList_1.AttributeDetailedName AS DeliveryGrade,
MX_AttributeDetailedList_2.AttributeDetailedName AS DeliveryWay, DeliveryFieldServiceList.DeliveryFieldServiceID, DeliveryFieldServiceList.LogisticsPlaceID, DeliveryFieldServiceList.FieldWord,
RTRIM(DeliveryFieldServiceList.SXMX_AttributeID) as SXMX_AttributeID, RTRIM(DeliveryFieldServiceList.DeliveryGradeID)as DeliveryGradeID, DeliveryFieldServiceList.AdmitNO, RTRIM(DeliveryFieldServiceList.PredictServiceDay)as PredictServiceDay,
RTRIM(DeliveryFieldServiceList.DeliveryWayID)as DeliveryWayID
FROM MX_AttributeDetailedList AS MX_AttributeDetailedList_2 INNER JOIN
MX_AttributeDetailedList INNER JOIN
LogisticsPlaceList INNER JOIN
DeliveryFieldServiceList ON LogisticsPlaceList.LogisticsPlaceID = DeliveryFieldServiceList.LogisticsPlaceID ON MX_AttributeDetailedList.MX_AttributeDetailedID = DeliveryFieldServiceList.SXMX_AttributeID INNER JOIN
MX_AttributeDetailedList AS MX_AttributeDetailedList_1 ON DeliveryFieldServiceList.DeliveryGradeID = MX_AttributeDetailedList_1.MX_AttributeDetailedID ON MX_AttributeDetailedList_2.MX_AttributeDetailedID = DeliveryFieldServiceList.DeliveryWayID
GROUP BY DeliveryFieldServiceList.DeleteNo,LogisticsPlaceList.LogisticsPlaceName, MX_AttributeDetailedList.AttributeDetailedName, MX_AttributeDetailedList_1.AttributeDetailedName,
MX_AttributeDetailedList_2.AttributeDetailedName, DeliveryFieldServiceList.DeliveryFieldServiceID, DeliveryFieldServiceList.LogisticsPlaceID, DeliveryFieldServiceList.FieldWord,
DeliveryFieldServiceList.SXMX_AttributeID,DeliveryFieldServiceList.DeliveryGradeID, DeliveryFieldServiceList.AdmitNO,DeliveryFieldServiceList.PredictServiceDay,
DeliveryFieldServiceList.DeliveryWayID
having DeliveryFieldServiceList.DeleteNo='False'
end
--新增配送领域维护
if @type='XinZengPeiSongLingYuWeiHu'
begin
insert into DeliveryFieldServiceList(LogisticsPlaceID, FieldWord,AdmitNO, SXMX_AttributeID,
DeliveryGradeID, DeliveryWayID, PredictServiceDay,DeleteNo)
values (LTRIM(RTRIM(@LogisticsPlaceID)), LTRIM(RTRIM(@FieldWord)),
LTRIM(RTRIM(@AdmitNO)), LTRIM(RTRIM(@SXMX_AttributeID)), LTRIM(RTRIM(@DeliveryGradeID))
, LTRIM(RTRIM(@DeliveryWayID)), LTRIM(RTRIM(@PredictServiceDay)),'False')
end
--修改配送领域信息
if @type='XiuGaiPeiSongLingYuXinXi'
update DeliveryFieldServiceList set SXMX_AttributeID=LTRIM(RTRIM(@SXMX_AttributeID)),
-- LTRIM、RTRIM分别是左去空格和右去空格
DeliveryGradeID=LTRIM(RTRIM(@DeliveryGradeID)), DeliveryWayID=LTRIM(RTRIM(@DeliveryWayID)),
PredictServiceDay=LTRIM(RTRIM(@PredictServiceDay))
where DeliveryFieldServiceID=@DeliveryFieldServiceID
--删除配送领域信息
if @type='ShanChuLingYuWeiHuXingXi'
begin
update DeliveryFieldServiceList set DeliveryFieldServiceList.DeleteNo='True'
where DeliveryFieldServiceList.DeliveryFieldServiceID=@DeliveryFieldServiceID
end