关闭

Ext在MVC中的提交方式总结

1235人阅读 评论(0) 收藏 举报
分类:

Ajax.request

 

@*Ext.Ajax.request({

url:'@Url.Action("UpdateCompanyCode", "CompanyCode")',

success: function(response) {

var rs =Ext.util.JSON.decode(response.responseText);

if (rs.Success) {

//ExtShowInfo(rs.Msg);

} else {

ExtShowError(rs.Msg);

}

},

failure: function (){

Ext.Msg.alert('提示', '服务器处理出错!请稍后再试!');

},

params: { rcmid:e.record.data.cmid, rcmkeepfield2: e.record.data.cmkeepfield2 }

});*@

 

public ActionResult UpdateCompanyCode(string rcmid,string rcmkeepfield2)

{

Models.JsonResponseData jrd = new Models.JsonResponseData();

try

{

//TranController.StartTran();

 

string cmid = Request["rcmid"];

string cmkeepfield2 = Request["rcmkeepfield2"];

string sql = String.Format("update CompanyInfo setCMKeepField2='{0}' where CMID='{1}' ", cmkeepfield2, cmid);

if (DbHelperSQL.ExecuteSql(sql)> 0)

{

//TranController.EndTran();

jrd.Success = true;

jrd.Msg = "公司代码修改成功!";  

}

else

{

//TranController.EndTran();

jrd.Success = false;

jrd.Msg = "公司账号不存在,请刷新界面!";  

}      

}

catch (Exceptionex)

{

//TranController.StrongRollback();

jrd.Success = false;

jrd.Msg = "终止过程出错!" + ex.Message;

}

return Json(jrd, JsonRequestBehavior.AllowGet);

}

 

Post

$.post('@Url.Action("UpdateFinanceAllocated", "FinanceAllocated")',

{ id: e.record.id,allocted_num: e.record.data.allocted_num, allocted_time:Ext.util.Format.date(e.record.data.allocted_time, 'Y-m-d') },

function (date) {

if (date != "sucess") {

Ext.MessageBox.alert("提示", date);

}

},"text");

 

var dsAllProducts = new Ext.data.Store({

           proxy: new Ext.data.HttpProxy({

                url: '@Url.Action("GetProduct", "Service")'

            }),

           reader: new Ext.data.JsonReader({

                root: '',

                id: 'AlignmentProductID'

            }, [

                { name: 'AlignmentProductID' },

                { name: 'ProductID' },

                { name: 'ProductName' },

                { name: 'ExecuteCity' },

                { name: 'ProductType' },

                { name: 'RealCost' },

                { name: 'ExecuteCost' },

                { name: 'CalculateType' },

                { name: 'CorpInfo' },

                { name: 'IsBigBag' },

                { name: 'ServiceCost' }

            ])

        });

 

 

submit

 

form.getForm().submit({

waitTitle: '请稍后...',

waitMsg: '正在上传文件,请稍后...',

url: '/MessageExt/Create',

method: 'post',

success: function (form, action) {

if(action.result.success==true)

{

Ext.MessageBox.alert("提示","发送成功");

gridstore.reload();

window.close();

}else{

Ext.MessageBox.alert("提示",action.result.success);

}

},

failure: function (form, action) {

Ext.Msg.alert('提示', '服务器处理出错!请稍后再试!');

},

params: {title:title,msg:msg,sendtype:sendtype,receiveId:receiveId }

});

 

public string Create()

{

//Models.JsonResponseDatajrd = new Models.JsonResponseData();

string result = "";

try

{

Model.Message model_message = new Model.Message();

 

HttpPostedFileBase file = Request.Files["file"];

 

model_message.ReceiveUserId= Request["receiveId"].ToString();

model_message.Title =Request["title"].ToString();

model_message.MessageContent= Request["msg"].ToString();

model_message.MessageType= Request["sendtype"] != null ? Convert.ToInt32(Request["sendtype"].ToString()) : 0;

model_message.SendUserId= Session["UserId"].ToString();

model_message.ReadFlag =0;

model_message.PId = 0;

model_message.DelFlag =0;

 

if (file != null)

{

string path = Server.MapPath("~/Upload/");

//执行文件上传           

string savepath = path + file.FileName;

file.SaveAs(savepath);

 

Ciicgz.ERP.Common.FileUpload fu = new Ciicgz.ERP.Common.FileUpload(Server.MapPath("~/"));

string fileid = fu.FileUploads("CmpContract", savepath);

fu.DeleteFileInDirectory(savepath);

 

if (fileid != "0" && fileid != null)

{

model_message.FilePath =fileid;

}

}

BLL.Message bll_message = new BLL.Message();

if (bll_message.Add(model_message) > 0)

{

result = "{success:true}";

}

else

{

result = "{success:false}";

}

}

catch (Exceptionex)

{

result = "{success:false,info:'" + ex.Message + "'}";

}

return result;

}

 

 

 

 

 

数据向后台提交(方式)

 

 

 

//以下是从后台中读取所有的数据,然后填充相应的页面上的text控件

 Ext.getCmp("credit_Apply_Form").getForm().load({

       url:'webaddress.aspx',

       params:{Param: "edit", objectId: paramObject},

       success:function(form, action){ 

        },

       failure:function(form, action) { Ext.Msg.alert("加载出错", action.result.errorMessage);}

});

 SampForm.submit({

    url:"Webaddress.aspx?Param=SaveCreditCardList",

    success:function(form,action){

         alert("操作成功");

      },

     failure:function(form,action){

          alert(action.result.info);

},

     params:{main:Ext.encode(SampForm.getFieldValues()),fDriction:Ext.encode(lstDireRecord)},

     waitMsg:"正在保存数据,稍后......"                                                                      

     });

 

Adjax

  Ext.Ajax.request({

     url:"CAddressWeb.aspx?Param=delSingleRecord",

     success:function(resp,opts){

          varrespText =Ext.util.JSON.decode(resp.responseText);                                           

if(respText.success == '1'){

alert("操作成功");

}else {

alert("操作失败");

}

},

     failure:function(resp,opts){

alert("操作失败");

},

      params:{objectId:selections[0].get("Id")}                                                                  

 });

 

 Ext.lib.Ajax.request("POST","CrAressWebn.aspx?Param=UpdateCreditLimit",{

success: function(respose, option) {

var result =Ext.util.JSON.decode(respose.responseText);

if (result.operateType = "success") {

 

};

},

failure: function() {

},

params:{ObjectID : ID}

); 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:123658次
    • 积分:1650
    • 等级:
    • 排名:千里之外
    • 原创:52篇
    • 转载:9篇
    • 译文:0篇
    • 评论:4条
    最新评论