62,055
社区成员
发帖
与我相关
我的任务
分享
{
text : "添加",
tooltip : "添加新的信息",
iconCls : "addicon",
handler : function() {
var win = new Swfu.BackMgr.infosWin({
canEdit : true,
iconCls : "addicon",
title : '新增记录'
});
win.show();
Ext.getCmp('BtnSave_infos').on('click', function() {
if(Ext.getCmp('title').getValue().trim().length<=0||Ext.getCmp('details').getValue().trim().length<=0||Ext.getCmp('classify').getRawValue().trim().length<=0)
{
Ext.ux.Toast.msg('提示','您的数据不完整,请先检查!');
return;
}
var records = {
'title' : Ext.getCmp('title').getValue(),
'details' : Ext.getCmp('details').getValue().replace(/</g,"|[|").replace(/>/g,"|]|"),//这里是新闻的详细内容,如果不替换<>标签的话会直接出错,替换了后,部分新闻仍然出错,错误就是json格式不对
'imgs' : "",
'classify' : Ext.getCmp('classify').getRawValue(),
'publiship' : "",
'publishman' : "",
'publishtime' : "",
'isshow' : "1",
'istop' : "0",
'hits' : 0,
'notes' : Ext.getCmp('notes').getValue()
};
var myMask = new Ext.LoadMask(Ext.getBody(), {
msg: '正在保存,请稍后......',
removeMask: true //完成后移除
});
myMask.show();
Ext.Ajax.request({
url : '/infos.mvc/Add_infos',
method : 'POST',
success : function(response, options) {
myMask.hide();
var responseMessage = Ext.util.JSON.decode(response.responseText);
if (responseMessage.Result) {
Ext.getCmp('infosMenu').getStore().reload();
Ext.getCmp('infoswin').close();
Ext.ux.Toast.msg('提示', '数据保存成功!');
}
else{
Ext.ux.Toast.msg('提示', '数据保存失败,请您重试!');
}
},
params : {
json : Ext.util.JSON.encode(records)
},
failure : function(form, action) {
if (action.failureType == 'server') {
obj = Ext.util.JSON
.decode(action.response.responseText);
Ext.Msg.alert('错误:', obj.errors.reason);
}
if (action.failureType == 'client') {
Ext.ux.Toast.msg('提示', '数据不正确,请核对后重新操作');
}
}
})
});
}
}
//添加记录
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Add_infos(string json)
{
var rdto = new ResultDTO();
JavaScriptSerializer jss = new JavaScriptSerializer();
infos infos = jss.Deserialize<infos>(json);
infos.publiship = Request.UserHostName.ToString();
infos.publishman = Session["username"].ToString();
infos.publishtime = DateTime.Now.ToString();
infos.details = infos.details.Replace("|[|", "<").Replace("|]|", ">").Replace("'", "\"").Replace("\r", "").Replace("\n", "").Replace("\\", "\\\\");
infos.imgs = MyGetImgUrl(infos.details);
try
{
ManagerFactory.infosMgr.Add_infos(infos);
rdto.Message = "添加成功";
rdto.Result = true;
}
catch
{
rdto.Message = "添加失败";
rdto.Result = false;
}
return this.Json(rdto);
}