using DBUtility;
|
using Model;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web.Http;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers.基础资料.基础资料
|
{
|
public class Gy_AssistantDataEntryController : ApiController
|
{
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
ListModels oListModels = new ListModels();
|
DataSet ds;
|
|
#region 销售退货原因/退货类型 金蝶云审核同步 API
|
[Route("Gy_AssistantDataEntry/SaveGy_AssistantDataEntryApi")]
|
[HttpPost]
|
public object SaveGy_AssistantDataEntryApi([FromBody] JObject sMainSub)
|
{
|
|
try
|
{
|
oCN.BeginTran();
|
LogService.Write("销售退货原因/退货类型 审核同步: " + sMainSub.ToString());
|
|
var sMain = "[" + sMainSub["model"].ToString() + "]";
|
var sSub = sMainSub["model"]["FENTRY"].ToString();
|
|
List<Model.ClsGy_AssistantData> lsmain = new List<Model.ClsGy_AssistantData>();
|
List<Model.ClsGy_AssistantDataEntry> lssub = new List<Model.ClsGy_AssistantDataEntry>();
|
lsmain = oListModels.getObjectByJson_Gy_AssistantData(sMain);
|
lssub = oListModels.getObjectByJson_Gy_AssistantDataEntry(sSub);
|
var sql = string.Empty;
|
foreach (var oMain in lsmain)
|
{
|
// 删除主表数据
|
sql = $@"delete from Gy_AssistantData where HID = {oMain.HID}";
|
oCN.RunProc(sql);
|
// 删除子表数据
|
sql = $@"delete from Gy_AssistantDataEntry where HID = {oMain.HID}";
|
oCN.RunProc(sql);
|
|
sql = $@"insert into Gy_AssistantData
|
(HID,HNumber,HName,HRemark,HLOCALEID)
|
values({oMain.HID}, '{oMain.HNumber}', '{oMain.HName}', '{oMain.HRemark}',
|
{oMain.HLOCALEID}
|
)
|
)
|
";
|
|
foreach(var oSub in lssub)
|
{
|
sql = $@"insert into Gy_AssistantDataEntry
|
(HID,HEntryID,HNumber,HName,HStopflag,HRemark
|
,HMakeTime,HMakeEmp,HCheckTime,HCheckEmp,HModifyTime,HModifyEmp
|
,HLOCALEID,HUSEORGID,HCREATEORGID)
|
values({oSub.HID}, '{oSub.HEntryID}', '{oSub.HNumber}', '{oSub.HName}',
|
'{oSub.HStopflag}', '{oSub.HRemark}', '{oSub.HMakeTime}',
|
'{oSub.HMakeEmp}', '{oSub.HCheckTime}', '{oSub.HCheckEmp}',
|
'{oSub.HModifyTime}', '{oSub.HModifyEmp}','{oSub.HLOCALEID}',
|
'{oSub.HUSEORGID}', '{oSub.HCREATEORGID}'
|
)
|
";
|
|
oCN.RunProc(sql);
|
}
|
|
}
|
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "保存成功!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
}
|
}
|