目录
1、 PurchasereturnController
1.1、 反审核退货单
1.1.1、 //配件ID
1.1.2、 //配件编码
1.1.3、 //修改后仓库
1.1.4、 //修改配件信息表库存量
using QXQPS.Models;
using QXQPS.Vo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace QXQPS.Areas.AccessoriessalesManagment.Controllers
{
public class PurchasereturnController : Controller
{
QXQPEntities myModels = new Models.QXQPEntities();
// GET: AccessoriessalesManagment/Purchasereturn
public ActionResult NoToAuditReturnForm(int ReturnFormID, int NewWarehouseID)//反审核退货单
{
var listReturnFormDetail = myModels.SYS_ReturnFormDetail.Where(m => m.ReturnFormID == ReturnFormID).ToList();
try
{
var list = myModels.PW_ReturnForm.Where(m => m.ReturnFormID == ReturnFormID).Single();
list.ReturnFormID = list.ReturnFormID;
list.ToAudit = false;
myModels.Entry(list).State = System.Data.Entity.EntityState.Modified;
if (myModels.SaveChanges() > 0)
{
foreach (var item in listReturnFormDetail)
{
var ReturnFormDetailID = item.ReturnFormDetailID;//明细ID
var FittingsInfoID = item.FittingsInfoID;
var Quantity = item.Quantity;//数量
var listinfor = myModels.SYS_FittingsInfo.Where(m => m.FittingsInfoID == FittingsInfoID).Select(m => new { m.FittingsCode }).SingleOrDefault();
var FittingsCode = listinfor.FittingsCode;
var listInventorys = myModels.SYS_Inventory.Where(m => m.WarehouseID == NewWarehouseID && m.FittingsCode == FittingsCode).SingleOrDefault();
listInventorys.InvenQuan = listInventorys.InvenQuan - Quantity;
myModels.Entry(listInventorys).State = System.Data.Entity.EntityState.Modified;
myModels.SaveChanges();
-
-
- //修改配件信息表库存量
-
var listFit = myModels.SYS_FittingsInfo.Where(m => m.FittingsInfoID == FittingsInfoID).SingleOrDefault();
listFit.InvenQuan = listFit.InvenQuan - Quantity;
myModels.Entry(listFit).State = System.Data.Entity.EntityState.Modified;
}
}
myModels.SaveChanges();
}
catch (Exception)
{
return Json(false, JsonRequestBehavior.AllowGet);
}
return Json(true, JsonRequestBehavior.AllowGet);
}