如何在ASP.NET MVC和jquery中的$ .post之后编写部分视图 [英] How to lode partial view after $.post in ASP.NET MVC and jquery
问题描述
大家好,
现在我在这里遇到问题,我正在开展一个计费项目,我正在将一个challan转换为Invoice,你知道大多数供应商在challan出售或栖息货物,然后准备发票,
在这里我试图将challan转换为发票,并希望展示如何将challan转换成发票
on ad to发票按钮点击我使用Jquery $ .post方法转换challan
并将所有信息数据存储在TempData []中,我想在局部视图中显示
但是它不应该在这里工作
请帮帮我
我尝试过:
部分查看
< td>< input type =textid =InvNo class =tmp1readonly =readonlyvalue =@ TempData [iNVOICENO2]style =width:70px/> < / TD>
< td>
< input type =textid =C ***class =c *** 1readonly =readonlyvalue =@ TempData [mcountno]style =width: 70px/>
< / td>
< td>
< input type =textid =Fstamtclass =fstamt1readonly =readonlyvalue =@ TempData [xamt]style =width:70px/>
< / td>
< td>< input type =textid =Txtamtclass =tmp3readonly =readonlyvalue =@ TempData [xtxamt]style =width:70px/ >< / TD>
< td>
< input type =textid =Totclass =tot1readonly =readonlyvalue =@ TempData [xfstamt]style =width:70px/>
< / td>
控制器行动
[HttpPost ]
public JsonResult Cnv(string sypplyerName,int PerTranChallanId,int ChalPerchesTranCode,string ChallaNo,decimal TaxAmount,decimal TotalAmount,int x1 = 1)
{
// int xcount =(int)TempData [ mcountno];
mcountno ++;
var suphistry = dc.Supplyers.Where(s => s.Sypplyer_name == sypplyerName).FirstOrDefault();
//发票数据starr
var Newsupname = suphistry.Sypplyer_name;
var NewsupID = suphistry.SupplyerID;
var newAddinsupl = suphistry.Add_in;
var NewClosingBalance = suphistry.ClosingBalance;
string newInvno =(string)TempData [invoiceNo];
DateTime newInvDate =(DateTime)TempData [InvDate];
var newinvoiceDate =(DateTime)newInvDate;
newinvoiceNumber =(string)newInvno;
//发票数据结束
//获取新的ptranCode
var ptran = dc.WorkingCodes.Where(m => m.ID == x1).FirstOrDefault();
var m_pran = ptran.PerTranCode;
var convrtCode = ptran.Challan_convertCode;
convrtCode = convrtCode + 1;
m_pran = m_pran + 1;
//结束新的ptrancode
//获取选定的challan数据
var P = dc.PercheshChallanTransations.Where(p => p.PerTranChallanId == PerTranChallanId).FirstOrDefault();
//结束默认的challan数据
int workingtran = dc.PerchesTransactions.Where(m => m.PTranCode == m_pran&& m.SupplyerId == NewsupID&& ; m.InvoiceNo == newInvno).Count();
if(workingtran> 0)
{
PerchesTransaction ptr = new PerchesTransaction
{
PTranCode = m_pran,
};
}
其他
{
//在Perches中填充数据转换
PerchesTransaction ptr = new PerchesTransaction
{
PTranCode = m_pran,
InvoiceNo = newInvno,
InvoiceDate = newInvDate,
SupplyerId = NewsupID,
SypplyerName = Newsupname,
InvoiceFirstTotal = P.InvoiceFirstTotal,
TaxAmount = P.TaxAmount,
TotalAmount = P.TotalAmount,
ChalPerchesTranCode = P.ChalPerchesTranCode,
Challan_trancode = convrtCode,
PayTranCode = 0,
PaidAmount = 0.00m,
BalAmount = P.TotalAmount,
};
列表< object> niv = new List< object>
{
ptr.InvoiceNo,
ptr.InvoiceDate,
ptr.SypplyerName,
ptr.SupplyerId,
ptr.PTranCode,
ptr .ChalPerchesTranCode,
ptr.Challan_trancode,
ptr.InvoiceFirstTotal,
ptr.TaxAmount,
ptr.TotalAmount,
ptr.PayTranCode,
ptr.PaidAmount ,
ptr.BalAmount
};
object [] invs = niv.ToArray();
// int outinv = dc.Database.ExecuteSqlCommand(插入PerchesTransaction(InvoiceNo,InvoiceDate,SypplyerName,SupplyerId,PTranCode,ChalPerchesTranCode,Challan_trancode,InvoiceFirstTotal,TaxAmount,TotalAmount,PayTranCode,PaidAmount,BalAmount)值(@ p0 ,@ p1,@ p2,@ p3,@ p4,@ p5,@ p6,@ p7,@ p8,@ p9,@ p10,@ p11,@ p12),invs);
var chg_Ptran = P.PTranCode;
var chg_id = P.PerTranChallanId;
// challan transation update
PercheshChallanTransation px1 = new PercheshChallanTransation
{
PTranCode = m_pran,
PerTranChallanId = chg_id,
};
列表< object> chg = new List< object>
{
px1.PTranCode,
px1.PerTranChallanId
};
object [] chg1 = chg.ToArray();
// int chg2 = dc.Database.ExecuteSqlCommand(更新PercheshChallanTransation设置PTranCode = @ p0,其中PerTranChallanId = @ p1,chg1);
// perches详细更新
PerchesDetail pt11 = new PerchesDetail
{
Invoice_no = newinvoiceNumber,
InvoiceDate = newinvoiceDate,
ChallConvertCode = convrtCode,
PerTranCode = m_pran,
PerChallanTrancode = P.ChalPerchesTranCode,
};
列表< object> ppd = new List< object>
{
pt11.Invoice_no,
pt11.InvoiceDate,
pt11.ChallConvertCode,
pt11.PerTranCode,
pt11.PerChallanTrancode
};
object [] pp1 = ppd.ToArray();
// int pp2 = dc.Database.ExecuteSqlCommand(更新PerchesDetails设置Invoice_no = @ p0,InvoiceDate = @ p1,ChallConvertCode = @ p2,PerTranCode = @ p3,其中PerChallanTrancode = @ p4,pp1);
// perches详细更新结束
//供应商更新
供应商ss =新供应商
{
ClosingBalance = NewClosingBalance + ptr.TotalAmount,
Add_in = newAddinsupl + ptr.TotalAmount,
SupplyerID = NewsupID
};
列表< object> sid = new List< object>
{
ss.ClosingBalance,
ss.Add_in,
ss.SupplyerID
};
object [] ss1 = sid.ToArray();
// int ss2 = dc.Database.ExecuteSqlCommand(更新供应商设置ClosingBalance = @ p0,Add_in = @ p1,其中SupplyerID = @ p2,ss1);
//供应商更新结束
xAmt = xAmt + ptr.TotalAmount;
xtxamt = xtxamt + ptr.TaxAmount;
xfstamt = xfstamt + ptr.InvoiceFirstTotal;
// TempData [Totamt] = pct.TotalAmount;
}
// var x11 = dc.PerchesTransactions.Where(x => x.PTranCode == m_pran).FirstOrDefault();
TempData [xamt] = xAmt;
TempData [xtxamt] = xtxamt;
TempData [xfstamt] = xfstamt;
TempData [mcountno] = mcountno;
TempData [iNVOICENO2] = newinvoiceNumber;
TempData.Keep();
var P11 = dc.PercheshChallanTransations.Where(p => p.SypplyerName == sypplyerName).FirstOrDefault();
// var c1 = dc.PerchesTransactions.Where(p => p.ChalPerchesTranCode == ChalPerchesTranCode).FirstOrDefault();
返回Json(新
{
redirectUrl = Url.Action(Getview,Perchus),
isRedirect = true
});
//返回Json(P11,JsonRequestBehavior.AllowGet);
}
public ActionResult Getview()
{
xAmt =(decimal)TempData [xamt];
xtxamt =(十进制)TempData [xtxamt];
xfstamt =(十进制)TempData [xfstamt];
mcountno =(int)TempData [mcountno];
newinvoiceNumber =(string)TempData [iNVOICENO2];
TempData [xamt] = xAmt;
TempData [xtxamt] = xtxamt;
TempData [xfstamt] = xfstamt;
TempData [mcountno] = mcountno;
TempData [iNVOICENO2] = newinvoiceNumber;
TempData.Keep();
返回PartialView(PerchesChallan);
}
这里我要显示部分查看数据
@ Html.PagedListPager(Model,page => Url.Action(ConvertrWorker,
new {page,sortOrder = ViewBag.CurrentSort,currentFilter = ViewBag.CurrentFilter}))
< ; div class =dtl>
< table class =table table-bordered>
< tr id =newrowclass =myrow>
< td> Ivnoice no:< / td>
< td>不计数:< / td>
< td>税金额:< / td>
< td>税额:< / td>
< td>总金额:< / td>
< td>添加费用:< / td>
< td>减少折扣& Ribet:< / td>
< td>提交< / TD>
< / tr>
< tr id =finalclass =final1>
@ Html.Partial(PerchesChallan)
< / tr>
< / table>
< / div>
jquery邮政方法(简称)
$( 。本).closest( TR)找到( '#convt')隐藏()。
$(this).closest('tr')。find('#cansel')。show();
$('。dtl')。show();
$ .post(url,{sypplyerName:sName,PerTranChallanId:pChallanId,ChalPerchesTranCode:pTranCodeINCHAL,ChallaNo:challaNo,TaxAmount:taxAmount,TotalAmount:totalAmount},function(data){
$ .notify(更新并转换Challan Succesfully,成功);
if(json.isRedirect){
window.location.href = json.redirectUrl;
}
});
.post方法转换challan
并将所有信息数据存储在TempData中[]我想在局部视图中显示
但它不应该在这里工作
请帮帮我
我尝试过:
局部视图
< td>< input type =textid =InvNoclass =tmp1readonly =readonlyvalue =@ TempData [iNVOICENO2]style =width:70px /> < / TD>
< td>
< input type =textid =C ***class =c *** 1readonly =readonlyvalue =@ TempData [mcountno]style =width: 70px/>
< / td>
< td>
< input type =textid =Fstamtclass =fstamt1readonly =readonlyvalue =@ TempData [xamt]style =width:70px/>
< / td>
< td>< input type =textid =Txtamtclass =tmp3readonly =readonlyvalue =@ TempData [xtxamt]style =width:70px/ >< / TD>
< td>
< input type =textid =Totclass =tot1readonly =readonlyvalue =@ TempData [xfstamt]style =width:70px/>
< / td>
控制器行动
[HttpPost ]
public JsonResult Cnv(string sypplyerName,int PerTranChallanId,int ChalPerchesTranCode,string ChallaNo,decimal TaxAmount,decimal TotalAmount,int x1 = 1)
{
// int xcount =(int)TempData [ mcountno];
mcountno ++;
var suphistry = dc.Supplyers.Where(s => s.Sypplyer_name == sypplyerName).FirstOrDefault();
//发票数据starr
var Newsupname = suphistry.Sypplyer_name;
var NewsupID = suphistry.SupplyerID;
var newAddinsupl = suphistry.Add_in;
var NewClosingBalance = suphistry.ClosingBalance;
string newInvno =(string)TempData [invoiceNo];
DateTime newInvDate =(DateTime)TempData [InvDate];
var newinvoiceDate =(DateTime)newInvDate;
newinvoiceNumber =(string)newInvno;
//发票数据结束
//获取新的ptranCode
var ptran = dc.WorkingCodes.Where(m => m.ID == x1).FirstOrDefault();
var m_pran = ptran.PerTranCode;
var convrtCode = ptran.Challan_convertCode;
convrtCode = convrtCode + 1;
m_pran = m_pran + 1;
//结束新的ptrancode
//获取选定的challan数据
var P = dc.PercheshChallanTransations.Where(p => p.PerTranChallanId == PerTranChallanId).FirstOrDefault();
//结束默认的challan数据
int workingtran = dc.PerchesTransactions.Where(m => m.PTranCode == m_pran&& m.SupplyerId == NewsupID&& ; m.InvoiceNo == newInvno).Count();
if(workingtran> 0)
{
PerchesTransaction ptr = new PerchesTransaction
{
PTranCode = m_pran,
};
}
其他
{
//在Perches中填充数据转换
PerchesTransaction ptr = new PerchesTransaction
{
PTranCode = m_pran,
InvoiceNo = newInvno,
InvoiceDate = newInvDate,
SupplyerId = NewsupID,
SypplyerName = Newsupname,
InvoiceFirstTotal = P.InvoiceFirstTotal,
TaxAmount = P.TaxAmount,
TotalAmount = P.TotalAmount,
ChalPerchesTranCode = P.ChalPerchesTranCode,
Challan_trancode = convrtCode,
PayTranCode = 0,
PaidAmount = 0.00m,
BalAmount = P.TotalAmount,
};
列表< object> niv = new List< object>
{
ptr.InvoiceNo,
ptr.InvoiceDate,
ptr.SypplyerName,
ptr.SupplyerId,
ptr.PTranCode,
ptr .ChalPerchesTranCode,
ptr.Challan_trancode,
ptr.InvoiceFirstTotal,
ptr.TaxAmount,
ptr.TotalAmount,
ptr.PayTranCode,
ptr.PaidAmount ,
ptr.BalAmount
};
object [] invs = niv.ToArray();
// int outinv = dc.Database.ExecuteSqlCommand(插入PerchesTransaction(InvoiceNo,InvoiceDate,SypplyerName,SupplyerId,PTranCode,ChalPerchesTranCode,Challan_trancode,InvoiceFirstTotal,TaxAmount,TotalAmount,PayTranCode,PaidAmount,BalAmount)值(@ p0 ,@ p1,@ p2,@ p3,@ p4,@ p5,@ p6,@ p7,@ p8,@ p9,@ p10,@ p11,@ p12),invs);
var chg_Ptran = P.PTranCode;
var chg_id = P.PerTranChallanId;
// challan transation update
PercheshChallanTransation px1 = new PercheshChallanTransation
{
PTranCode = m_pran,
PerTranChallanId = chg_id,
};
列表< object> chg = new List< object>
{
px1.PTranCode,
px1.PerTranChallanId
};
object [] chg1 = chg.ToArray();
// int chg2 = dc.Database.ExecuteSqlCommand(更新PercheshChallanTransation设置PTranCode = @ p0,其中PerTranChallanId = @ p1,chg1);
// perches详细更新
PerchesDetail pt11 = new PerchesDetail
{
Invoice_no = newinvoiceNumber,
InvoiceDate = newinvoiceDate,
ChallConvertCode = convrtCode,
PerTranCode = m_pran,
PerChallanTrancode = P.ChalPerchesTranCode,
};
列表< object> ppd = new List< object>
{
pt11.Invoice_no,
pt11.InvoiceDate,
pt11.ChallConvertCode,
pt11.PerTranCode,
pt11.PerChallanTrancode
};
object [] pp1 = ppd.ToArray();
// int pp2 = dc.Database.ExecuteSqlCommand(更新PerchesDetails设置Invoice_no = @ p0,InvoiceDate = @ p1,ChallConvertCode = @ p2,PerTranCode = @ p3,其中PerChallanTrancode = @ p4,pp1);
// perches详细更新结束
//供应商更新
供应商ss =新供应商
{
ClosingBalance = NewClosingBalance + ptr.TotalAmount,
Add_in = newAddinsupl + ptr.TotalAmount,
SupplyerID = NewsupID
};
列表< object> sid = new List< object>
{
ss.ClosingBalance,
ss.Add_in,
ss.SupplyerID
};
object [] ss1 = sid.ToArray();
// int ss2 = dc.Database.ExecuteSqlCommand(更新供应商设置ClosingBalance = @ p0,Add_in = @ p1,其中SupplyerID = @ p2,ss1);
//供应商更新结束
xAmt = xAmt + ptr.TotalAmount;
xtxamt = xtxamt + ptr.TaxAmount;
xfstamt = xfstamt + ptr.InvoiceFirstTotal;
// TempData [Totamt] = pct.TotalAmount;
}
// var x11 = dc.PerchesTransactions.Where(x => x.PTranCode == m_pran).FirstOrDefault();
TempData [xamt] = xAmt;
TempData [xtxamt] = xtxamt;
TempData [xfstamt] = xfstamt;
TempData [mcountno] = mcountno;
TempData [iNVOICENO2] = newinvoiceNumber;
TempData.Keep();
var P11 = dc.PercheshChallanTransations.Where(p => p.SypplyerName == sypplyerName).FirstOrDefault();
// var c1 = dc.PerchesTransactions.Where(p => p.ChalPerchesTranCode == ChalPerchesTranCode).FirstOrDefault();
返回Json(新
{
redirectUrl = Url.Action(Getview,Perchus),
isRedirect = true
});
//返回Json(P11,JsonRequestBehavior.AllowGet);
}
public ActionResult Getview()
{
xAmt =(decimal)TempData [xamt];
xtxamt =(十进制)TempData [xtxamt];
xfstamt =(十进制)TempData [xfstamt];
mcountno =(int)TempData [mcountno];
newinvoiceNumber =(string)TempData [iNVOICENO2];
TempData [xamt] = xAmt;
TempData [xtxamt] = xtxamt;
TempData [xfstamt] = xfstamt;
TempData [mcountno] = mcountno;
TempData [iNVOICENO2] = newinvoiceNumber;
TempData.Keep();
返回PartialView(PerchesChallan);
}
这里我要显示部分查看数据
@ Html.PagedListPager(Model,page => Url.Action(ConvertrWorker,
new {page,sortOrder = ViewBag.CurrentSort,currentFilter = ViewBag.CurrentFilter}))
< ; div class =dtl>
< table class =table table-bordered>
< tr id =newrowclass =myrow>
< td> Ivnoice no:< / td>
< td>不计数:< / td>
< td>税金额:< / td>
< td>税额:< / td>
< td>总金额:< / td>
< td>添加费用:< / td>
< td>减少折扣& Ribet:< / td>
< td>提交< / TD>
< / tr>
< tr id =finalclass =final1>
@ Html.Partial(PerchesChallan)
< / tr>
< / table>
< / div>
jquery邮政方法(简称)
(本).closest( TR)找到( '#convt')隐藏();
(本).closest( TR ')发现(' #cansel')显示();
Hi Everybody ,
Now i am facing problem here , I am working on a billing project that i am Converting a challan to Invoice ,you know most of vendor sold or perches goods on challan and then prepare its invoice ,
here i trying to convert challan to Invoice and wish to show how meny challan converted in to invoice
on Ad to invoice button click i use Jquery $.post method to convert challan
and store this all info data in TempData[""] which i want to show in partial view
but it should not work here
please help me
What I have tried:
partial view
<td><input type="text" id="InvNo" class="tmp1" readonly="readonly" value="@TempData["iNVOICENO2"]" style="width:70px" /> </td> <td> <input type="text" id="C***" class="c***1" readonly="readonly" value="@TempData["mcountno"]" style="width:70px" /> </td> <td> <input type="text" id="Fstamt" class="fstamt1" readonly="readonly" value="@TempData["xamt"]" style="width:70px" /> </td> <td><input type="text" id="Txtamt" class="tmp3" readonly="readonly" value="@TempData["xtxamt"]" style="width:70px" /></td> <td> <input type="text" id="Tot" class="tot1" readonly="readonly" value="@TempData["xfstamt"]" style="width:70px" /> </td>
controller action
[HttpPost] public JsonResult Cnv(string sypplyerName, int PerTranChallanId, int ChalPerchesTranCode, string ChallaNo, decimal TaxAmount, decimal TotalAmount, int x1 = 1) { //int xcount = (int)TempData["mcountno"]; mcountno++; var suphistry = dc.Supplyers.Where(s => s.Sypplyer_name == sypplyerName).FirstOrDefault(); //Invoice data starr var Newsupname = suphistry.Sypplyer_name; var NewsupID = suphistry.SupplyerID; var newAddinsupl = suphistry.Add_in; var NewClosingBalance = suphistry.ClosingBalance; string newInvno = (string)TempData["invoiceNo"]; DateTime newInvDate = (DateTime)TempData["InvDate"]; var newinvoiceDate = (DateTime)newInvDate; newinvoiceNumber = (string)newInvno; //Invoice data End // Get new ptranCode var ptran = dc.WorkingCodes.Where(m => m.ID == x1).FirstOrDefault(); var m_pran = ptran.PerTranCode; var convrtCode = ptran.Challan_convertCode; convrtCode = convrtCode + 1; m_pran = m_pran + 1; // End New ptrancode //Get Selected challan Data var P = dc.PercheshChallanTransations.Where(p => p.PerTranChallanId == PerTranChallanId).FirstOrDefault(); //End silected challan data int workingtran = dc.PerchesTransactions.Where(m => m.PTranCode == m_pran && m.SupplyerId == NewsupID && m.InvoiceNo == newInvno).Count(); if (workingtran > 0) { PerchesTransaction ptr = new PerchesTransaction { PTranCode = m_pran, }; } else { //Fill Data in Perches transation PerchesTransaction ptr = new PerchesTransaction { PTranCode = m_pran, InvoiceNo = newInvno, InvoiceDate = newInvDate, SupplyerId = NewsupID, SypplyerName = Newsupname, InvoiceFirstTotal = P.InvoiceFirstTotal, TaxAmount = P.TaxAmount, TotalAmount = P.TotalAmount, ChalPerchesTranCode = P.ChalPerchesTranCode, Challan_trancode = convrtCode, PayTranCode = 0, PaidAmount = 0.00m, BalAmount = P.TotalAmount, }; List<object> niv = new List<object> { ptr.InvoiceNo, ptr.InvoiceDate , ptr.SypplyerName , ptr.SupplyerId, ptr.PTranCode, ptr.ChalPerchesTranCode, ptr.Challan_trancode , ptr.InvoiceFirstTotal, ptr.TaxAmount , ptr.TotalAmount, ptr.PayTranCode, ptr.PaidAmount , ptr.BalAmount }; object[] invs = niv.ToArray(); // int outinv = dc.Database.ExecuteSqlCommand("Insert into PerchesTransaction(InvoiceNo,InvoiceDate,SypplyerName,SupplyerId,PTranCode,ChalPerchesTranCode,Challan_trancode,InvoiceFirstTotal,TaxAmount,TotalAmount,PayTranCode,PaidAmount,BalAmount) values(@p0,@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11,@p12)", invs); var chg_Ptran = P.PTranCode; var chg_id = P.PerTranChallanId; // challan transation update PercheshChallanTransation px1 = new PercheshChallanTransation { PTranCode = m_pran, PerTranChallanId = chg_id, }; List<object> chg = new List<object> { px1.PTranCode, px1.PerTranChallanId }; object[] chg1 = chg.ToArray(); // int chg2 = dc.Database.ExecuteSqlCommand("update PercheshChallanTransation set PTranCode=@p0 where PerTranChallanId=@p1 ", chg1); // perches detail update PerchesDetail pt11 = new PerchesDetail { Invoice_no = newinvoiceNumber, InvoiceDate = newinvoiceDate, ChallConvertCode = convrtCode, PerTranCode = m_pran, PerChallanTrancode = P.ChalPerchesTranCode, }; List<object> ppd = new List<object> { pt11.Invoice_no, pt11.InvoiceDate, pt11.ChallConvertCode, pt11.PerTranCode, pt11.PerChallanTrancode }; object[] pp1 = ppd.ToArray(); // int pp2 = dc.Database.ExecuteSqlCommand("Update PerchesDetails set Invoice_no=@p0,InvoiceDate=@p1,ChallConvertCode=@p2,PerTranCode=@p3 where PerChallanTrancode=@p4 ", pp1); // perches detail update End // Supplyer Update Supplyer ss = new Supplyer { ClosingBalance = NewClosingBalance + ptr.TotalAmount, Add_in = newAddinsupl + ptr.TotalAmount, SupplyerID = NewsupID }; List<object> sid = new List<object> { ss.ClosingBalance, ss.Add_in, ss.SupplyerID }; object[] ss1 = sid.ToArray(); // int ss2 = dc.Database.ExecuteSqlCommand("Update Supplyer set ClosingBalance=@p0,Add_in=@p1 where SupplyerID=@p2", ss1); // Supplyer Update end xAmt = xAmt + ptr.TotalAmount; xtxamt = xtxamt + ptr.TaxAmount; xfstamt = xfstamt + ptr.InvoiceFirstTotal; //TempData["Totamt"] = pct.TotalAmount; } //var x11 = dc.PerchesTransactions.Where(x => x.PTranCode == m_pran).FirstOrDefault(); TempData["xamt"] = xAmt; TempData["xtxamt"] = xtxamt; TempData["xfstamt"] = xfstamt; TempData["mcountno"] = mcountno; TempData["iNVOICENO2"] = newinvoiceNumber; TempData.Keep(); var P11 = dc.PercheshChallanTransations.Where(p => p.SypplyerName == sypplyerName).FirstOrDefault(); //var c1 = dc.PerchesTransactions.Where(p => p.ChalPerchesTranCode == ChalPerchesTranCode).FirstOrDefault(); return Json(new { redirectUrl = Url.Action("Getview" , "Perchus"), isRedirect = true }); //return Json(P11, JsonRequestBehavior.AllowGet); } public ActionResult Getview() { xAmt=(decimal)TempData["xamt"] ; xtxamt=(decimal)TempData["xtxamt"] ; xfstamt=(decimal)TempData["xfstamt"] ; mcountno=(int)TempData["mcountno"] ; newinvoiceNumber=(string)TempData["iNVOICENO2"] ; TempData["xamt"] = xAmt; TempData["xtxamt"] = xtxamt; TempData["xfstamt"] = xfstamt; TempData["mcountno"] = mcountno; TempData["iNVOICENO2"] = newinvoiceNumber; TempData.Keep(); return PartialView("PerchesChallan"); }
Here i want to show partial View data
@Html.PagedListPager(Model, page => Url.Action("ConvertrWorker", new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })) <div class="dtl"> <table class="table table-bordered"> <tr id="newrow" class=" myrow"> <td> Ivnoice no : </td> <td> No OF Count : </td> <td> Befor Tax Amount : </td> <td> Tax Amount : </td> <td> Total Amount : </td> <td> Add Charges : </td> <td> Less Discount & Ribet : </td> <td> Submit</td> </tr> <tr id="final" class="final1"> @Html.Partial("PerchesChallan") </tr> </table> </div>
jquery Post method (in short)
$(this).closest("tr").find('#convt').hide(); $(this).closest('tr').find('#cansel').show(); $('.dtl').show(); $.post(url, { sypplyerName: sName, PerTranChallanId: pChallanId, ChalPerchesTranCode: pTranCodeINCHAL, ChallaNo: challaNo, TaxAmount: taxAmount, TotalAmount: totalAmount }, function (data) { $.notify("Update And Convert Challan Succesfully ", "success"); if (json.isRedirect) { window.location.href = json.redirectUrl; } });
.post method to convert challan
and store this all info data in TempData[""] which i want to show in partial view
but it should not work here
please help me
What I have tried:
partial view
<td><input type="text" id="InvNo" class="tmp1" readonly="readonly" value="@TempData["iNVOICENO2"]" style="width:70px" /> </td> <td> <input type="text" id="C***" class="c***1" readonly="readonly" value="@TempData["mcountno"]" style="width:70px" /> </td> <td> <input type="text" id="Fstamt" class="fstamt1" readonly="readonly" value="@TempData["xamt"]" style="width:70px" /> </td> <td><input type="text" id="Txtamt" class="tmp3" readonly="readonly" value="@TempData["xtxamt"]" style="width:70px" /></td> <td> <input type="text" id="Tot" class="tot1" readonly="readonly" value="@TempData["xfstamt"]" style="width:70px" /> </td>
controller action
[HttpPost] public JsonResult Cnv(string sypplyerName, int PerTranChallanId, int ChalPerchesTranCode, string ChallaNo, decimal TaxAmount, decimal TotalAmount, int x1 = 1) { //int xcount = (int)TempData["mcountno"]; mcountno++; var suphistry = dc.Supplyers.Where(s => s.Sypplyer_name == sypplyerName).FirstOrDefault(); //Invoice data starr var Newsupname = suphistry.Sypplyer_name; var NewsupID = suphistry.SupplyerID; var newAddinsupl = suphistry.Add_in; var NewClosingBalance = suphistry.ClosingBalance; string newInvno = (string)TempData["invoiceNo"]; DateTime newInvDate = (DateTime)TempData["InvDate"]; var newinvoiceDate = (DateTime)newInvDate; newinvoiceNumber = (string)newInvno; //Invoice data End // Get new ptranCode var ptran = dc.WorkingCodes.Where(m => m.ID == x1).FirstOrDefault(); var m_pran = ptran.PerTranCode; var convrtCode = ptran.Challan_convertCode; convrtCode = convrtCode + 1; m_pran = m_pran + 1; // End New ptrancode //Get Selected challan Data var P = dc.PercheshChallanTransations.Where(p => p.PerTranChallanId == PerTranChallanId).FirstOrDefault(); //End silected challan data int workingtran = dc.PerchesTransactions.Where(m => m.PTranCode == m_pran && m.SupplyerId == NewsupID && m.InvoiceNo == newInvno).Count(); if (workingtran > 0) { PerchesTransaction ptr = new PerchesTransaction { PTranCode = m_pran, }; } else { //Fill Data in Perches transation PerchesTransaction ptr = new PerchesTransaction { PTranCode = m_pran, InvoiceNo = newInvno, InvoiceDate = newInvDate, SupplyerId = NewsupID, SypplyerName = Newsupname, InvoiceFirstTotal = P.InvoiceFirstTotal, TaxAmount = P.TaxAmount, TotalAmount = P.TotalAmount, ChalPerchesTranCode = P.ChalPerchesTranCode, Challan_trancode = convrtCode, PayTranCode = 0, PaidAmount = 0.00m, BalAmount = P.TotalAmount, }; List<object> niv = new List<object> { ptr.InvoiceNo, ptr.InvoiceDate , ptr.SypplyerName , ptr.SupplyerId, ptr.PTranCode, ptr.ChalPerchesTranCode, ptr.Challan_trancode , ptr.InvoiceFirstTotal, ptr.TaxAmount , ptr.TotalAmount, ptr.PayTranCode, ptr.PaidAmount , ptr.BalAmount }; object[] invs = niv.ToArray(); // int outinv = dc.Database.ExecuteSqlCommand("Insert into PerchesTransaction(InvoiceNo,InvoiceDate,SypplyerName,SupplyerId,PTranCode,ChalPerchesTranCode,Challan_trancode,InvoiceFirstTotal,TaxAmount,TotalAmount,PayTranCode,PaidAmount,BalAmount) values(@p0,@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11,@p12)", invs); var chg_Ptran = P.PTranCode; var chg_id = P.PerTranChallanId; // challan transation update PercheshChallanTransation px1 = new PercheshChallanTransation { PTranCode = m_pran, PerTranChallanId = chg_id, }; List<object> chg = new List<object> { px1.PTranCode, px1.PerTranChallanId }; object[] chg1 = chg.ToArray(); // int chg2 = dc.Database.ExecuteSqlCommand("update PercheshChallanTransation set PTranCode=@p0 where PerTranChallanId=@p1 ", chg1); // perches detail update PerchesDetail pt11 = new PerchesDetail { Invoice_no = newinvoiceNumber, InvoiceDate = newinvoiceDate, ChallConvertCode = convrtCode, PerTranCode = m_pran, PerChallanTrancode = P.ChalPerchesTranCode, }; List<object> ppd = new List<object> { pt11.Invoice_no, pt11.InvoiceDate, pt11.ChallConvertCode, pt11.PerTranCode, pt11.PerChallanTrancode }; object[] pp1 = ppd.ToArray(); // int pp2 = dc.Database.ExecuteSqlCommand("Update PerchesDetails set Invoice_no=@p0,InvoiceDate=@p1,ChallConvertCode=@p2,PerTranCode=@p3 where PerChallanTrancode=@p4 ", pp1); // perches detail update End // Supplyer Update Supplyer ss = new Supplyer { ClosingBalance = NewClosingBalance + ptr.TotalAmount, Add_in = newAddinsupl + ptr.TotalAmount, SupplyerID = NewsupID }; List<object> sid = new List<object> { ss.ClosingBalance, ss.Add_in, ss.SupplyerID }; object[] ss1 = sid.ToArray(); // int ss2 = dc.Database.ExecuteSqlCommand("Update Supplyer set ClosingBalance=@p0,Add_in=@p1 where SupplyerID=@p2", ss1); // Supplyer Update end xAmt = xAmt + ptr.TotalAmount; xtxamt = xtxamt + ptr.TaxAmount; xfstamt = xfstamt + ptr.InvoiceFirstTotal; //TempData["Totamt"] = pct.TotalAmount; } //var x11 = dc.PerchesTransactions.Where(x => x.PTranCode == m_pran).FirstOrDefault(); TempData["xamt"] = xAmt; TempData["xtxamt"] = xtxamt; TempData["xfstamt"] = xfstamt; TempData["mcountno"] = mcountno; TempData["iNVOICENO2"] = newinvoiceNumber; TempData.Keep(); var P11 = dc.PercheshChallanTransations.Where(p => p.SypplyerName == sypplyerName).FirstOrDefault(); //var c1 = dc.PerchesTransactions.Where(p => p.ChalPerchesTranCode == ChalPerchesTranCode).FirstOrDefault(); return Json(new { redirectUrl = Url.Action("Getview" , "Perchus"), isRedirect = true }); //return Json(P11, JsonRequestBehavior.AllowGet); } public ActionResult Getview() { xAmt=(decimal)TempData["xamt"] ; xtxamt=(decimal)TempData["xtxamt"] ; xfstamt=(decimal)TempData["xfstamt"] ; mcountno=(int)TempData["mcountno"] ; newinvoiceNumber=(string)TempData["iNVOICENO2"] ; TempData["xamt"] = xAmt; TempData["xtxamt"] = xtxamt; TempData["xfstamt"] = xfstamt; TempData["mcountno"] = mcountno; TempData["iNVOICENO2"] = newinvoiceNumber; TempData.Keep(); return PartialView("PerchesChallan"); }
Here i want to show partial View data
@Html.PagedListPager(Model, page => Url.Action("ConvertrWorker", new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })) <div class="dtl"> <table class="table table-bordered"> <tr id="newrow" class=" myrow"> <td> Ivnoice no : </td> <td> No OF Count : </td> <td> Befor Tax Amount : </td> <td> Tax Amount : </td> <td> Total Amount : </td> <td> Add Charges : </td> <td> Less Discount & Ribet : </td> <td> Submit</td> </tr> <tr id="final" class="final1"> @Html.Partial("PerchesChallan") </tr> </table> </div>
jquery Post method (in short)
(this).closest("tr").find('#convt').hide();
(this).closest('tr').find('#cansel').show();
这篇关于如何在ASP.NET MVC和jquery中的$ .post之后编写部分视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!