chenhaozhe
2025-10-20 412008d398f3554755ffd52257e7564b83eebb1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
    }
}