@model ProdOrderAutoGrGiRequestSystem.Models.ProdKBCardModel
@{
ViewBag.Title = "Index";
var jTableStyle = "metro/blue/jtable.css";
if (!string.IsNullOrEmpty(Request["jTableStyle"]))
{
jTableStyle = Request["jTableStyle"];
}
}
<h2><span class="glyphicon glyphicon-search"></span>Shortship Kanban Enquiry</h2>
<head>
<meta charset="utf-8" />
<link href="@Url.Content("~/Content/Sitejt.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/metroblue/jquery-ui.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/highlight.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Scripts/jtable/themes/" + jTableStyle)" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Scripts/syntaxhighligher/styles/shCore.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Scripts/syntaxhighligher/styles/shThemeDefault.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/bootstrap.min.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/bootstrap.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.11.0.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-2.6.2.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.9.0.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.9.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/syntaxhighligher/shCore.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/syntaxhighligher/shBrushJScript.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/syntaxhighligher/shBrushXml.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/syntaxhighligher/shBrushCSharp.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/syntaxhighligher/shBrushSql.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jtablesite.js")" type="text/javascript"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jtable/jquery.jtable.js")"></script>
</head>
<!-- Container for jTable -->
<script type="text/javascript">
function CheckData() { }
function load() {
//Load student list from server
$.ajaxSetup({
cache: false
});
$('#StudentTableContainer').jtable('load', {
type: $('#ddlType').val(),
sn: $('#SN').val(),
material: $('#Material').val(),
plant: $('#Plant').val(),
status: $('#Show').is(':checked')
});
}
function InitJTable() {
$.ajaxSetup({
cache: false
});
var type = $('#ddlType').val()=="1"?true:false;
$('#StudentTableContainer').jtable({
title: 'Kanban Enquiry List',
paging: true,
pageSize: 10,
sorting: true,
defaultSorting: 'RequestNo ASC',
actions: {
listAction: '@Url.Action("ShortShipList")'
},
fields: {
OrderNo: {
title: type ? 'Order No.' : 'PO',
// visibility: type == "1" ? 'hidden' : '',
'15%',
listClass: 'child-opener-image-column',
display: function (data) {
var no = data.record.OrderNo;
var $img = $('<a title="show detail">' + no + '</a>');
$img.click(function () {
$('#StudentTableContainer').jtable('openChildTable',
$img.closest('tr'),
{
title: data.record.OrderNo + ' - details',
actions: {
listAction: '@Url.Action("GetDetails")?RequestNo=' + data.record.RequestNo
},
fields: {
IssueDate: {
title: 'Issue Date',
'15%',
type: 'date',
displayFormat: 'yy/mm/dd',
create: false,
edit: false,
sorting: false
},
IssueBy: {
title: 'Issued By',
'15%'
},
ProcessDept: {
title: 'ProcessDept',
'12%'
},
Department: {
title: 'Department',
'15%',
visibility: type ? '' : 'hidden'
},
Shop: {
title: 'Shop',
'15%',
visibility: type ? '' : 'hidden'
},
Location: {
title: 'Location',
'15%',
visibility: type ? '' : 'hidden'
},
DeliveryDate: {
title: 'Delivery Date',
'15%',
type: 'date',
displayFormat: 'yy/mm/dd',
sorting: true,
visibility: type ? 'hidden' : ''
},
CommitDate: {
title: 'CommitDate',
'15%',
type: 'date',
displayFormat: 'yy/mm/dd',
sorting: true,
visibility: type ? '' : 'hidden'
},
CloseDate: {
title: 'CloseDate',
'15%',
type: 'date',
displayFormat: 'yy/mm/dd',
create: false,
edit: false,
sorting: true
},
RespDept: {
title: 'RespDept',
'15%'
},
Reason: {
title: 'Reason',
'15%',
visibility: type ? 'hidden' : ''
},
ReasonProvider: {
title: 'ReasonProvider',
'15%',
visibility: type ? 'hidden' : ''
},
ReasonCategory: {
title: 'ReasonCategory',
'15%',
visibility: type ? 'hidden' : ''
},
ShipmentDate: {
title: 'ShipmentDate',
'15%',
type: 'date',
displayFormat: 'yy-mm-dd',
create: false,
edit: false,
sorting: false
},
Plant: {
title: 'Plant',
'15%',
visibility: type ? '' : 'hidden'
}
}
}, function (Deatil) { //opened handler
Deatil.childTable.jtable('load');
});
});
return $img;
}
},
Material: {
title: 'Material',
'15%'
},
Description: {
title: 'Description',
visibility: type ? 'hidden' : ''
},
Module: {
title: 'Module',
'15%',
visibility: type ? '' : 'hidden'
},
ModuleDesc: {
title: 'ModuleDesc',
'15%',
visibility: type ? '' : 'hidden'
},
Model: {
title: 'Model',
'23%'
},
SN: {
title: 'Serial No.'
},
SO: {
title: 'Sales Order No.',
'13%'
},
SOItem: {
title: 'Sales Order Item',
'12%'
},
ShortQty: {
title: 'Short Ship Qty'
},
OpenQty: {
title: 'Open Qty',
'12%'
},
Recipient: {
title: 'recipient',
'15%',
visibility: type ? '' : 'hidden'
}
// RequestNo: {
// title: 'Kanban Card No.',
// key: true,
// create: false,
// edit: false,
// display: function (data) {
// //debugger;
// var no = data.record.RequestNo;
// var $img = $('<a href=@Url.Action("GetDetails", "RequestEnquiry")?id=' + no + '>' + no + '</a>');
// $img.click(function () { window.open('@Url.Action("GetDetails", "RequestEnquiry", new {prno="ggg" } )'); });
// return $img;
// }
// }
}
});
}
</script>
<script type="text/javascript">
$(document).ready(function () {
$('#Cancle').click(function () { });
$('#ddlType,#SN,#Material,#Plant,#Show').change(function () { $("#StudentTableContainer").jtable('destroy'); InitJTable(); load(); });
$('#Cancle').click(function () { window.location.href = '@Url.Action("Index", "RequestEnquiry", new { } )'; });
//Prepare jtable plugin
InitJTable();
load();
});
</script>
@using (Html.BeginForm("ShortShipList", "RequestEnquiry", FormMethod.Post, new { id = "FormEnq", onsubmit = "return CheckData()" }))
{
<fieldset>
<div class="editor-label">
@Html.LabelFor(model => model.Type)
</div>
<div class="editor-field">
@Html.DropDownList("Type",
(List<SelectListItem>)ViewBag.ListType, new { id = "ddlType" })
@Html.ValidationMessageFor(model => model.Type)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.SN)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.SN)
@Html.ValidationMessageFor(model => model.SN)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Material)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Material)
@Html.ValidationMessageFor(model => model.Material)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Plant)
</div>
<div class="editor-field">
@Html.DropDownList("Plant", (List<SelectListItem>)ViewBag.ListPlant, "--select--", new { id = "Plant" })
@Html.ValidationMessageFor(model => model.Plant)
</div>
<div class="editor-label">
@Html.CheckBox("Show", new { id = "Show", onChange = "load()" })
@Html.Label("Show Outstanding Kanban Card Only")
</div>
<p>
@* <input type="submit" value="Search" onclick='load() ' />*@
<input type="button" class="btn btn-inverse" value="Cancle" id="Cancle" />
@*<input type="submit" class="btn btn-link" value="Download" onclick='this.form.action="@Url.Action("ToExcel")" ' />*@
<button type="submit" class="btn btn-link btn-lg" onclick='this.form.action="@Url.Action("ToExcel")" ' >
Download<span class="glyphicon glyphicon-download-alt"></span>
</button>
</p>
</fieldset>
}
<div id="StudentTableContainer"></div>
后台:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using BusinessLogicLayer;
using DataAccessLayer;
using System.Configuration;
using ProdOrderAutoGrGiRequestSystem.Helper;
using System.Web.Routing;
using System.Globalization;
using System.Threading;
namespace ProdOrderAutoGrGiRequestSystem.Controllers
{
public class RequestEnquiryController : Controller
{
//
// GET: /RequestEnquiry/
public static string badge, useracc, lang; public static bool pageAuth;
protected override void Initialize(RequestContext requestContext)
{
base.Initialize(requestContext);
}
public ActionResult Index()
{
string UserName = Request.ServerVariables.Get("LOGON_USER").ToLower();
CultureInfo usCulture = Thread.CurrentThread.CurrentUICulture;
lang = "en-US";
useracc = UserName.Split('\')[1].ToString().Trim();
badge = AsmUserManager.getUserInfo(useracc).badge;
List<ShortShipRightManager> dt = ShortShipRightManage.SearchShortShipRightmanage(badge);
if (dt.Count > 0)
{
if (ShortShipRightManage.SearchShortShipRightmanage(badge).FirstOrDefault().RightName.IndexOf("Enquiry") < 0)
pageAuth = false;
else
pageAuth = true;
}
else
pageAuth = false;
ViewBag.Message = "Request Enquiry";
if (pageAuth)
{
ViewBag.ListType = new List<SelectListItem> { new SelectListItem { Text = "PROD_KB_CARD", Value = "1" }, new SelectListItem { Text = "CUST_KB_CARD", Value = "2" } };
string plant = ConfigurationManager.AppSettings["Plant"].ToString();
string[] str = plant.Split(';');
ViewBag.ListPlant = new List<SelectListItem>();
foreach (var i in str)
{
ViewBag.ListPlant.Add(new SelectListItem { Text = i, Value = i });
}
return View();
}
else
return View("~/Views/Home/Index.cshtml");
}
public ActionResult SearchResult()
{
return View();
}
[HttpPost]
public JsonResult GetDetails(int RequestNo)
{
try
{
var detail = ShortShipManager.searchSingleShortShip(RequestNo);
return Json(new { Result = "OK", Records = detail });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
[HttpPost]
public ActionResult ToExcel(string Download="")
{
try
{
string strdate = DateTime.Now.ToString("yyyyMMddhhmmss");//获取当前时间
return File(NOPIHelper.ListToExcel((List<ShortShipRequest>)Session["datatable"], (string)Session["type"]), "application/vnd.ms-excel", strdate + "Excel.xls");
}
catch(Exception e) {
return Json(e.Message+e.InnerException+e.StackTrace, JsonRequestBehavior.AllowGet);
}
}
[HttpPost]
public JsonResult ShortShipList(string type="",string sn="",string material="",string plant="",bool status=false, int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
{
ViewBag.type = true;
ShortShipRequest s = new ShortShipRequest();
s.Type = type;
s.SN = sn;
s.Material = material;
s.Plant = plant;
s.Status = status?0:-1;
try
{
IEnumerable<ShortShipRequest> dt = new List<ShortShipRequest>();
dt =ShortShipManager.searchShortShip(s);
Session["type"] = type;
Session["datatable"] = dt;
return Json(new { Result = "OK", Records = dt, TotalRecordCount = dt.Count() });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
}
}
searchShortShip方法:
public static List<ShortShipRequest> searchShortShip(ShortShipRequest sh)
{
using (SAPEntities1 ss = new SAPEntities1()) {
List<ShortShipRequest> s = (from a in ss.ShortShipRequests
where a.Type==sh.Type&&( a.Status==0||a.Status==1)
select a).ToList();
if (!string.IsNullOrEmpty(sh.SN))
s=s.Where(m=>m.SN==sh.SN).ToList();
if (!string.IsNullOrEmpty(sh.Material))
s=s.Where(m=>m.Material==sh.Material).ToList();;
if (!string.IsNullOrEmpty(sh.Plant))
s=s.Where(m=>m.Plant==sh.Plant).ToList();
if(sh.Status==0)
s=s.Where(m=>m.Status==0).ToList();
return s;
}
}