增加extjs版的起运港维护页面

ShenZhenCHJY
dengyu 5 days ago
parent 7cf89aad0d
commit 7c218a2951

@ -0,0 +1,155 @@
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Models.CodeLoadPort;
using DSWeb.MvcShipping.DAL.MsCodeLoadPort;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.SoftMng.Filter;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCodeLoadPortController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataList(string condition,string sort)
{
var dataList = MsCodeLoadPortDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataListRm(string PORT, string sort)
{
var condition = "";
if (PORT == "")
{
condition = "";
}
else
{
condition = " PORTID like '%" + PORT + "%' or PORTENAME like '%" + PORT + "%' ";
}
var dataList = MsCodeLoadPortDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetData(string handle, string condition)
{
CodeLoadPort head = null;
if (handle == "edit")
{
var list = MsCodeLoadPortDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CodeLoadPort();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<CodeLoadPort>(data);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
var GID = headData.PORTID;
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCodeLoadPortDAL.GetData("PORTID='" + GID + "'", Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<CodeLoadPort>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeLoadPort>>(body);
DBResult result = MsCodeLoadPortDAL.SaveDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}

@ -0,0 +1,155 @@
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.CodeLoadPort;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
namespace DSWeb.MvcShipping.DAL.MsCodeLoadPort
{
public class MsCodeLoadPortDAL
{
#region Inquery DataList
static public List<CodeLoadPort> GetDataList(string strCondition, string companyid, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("PORTID,PORT,CNAME,EDICODE");
strSql.Append(" from code_loadport ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" WHERE " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else {
strSql.Append(" order by PORT");
}
return SetData(strSql);
}
static public CodeLoadPort GetData(string condition, string companyid)
{
CodeLoadPort data = null;
var list = GetDataList(condition,companyid);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new CodeLoadPort();
}
return data;
}
private static List<CodeLoadPort> SetData(StringBuilder strSql)
{
var headList = new List<CodeLoadPort>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
CodeLoadPort data = new CodeLoadPort();
#region Set DB data to Object
data.PORTID = Convert.ToString(reader["PORTID"]);
data.PORT = Convert.ToString(reader["PORT"]);
data.CNAME = Convert.ToString(reader["CNAME"]);
data.EDICODE = Convert.ToString(reader["EDICODE"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
public static DBResult SaveDetail(List<CodeLoadPort> bodyList, string companyid)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into code_loadport (PORTID,PORT,CNAME,EDICODE)
values (@PORTID,@PORT,@CNAME,@EDICODE) ");
var cmdUpdate =
db.GetSqlStringCommand(
@"update code_loadport set PORT=@PORT,CNAME=@CNAME,EDICODE=@EDICODE where PORTID=@PORTID ");
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (enumValue.PORTID == "*" || enumValue.PORTID == "")
{
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@PORTID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@PORT", DbType.String, enumValue.PORT);
db.AddInParameter(cmdInsert, "@CNAME", DbType.String, enumValue.CNAME);
db.AddInParameter(cmdInsert, "@EDICODE", DbType.String, enumValue.EDICODE);
db.ExecuteNonQuery(cmdInsert, tran);
}
else
{
cmdUpdate.Parameters.Clear();
db.AddInParameter(cmdUpdate, "@PORTID", DbType.String, enumValue.PORTID);
db.AddInParameter(cmdUpdate, "@PORT", DbType.String, enumValue.PORT);
db.AddInParameter(cmdUpdate, "@CNAME", DbType.String, enumValue.CNAME);
db.AddInParameter(cmdUpdate, "@EDICODE", DbType.String, enumValue.EDICODE);
db.ExecuteNonQuery(cmdUpdate, tran);
}
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功" + result.Message;
return result;
}
#region 参照部分
#endregion
}
}

@ -0,0 +1,68 @@
using System;
using HcUtility.Core;
using Newtonsoft.Json;
namespace DSWeb.MvcShipping.Models.CodeLoadPort
{
[JsonObject]
public class CodeLoadPort : ModelObjectBillHead
{
#region private Fields
private string _PORTID = Guid.NewGuid().ToString();
private string _PORT = String.Empty;
private string _CNAME = String.Empty;
private string _EDICODE = String.Empty;
#endregion
#region Public Properties
[ModelDB(MDBType = ModelDBOprationType.All, IsPrimary = true)]
public string PORTID
{
get { return _PORTID; }
set { _PORTID = value; }
}
[ModelDB]
public string PORT
{
get { return _PORT; }
set { _PORT = value; }
}
[ModelDB]
public string CNAME
{
get { return _CNAME; }
set { _CNAME = value; }
}
public string EDICODE
{
get { return _EDICODE; }
set { _EDICODE = value; }
}
#endregion
public CodeLoadPort()
{
TableName = "code_loadport";
}
}
#region 参照部分
#endregion
}

@ -0,0 +1,16 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/MvcShipping/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" src="../../../../Areas/MvcShipping/Viewsjs/MsCodeLoadPort/MsCodeLoadPortModel.js"></script>
<script type="text/javascript" src="../../../../Areas/MvcShipping/Viewsjs/MsCodeLoadPort/MsCodeLoadPortIndex.js"></script>
<script type="text/javascript" src="../../../../Areas/MvcShipping/Viewsjs/MsCodeLoadPort/Index.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<div id="viewport" ></div>
</asp:Content>

@ -0,0 +1,31 @@
Ext.BLANK_IMAGE_URL = '../../TruckMng/Content/Images/s.gif';
var panelIndex = null;
Ext.onReady(function () {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
panelIndex = new window.Shipping.MsCodeLoadPortIndex({
layout: 'border'
});
var view = new Ext.Viewport({
layout: 'border',
renderTo: 'viewport',
border: false,
items: [{
region: 'center',
layout: 'fit',
items: [panelIndex]
}]
});
});
function OprationSwap() {
return panelIndex.OprationSwap();
}
function AddNewRecord(record) {
panelIndex.AddNewRecord(record);
}

@ -0,0 +1,400 @@
Ext.namespace('Shipping');
Shipping.MsCodeLoadPortIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCodeLoadPortIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCodeLoadPortIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsCodeLoadPort',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeLoadPort/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: [{
sortable: true,
dataIndex: 'PORTID',
header: 'PORTID',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'PORT',
header: '港口英文名',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'CNAME',
header: '港口中文名',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'EDICODE',
header: 'EDI代码',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}
]
});
this.gridList.on('edit', function (editor, e, eOpts) {
this.gridAfterEdit(editor, e, eOpts);
}, this);
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
_this = this;
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '港口名称',
name: 'Port',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '中文名称',
name: 'PortName',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新增",
iconCls: "btnadd",
handler: function (button, event) {
this.addDetail();
// this.OprationStatus = 'add';
// window.open('/MvcShipping/MsCodeYardDataSet/Edit', "CODEYARDDATASET", 'width=800,height=600,top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
},
scope: this
},
{
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.onPostDetailClick(button, event);
},
scope: this
}, '-',
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.formSearch, this.panelBtn]
});
this.panelCtn = new Ext.Panel({
layout: "border",
title: '起运港',
id: 'pnlctn',
region: "center",
items: [this.gridList]
});
this.MainCenter = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
frame: false,
region: 'center',
enableTabScroll: true,
items:
[
this.panelCtn
]
});
Ext.apply(this, {
items: [this.panelTop, this.MainCenter]
});
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.onRefreshClick();
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: 500, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
addDetail: function () {
//var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo);
var record = Ext.create('MsCodeLoadPort', {
PORTID: '*',
PORT: '',
CNAME: '',
EDICODE: ''
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
gridAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
},
onPostDetailClick: function (button, event) {
var bodyDrChFeeDatas = [];
var i;
for (i = 0; i < this.storeList.getCount(); i += 1) {
var memberyf = this.storeList.getAt(i);
bodyDrChFeeDatas.push(memberyf);
};
var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas);
_thisfee = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCodeLoadPort/SaveDetail',
scope: this,
params: {
body: jsonChFeeBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.onRefreshClick();
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCodeLoadPort/Delete',
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}, //onDeleteClick
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var portid = form.findField('Port').getValue();
sql = sql + getAndConSql(sql, portid, " PORT like '%" + portid + "%' ");
var PortName = form.findField('PortName').getValue();
sql = sql + getAndConSql(sql, PortName, " CNAME like '%" + PortName + "%' ");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
});

@ -0,0 +1,11 @@
Ext.define('MsCodeLoadPort', {
extend: 'Ext.data.Model',
idProperty: 'PORTID',
fields: [
{ name: 'PORTID', type: 'string' },
{ name: 'PORT', type: 'string' },
{ name: 'CNAME', type: 'string' },
{ name: 'EDICODE', type: 'string' }
]
});

@ -2322,6 +2322,9 @@
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeFeeTemplateAgent\MsCodeFeeTemplateAgentModel.js" />
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeFeeTemplateAgent\Zi_en-us.js" />
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeFeeTemplateAgent\Zi_zh-cn.js" />
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeLoadPort\Index.js" />
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeLoadPort\MsCodeLoadPortIndex.js" />
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeLoadPort\MsCodeLoadPortModel.js" />
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeSgAuditRule\Index.js" />
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeSgAuditRule\MsCodeSgAuditRuleIndex.js" />
<Content Include="Areas\MvcShipping\Viewsjs\MsCodeSgAuditRule\MsCodeSgAuditRuleModel.js" />
@ -3451,6 +3454,7 @@
<Content Include="Areas\MvcShipping\Views\MsCodeFeeTemplateAgent\AddFee.aspx" />
<Content Include="Areas\MvcShipping\Views\MsCodeFeeTemplateAgent\Edit.aspx" />
<Content Include="Areas\MvcShipping\Views\MsCodeFeeTemplateAgent\Index.aspx" />
<Content Include="Areas\MvcShipping\Views\MsCodeLoadPort\Index.aspx" />
<Content Include="Areas\MvcShipping\Views\MsCrmClient\VisitPlanEdit.aspx" />
<Content Include="Areas\MvcShipping\Views\MsCrmClient\VisitEdit.aspx" />
<Content Include="Areas\MvcShipping\Views\MsCrmClient\Edit.aspx" />
@ -7811,7 +7815,10 @@
<DependentUpon>SiteFile.Master</DependentUpon>
</Compile>
<Compile Include="Areas\MvcShipping\Controllers\DJYORDERController.cs" />
<Compile Include="Areas\MvcShipping\Controllers\MsCodeLoadPortController.cs" />
<Compile Include="Areas\MvcShipping\DAL\DJYORDER\DJYORDERDAL.cs" />
<Compile Include="Areas\MvcShipping\DAL\MsCodeLoadPort\MsCodeLoadPortDAL.cs" />
<Compile Include="Areas\MvcShipping\Models\MsCodeLoadPort\LoadPortModel.cs" />
<Compile Include="Areas\SysMng\Controllers\SysRoleTaskQueryController.cs" />
<Compile Include="Areas\CommMng\DAL\PageHelperEIP.cs" />
<Compile Include="Areas\CommMng\DAL\PagerHelper.cs" />

Loading…
Cancel
Save