SGGL_HBAZ/SGGL/WebAPI/Controllers/MaterialsExitController.cs

92 lines
3.6 KiB
C#
Raw Normal View History

2025-07-08 18:51:57 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Web.Http;
using WebAPI.Helpers;
namespace WebAPI.Controllers
{
public class MaterialsExitController : ApiController
{
#region
[HttpPost]
public Model.ResponeData AddMaterialExitM(Model.Cl_W_MaterialStorageM exit)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var userTime = DateTime.Now;
int count = db.Cl_W_MaterialStorageM.Where(x => x.UserTime.Value.Year == userTime.Year && x.UserTime.Value.Month == userTime.Month && x.UserTime.Value.Day == userTime.Day).ToList().Count();
Model.Cl_W_MaterialStorageM exitM = new Model.Cl_W_MaterialStorageM
{
StorageSheetMID = exit.StorageSheetMID,
StorageSheetCode = string.Format("RKD--{0}{1}", DateTime.Now.ToString("yyyyMMdd"), count.ToString("000")),
UserId = exit.UserId,
UserTime = DateTime.Now,
IsOk = "0", // 0-未审核1-已审核
APid = exit.APid, // 采购方类别(甲乙供)
Specialityid = exit.Specialityid, // 专业ID
InstallationId = exit.InstallationId
};
exit.UserTime = DateTime.Now;
exit.StorageSheetCode = string.Format("CKD--{0}{1}", DateTime.Now.ToString("yyyyMMdd"), count.ToString("000"));
db.Cl_W_MaterialStorageM.InsertOnSubmit(exitM);
db.SubmitChanges();
responeData.data = exit;
}
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
[HttpPost]
public Model.ResponeData AddMaterialExitS(Model.Cl_W_MaterialStorageS s)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Cl_W_MaterialStorageS cws = new Model.Cl_W_MaterialStorageS();
cws.SystemCode = s.SystemCode;
cws.StorageQuantity = s.StorageQuantity; // 到货数量
cws.TheoryWeight = s.TheoryWeight; // 单价
cws.ActualWeight = s.ActualWeight; // 金额
cws.RecordTableOptions = s.RecordTableOptions; // 备注说明
cws.Manufacturer = s.Manufacturer; // 制造厂家
cws.ProjectId = s.ProjectId;
cws.StorageSheetMID = s.StorageSheetMID;
cws.StorageSheetSID = Guid.NewGuid().ToString();
cws.MaterialID = s.MaterialID;
db.Cl_W_MaterialStorageS.InsertOnSubmit(cws);
db.SubmitChanges();
responeData.data = "添加成功";
}
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}