CustomersettleController
目录
1、 CustomersettleController
1.1、 新增结算单
1.1.1、 //声明一个变量
1.1.2、 //结算单
1.1.3、 //新增
1.1.4、 //修改
using QXQPS.Models;
using QXQPS.Vo;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace QXQPS.Areas.ProcurementManagment.Controllers
{
public class CustomersettleController : Controller
{
QXQPEntities myModels = new QXQPEntities();
public ActionResult Insertencipher(List<PW_SalBalance> ListSalBalance, List<SYS_SalBalancetDetail> ListSalesorderDetai)//新增结算单
{
var SalBalanceID = 0;
var tt = 0;
try
{
-
-
- //结算单
-
if (ListSalBalance[0].SalBalanceID == 0)
{
-
-
- //新增
-
myModels.PW_SalBalance.Add(ListSalBalance[0]);
tt = myModels.SaveChanges();//赋值
SalBalanceID = ListSalBalance[0].SalBalanceID;
}
else
{
-
-
- //修改
-
myModels.Entry(ListSalBalance[0]).State = System.Data.Entity.EntityState.Modified;
myModels.SaveChanges();
}
if (tt > 0)
{
ListSalesorderDetai[0].SalBalanceID = ListSalBalance[0].SalBalanceID;
if (ListSalesorderDetai[0].SalBalancetDetailID == 0)
{
myModels.SYS_SalBalancetDetail.Add(ListSalesorderDetai[0]); //新增
myModels.SaveChanges();
}
else
{
myModels.Entry(ListSalesorderDetai[0]).State = System.Data.Entity.EntityState.Modified;//修改
myModels.SaveChanges();
}
myModels.SaveChanges();
}
}
catch (Exception)
{
return Json(false, JsonRequestBehavior.AllowGet);
}
return Json(SalBalanceID, JsonRequestBehavior.AllowGet);
}