单据还原
单据还原是对已经作废的单据进行还原处理,还原后的单据又可以进行派车作业
单据还原界面:
单据还原用到的表:
货运单表(FreightReceiptsList)、属性明细表(MX_AttributeDetailedList)
货运单表的字段有:货运单ID、取送单号、公司ID、寄件客户ID 收件客户ID、接单时间、要求送达时间、寄件地址、审核否、收件地址、付款条件ID、货运单状态ID、签收确认ID、备注、开单人ID、寄件领域、领域属性维护ID、签收单状态 类别、配送方式、扣帐时间
表名 | 数据类型 | 主键/外键 | 说明 |
FreightReceiptsID | Int | 主键 | 货运单ID |
SendNumber | Char |
| 取送单号 |
CompanyID | Int | 外键 | 公司ID |
SendClientID | Int | 外键 | 寄件客户ID |
CollectClientID | Int | 外键 | 收件客户ID |
ConnectTime | datetime |
| 接单时间 |
RequireServiceTime | datetime |
| 要求送达时间 |
SendAddress | char |
| 寄件地址 |
CheckNo | bit |
| 审核否 |
DeliveryFieldServiceID | Int | 外键 | 领域属性维护ID |
PayCondition | Int | 外键 | 付款条件ID |
FreightReceiptsStateID | Int | 外键 | 货运单状态ID |
SignForStateID | Int | 外键 | 签收确认ID |
Remark | Char |
| 备注 |
StaffID | Int | 外键 | 开单人ID |
SendFieldWord | Char |
| 寄件领域 |
DeliveryFieldServiceID | Int | 外键 | 领域属性维护ID |
SignFor | Int | 外键 | 签收单状态ID |
ClassesID | Int | 外键 | 类别 |
DeliveryWayID | Int | 外键 | 配送方式 |
DductTime | datetime |
| 扣帐时间 |
属性明细表的字段:属性明细ID、属性明细名称、属性集合ID
列名 | 数据类型 | 主键/外键 | 说明 |
MX_AttributeDetailedID | Int | 主键 | 属性明细ID |
AttributeDetailedName | Char |
| 属性明细名称 |
AttributeGatherID | Int | 外键 | 属性集合ID |
关系图:
模块功能的具体实现
//单据还原界面的Html代码:
<body>
<table id="dgrd_ReceiptsRestore" class="easyui-datagrid" title="单据还原" style="width:1100px;height:360px;background-color: #CCCCCC;"
data-options="rownumbers:true,singleSelect:true
,rowStyler:function(index,row){@*返回颜色给行*@
if (index%2==0){
return 'background-color:#D1EEEE';
}
} " frame="border">
<thead>
<tr align="center">
<th data-options="field:'DeliverReceiptsID',width:8,hidden:true, align:'center'" bgcolor="#3333CC">发车单据ID</th>
<th data-options="field:'CompanyName',width:150,align:'center'">公司</th>
<th data-options="field:'SendNumber',width:150,align:'center'">取送单号</th>
<th data-options="field:'CollectFieldWord',width:80,align:'center'">运交领域</th>
<th data-options="field:'ClientName1',width:100,align:'center'" style="color: #FF3300; font-size: 17px; font-family: 华文行楷">取送客户</th>
<th data-options="field:'AttributeDetailedName',width:100,align:'center'" style="color: #FF3300; font-size: 17px; font-family: 华文行楷">类别</th>
<th data-options="field:'CarTimes',width:70,align:'center' ">车次</th>
<th data-options="field:'DrawOutUnusualID',width:70,align:'center',formatter:DrawOutformatter">出车</th>
<th data-options="field:'ReturnCarUnusualIID',width:70,align:'center',formatter:ReturnCarformatter">返车</th>
<th data-options="field:'ReturnCarUnusualIName',width:100,align:'center',formatter:zhujiformatter">注记</th>
<th data-options="field:'shf',width:70,align:'center',formatter:myFormatter">还原</th>
<th data-options="field:'BoxCount',width:70,align:'center'">箱</th>
<th data-options="field:'Remark',width:70,align:'center',hidden:true"></th>
<th data-options="field:'CollectAddress',width:250,align:'center'">取送地址</th>
</tr>
</thead>
</table>
<center><input " type="submit"οnclick="btn_ReceiptsRestore()" value="单据还原" style="width:100px;color: #FF0000; font-size: 17px" />
</center>
</body>
//单据还原界面脚本代码:
<script type="text/javascript">
$(document).ready(function(){
BinDingDatagrid();
});
function BinDingDatagrid(){
if (parent.PanDuan() == 0) { //parent.PanDuan()是调用父网页区的方法,PanDuan()是父网页区中的方法
$.getJSON("/DrawOutAndReturnCar/SelecteReceiptsRestore?strCarTimes=" + "" + "&strSendNumber=" + "" + "&intCompanyID=" + 0 + "&",
function (data) {//没有选择条件时查询出所有作废的单据绑定到datagrid中
$("#dgrd_ReceiptsRestore").datagrid('loadData', data);
});
}
else {//有条件查询作废的单据绑定到datagrid中
$.getJSON("/DrawOutAndReturnCar/SelecteReceiptsRestore?strCarTimes=" + parent.CarTimes() + "&strSendNumber=" + parent.SendNumber() + "&intCompanyID=" + parent.CompanyID() + "&",
function (data){
$("#dgrd_ReceiptsRestore").datagrid('loadData', data);
});
}
}
//当datagrid中加载每一行数据时触发此方法返回一个选择框
function myFormatter(data, row, Index) {
return '<input style="width:20px;height:20px" id="HuanYuan'+ Index +'" type="checkbox" />';
}
//当datagrid中的行数据发生变化时触发此方法
function DrawOutformatter(data, row, Index) {//参数data为单元格的值,row为行数据,Index为行索引
if (data == 2) { return "不再派车"; }
else {
if (data == 0) { return "未出车"; } else { return "已出车"; }
}
}
//当datagrid中的行数据发生变化时触发此方法
function ReturnCarformatter(data, row, Index) {//参数data为单元格的值,row为行数据,Index为行索引
if (data == 2) { return "不再派车"; } else { return "未返车"; }
}
function zhujiformatter(data, row, Index) {
if (row.DrawOutUnusualReason.trim().length > 0 && data != -1) {//判断是否存在出车异常原因
return row.DrawOutUnusualReason.trim();
}
else {//存在返车异常原因时执行else下面的方法
if (data == -1) { return ""; }
else {
return row.MX_ReturnCarUnusualIIName.trim(); //返回返车异常原因信息
}
}
}
var panduan = 0;
var DJBZ = "";
//点击’单据还原‘按钮时触发此方法
function btn_ReceiptsRestore() {
var FuZhu = 1;
var Rows = $("#dgrd_ReceiptsRestore").datagrid("getRows");//获取datagrid中所有的数据
for (var i = 0; i < Rows.length; i++) {//遍历循环datagrid中的数据
if (document.getElementById("HuanYuan" + i).checked == true) { //判断单据还原的选择框是否选中,如果选中执行if里面的方法
panduan = 1;
DJBZ = "";
if (Rows[i].Remark != null) {
DJBZ = Rows[i].Remark; //获取选中要还原的单据的备注赋值给参数DJBZ
}
$.getJSON("/DrawOutAndReturnCar/updateDeliverReceiptsList?intMX_DeliveryCarTimesServiceID=" + Rows[i].DeliverReceiptsID + "&intFreightReceiptsID=" + Rows[i].FreightReceiptsID+"&strRemark="+DJBZ);
Rows[i].DrawOutUnusualID = 0; Rows[i].ReturnCarUnusualIID = 4; Rows[i].ReturnCarUnusualIName = -1;
$("#dgrd_ReceiptsRestore").datagrid("refreshRow", i);
alert("还原成功!");
}
else {
if (panduan == 0 && FuZhu==1) {//判断是否选中要还原的单据
alert("请选择要进行还原的单据!");
panduan = 0;
FuZhu = 2;
}
}
}
}
</script>
//下面是接收从界面传值的控制器的代码:
//查询单据还原信息
public ActionResult SelecteReceiptsRestore(string strCarTimes, string strSendNumber, int intCompanyID)//参数strCarTimes为车次、strSendNumber为取送单号、intCompanyID为公司ID
{
DataTable dt = myDrawOutAndReturnCar.SelecteReceiptsRestore(strCarTimes, strSendNumber, intCompanyID);
StringBuilder stringbuilder = new StringBuilder();
DataView dv = new DataView(dt);
dv.RowFilter = "FreightReceiptsStateID <> 43";//过滤出货运单状态为作废的单据
DataTable dtChild = dv.ToTable();
List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dtChild);
return Json(listReturn, JsonRequestBehavior.AllowGet);
}
//修改单据还原
public ActionResult updateDeliverReceiptsList(int intMX_DeliveryCarTimesServiceID, int intFreightReceiptsID, string strRemark)
{
string date =strRemark+" 该单据于 "+ DateTime.Now.ToShortDateString()+" 作了单据还原";//记录单据还原时间
int i = myDrawOutAndReturnCar.updateDeliverReceiptsList(intMX_DeliveryCarTimesServiceID, intFreightReceiptsID, date);
return Json(i, JsonRequestBehavior.AllowGet);
}
//下面是接收从控制器传值的逻辑层的代码:
//查询单据还原信息
public DataTable SelecteReceiptsRestore(string strCarTimes, string strSendNumber, int intCompanyID)
{
SqlParameter[] SQL ={
new SqlParameter("@type",SqlDbType.Char),
new SqlParameter("@CarTimes",SqlDbType.Char),
new SqlParameter("@SendNumber",SqlDbType.Char),
new SqlParameter("@CompanyID",SqlDbType.Int),
};
SQL[0].Value = "SelecteReceiptsRestore";
SQL[1].Value =strCarTimes;
SQL[2].Value =strSendNumber;
SQL[3].Value = intCompanyID;
DataTable dt = myDALMethod.DAL_SelectDB_Par("SendCar", SQL);
return dt;
}
//修改单据还原
public int updateDeliverReceiptsList(int intMX_DeliveryCarTimesServiceID, int intFreightReceiptsID, string strRemark)
{
SqlParameter[] SQL ={
new SqlParameter("@type",SqlDbType.Char),
new SqlParameter("@MX_DeliveryCarTimesServiceID",SqlDbType.Int),
new SqlParameter("@FreightReceiptsID",SqlDbType.Int),
new SqlParameter("@Remark",SqlDbType.Char),
};
SQL[0].Value = "updateDeliverReceiptsList";
SQL[1].Value = intMX_DeliveryCarTimesServiceID;
SQL[2].Value = intFreightReceiptsID;
SQL[3].Value = strRemark;
int i = myDALMethod.DAL_OPTableDB_Par("SendCar", SQL);
return i;
}
//下面是存储过程的代码:
--单据还原
if @type='SelecteReceiptsRestore'
begin
if @CarTimes!=''
begin
set @sql=' where MX_DeliveryCarTimesServiceList.CarTimes='''+LTRIM(RTRIM(@CarTimes))+''''
end
if @SendNumber!=''
begin
if @sql !=''
set @sql=@sql+' and FreightReceiptsList.SendNumber='''+LTRIM(RTRIM(@SendNumber))+''''
else set @sql=' where FreightReceiptsList.SendNumber='''+LTRIM(RTRIM(@SendNumber))+''''
end
if @CompanyID!=0
begin
if @sql !=''
set @sql=@sql+' and FreightReceiptsList.CompanyID='''+LTRIM(RTRIM(@CompanyID))+''''
else set @sql=' where FreightReceiptsList.CompanyID='''+LTRIM(RTRIM(@CompanyID))+''''
end
begin
if @sql !=''
set @sql=@sql+' and DrawOutUnusualList.DrawOutUnusualID=2 or ReturnCarUnusualIList.ReturnCarUnusualIID=2 '
else set @sql=' where DrawOutUnusualList.DrawOutUnusualID=2 or ReturnCarUnusualIList.ReturnCarUnusualIID=2 '
end
exec('SELECT MX_AttributeDetailedList.AttributeDetailedName, DeliverReceiptsList.MX_DeliveryCarServiceID, DeliverReceiptsList.HandleManID, StaffList.StaffName,
ReturnCarUnusualIList.ReturnCarUnusualIName, DeliverReceiptsList.ReturnCarUnusualIReasonID, MX_ReturnCarUnusualIList.MX_ReturnCarUnusualIIName,
DrawOutUnusualList.DrawOutUnusualName, DeliverReceiptsList.DrawOutUnusualIReasonID, MX_DrawOutUnusualDetailList.DrawOutUnusualName AS DrawOutUnusualReason,
DeliverReceiptsList.DeliverReceiptsID, DeliverReceiptsList.BoxCount, DeliverReceiptsList.FreightReceiptsID, DeliverReceiptsList.DrawOutUnusualID, DeliverReceiptsList.ReturnCarUnusualIID,
DeliverReceiptsList.OpenCarAffirm, DeliverReceiptsList.ReturnCarAffirm, DeliverReceiptsList.HandleTime, FreightReceiptsList.SendNumber, MX_DeliveryCarTimesServiceList.CarTimes,
MX_DeliveryCarTimesServiceList.DeliveryCarTimeServiceID, MX_AttributeDetailedList_1.AttributeDetailedName AS DeliveryWayName, FreightReceiptsList.CompanyID,
CompanyList.CompanyName, FreightReceiptsList.SendClientID, ClientList.ClientName, ClientList.ClientAbbreviation, ClientList.LinkMan, ClientList.LinkPhone, ClientList.ClientNumber,
ClientList_1.ClientAbbreviation AS ClientAbbreviation1, ClientList_1.LinkMan AS LinkMan1, ClientList_1.LinkPhone AS LinkPhone1, ClientList_1.ClientNumber AS ClientNumber1,
ClientList_1.ClientID, ClientList_1.ClientName AS ClientName1, MX_AttributeDetailedList_1.MX_AttributeDetailedID, MX_AttributeDetailedList_2.AttributeDetailedName AS SignForState,
FreightReceiptsList.SignForStateID, MX_DeliveryCarTimesServiceList.PredictDrawOutTime, DeliveryCarTimesServiceList.DeliveryWayID, FreightReceiptsList.CollectAddress,
FreightReceiptsList.ClassesID, LTRIM(RTRIM(DeliverReceiptsList.Remark)) AS Remark, FreightReceiptsList.FreightReceiptsStateID, DeliveryFieldServiceList.FieldWord AS CollectFieldWord
FROM DeliverReceiptsList INNER JOIN
FreightReceiptsList ON DeliverReceiptsList.FreightReceiptsID = FreightReceiptsList.FreightReceiptsID INNER JOIN
MX_AttributeDetailedList ON FreightReceiptsList.ClassesID = MX_AttributeDetailedList.MX_AttributeDetailedID INNER JOIN
MX_DeliveryCarTimesServiceList ON DeliverReceiptsList.MX_DeliveryCarServiceID = MX_DeliveryCarTimesServiceList.MX_DeliveryCarTimesServiceID INNER JOIN
StaffList ON DeliverReceiptsList.HandleManID = StaffList.StaffID INNER JOIN
DeliveryCarTimesServiceList ON MX_DeliveryCarTimesServiceList.DeliveryCarTimeServiceID = DeliveryCarTimesServiceList.DeliveryCarTimesServiceID INNER JOIN
MX_AttributeDetailedList AS MX_AttributeDetailedList_1 ON DeliveryCarTimesServiceList.DeliveryWayID = MX_AttributeDetailedList_1.MX_AttributeDetailedID INNER JOIN
CompanyList ON FreightReceiptsList.CompanyID = CompanyList.CompanyID INNER JOIN
ClientList ON FreightReceiptsList.SendClientID = ClientList.ClientID INNER JOIN
ClientList AS ClientList_1 ON FreightReceiptsList.CollectClientID = ClientList_1.ClientID INNER JOIN
MX_AttributeDetailedList AS MX_AttributeDetailedList_2 ON FreightReceiptsList.SignForStateID = MX_AttributeDetailedList_2.MX_AttributeDetailedID INNER JOIN
DeliveryFieldServiceList ON FreightReceiptsList.DeliveryFieldServiceID = DeliveryFieldServiceList.DeliveryFieldServiceID LEFT OUTER JOIN
MX_ReturnCarUnusualIList ON DeliverReceiptsList.ReturnCarUnusualIReasonID = MX_ReturnCarUnusualIList.MX_ReturnCarUnusualIID LEFT OUTER JOIN
ReturnCarUnusualIList ON DeliverReceiptsList.ReturnCarUnusualIID = ReturnCarUnusualIList.ReturnCarUnusualIID LEFT OUTER JOIN
MX_DrawOutUnusualDetailList ON DeliverReceiptsList.DrawOutUnusualIReasonID = MX_DrawOutUnusualDetailList.MX_DrawOutUnusualDetailID LEFT OUTER JOIN
DrawOutUnusualList ON DeliverReceiptsList.DrawOutUnusualID = DrawOutUnusualList.DrawOutUnusualID
' + @sql)
end
--修改单据还原
if @type='updateDeliverReceiptsList'
begin
update DeliverReceiptsList set Remark=RTRIM(@Remark)
where DeliverReceiptsID=@MX_DeliveryCarTimesServiceID
update FreightReceiptsList set SignForStateID=44,FreightReceiptsStateID=43
where FreightReceiptsID=@FreightReceiptsID
end
--修改货运单状态和记录信息
if @type='UpdateFreightReceiptsSignFor'
begin
update FreightReceiptsList set SignFor=@SignFor,Remark=RTRIM(Remark)+@Remark,SignForStateID=@SignForStateID
where FreightReceiptsID=@FreightReceiptsID
end