chenhaozhe
2026-03-27 9d4fdc8ef43bfcafdb4a0f3e0e3d59cef1812b15
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DBUtility;
 
namespace DAL
{
    public class ClsCg_OrderTransportBill_Ctl : ClsXt_BaseBill
    {
 
        public ClsCg_OrderTransportBill_Ctl()
        {
            base.MvarItemKeySub = "ClsCg_OrderTransportBillSub";
            base.MvarItemKeySub2 = "ClsCg_OrderTransportBillSub_Money";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "ClsCg_OrderTransportBillMain";
            base.MvarReportTitle = "运单申请";
            base.BillType = "1118";
            base.HBillSubType = "1118";
 
        }
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        //原代码 用于 替换子项目
        public string HOldNumber;
        public Model.ClsCg_OrderTransportBill_Model oModel = new Model.ClsCg_OrderTransportBill_Model();
        public Model.ClsCg_OrderTransportBillSub_Model oModel_Sub = new Model.ClsCg_OrderTransportBillSub_Model();
        public Model.ClsCg_OrderTransportBillSub_Money_Model oModel_Sub_Money = new Model.ClsCg_OrderTransportBillSub_Money_Model();
 
        public override bool DeleteBill(long lngBillKey, ref string sReturn)
        {
            return base.DeleteBill(lngBillKey, ref sReturn);
        }
 
        public override bool IsExistMainID(ref string sReturn, long lngBillKey, Pub_Class.ClsPub.Enum_BillStatus oBillStatus)
        {
            return base.IsExistMainID(ref sReturn, lngBillKey, oBillStatus);
        }
 
        public override bool IsExistBillNo(ref string sReturn, string sBillNo, Pub_Class.ClsPub.Enum_BillStatus oBillStatus, long lngBillKey)
        {
            return base.IsExistBillNo(ref sReturn, sBillNo, oBillStatus, lngBillKey);
        }
 
        public override bool ModifyBill(long lngBillKey, ref string sReturn)
        {
            return base.ModifyBill(lngBillKey, ref sReturn);
        }
 
        public override bool AddBill(ref string sReturn)
        {
            bool success = false;
            // 添加主表
            string sql = $@" Insert Into {MvarItemKey}
            INSERT INTO BillMain (
            HYear, HPeriod, HBillType, HBillSubType, HInterID, HDate, HBillNo, HBillStatus,
            HCheckItemNowID, HCheckItemNextID, HCheckFlowID, HRemark, HBacker, HBackDate, HBackRemark,
            HChecker, HCheckDate, HMaker, HMakeDate, HUpDater, HUpDateDate, HCloseMan, HCloseDate,
            HCloseType, HDeleteMan, HDeleteDate, HMainSourceBillType, HMainSourceInterID, HMainSourceEntryID,
            HMainSourceBillNo, HPrintQty, HItemMainID, HCusID, HStockOutBillMainID, HStockOutBillNo,
            HSupID, HOrderBillNumber, HOrderType, HTransportType, HTransportMoney, HSendAddr,
            HReceAddr, HGoodsVolume, HTakeGoodsTime, HArriveGoodsTime, HCarID, HDriverID,
            HLoadRate, HOrderStatus
            ) VALUES (
            {oModel.HYear}, {oModel.HPeriod}, '{oModel.HBillType}', '{oModel.HBillSubType}', {oModel.HInterID}, '{oModel.HDate}', '{oModel.HBillNo}', {oModel.HBillStatus},
            {oModel.HCheckItemNowID}, {oModel.HCheckItemNextID}, {oModel.HCheckFlowID}, '{oModel.HRemark}', '{oModel.HBacker}', '{oModel.HBackDate}', '{oModel.HBackRemark}',
            '{oModel.HChecker}', '{oModel.HCheckDate}', '{oModel.HMaker}', '{oModel.HMakeDate}', '{oModel.HUpDater}', '{oModel.HUpDateDate}', '{oModel.HCloseMan}', '{oModel.HCloseDate}',
            {oModel.HCloseType}, '{oModel.HDeleteMan}', '{oModel.HDeleteDate}', '{oModel.HMainSourceBillType}', {oModel.HMainSourceInterID}, {oModel.HMainSourceEntryID},
            '{oModel.HMainSourceBillNo}', {oModel.HPrintQty}, {oModel.HItemMainID}, {oModel.HCusID}, {oModel.HStockOutBillMainID}, '{oModel.HStockOutBillNo}',
            {oModel.HSupID}, '{oModel.HOrderBillNumber}', '{oModel.HOrderType}', '{oModel.HTransportType}', {oModel.HTransportMoney}, '{oModel.HSendAddr}',
            '{oModel.HReceAddr}', {oModel.HGoodsVolume}, '{oModel.HTakeGoodsTime}', '{oModel.HArriveGoodsTime}', {oModel.HCarID}, {oModel.HDriverID},
            {oModel.HLoadRate}, {oModel.HOrderStatus}
            ";
 
            oCn.RunProc(sql);
            // 添加子表
            success = AddBillSub(ref DBUtility.ClsPub.sExeReturnInfo);
 
            // 添加子表-金额
            success = AddBillSub_Money(ref DBUtility.ClsPub.sExeReturnInfo);
 
            return success;
        }
 
        public override bool ShowBill(long lngBillKey, ref string sReturn)
        {
            return base.ShowBill(lngBillKey, ref sReturn);
        }
 
        public override void DeleteRelation(ref string sReturn, long lngBillKey)
        {
            base.DeleteRelation(ref sReturn, lngBillKey);
        }
 
        public override void AddNewRelation(ref string sReturn, long lngBillKey)
        {
            base.AddNewRelation(ref sReturn, lngBillKey);
        }
 
        // 添加子单据
        public bool AddBillSub(ref string sReturn)
        {
            string sql = $@"
            INSERT INTO {MvarItemKeySub} (
                HInterID, HBillNo_bak, HEntryID, HCloseMan, HEntryCloseDate, HCloseType,
                HRemark, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType,
                HRelationQty, HRelationMoney, HItemSubID, HMaterID, HVolume, HPack, HUnitID
            ) VALUES (
                {oModel_Sub.HInterID}, '{oModel_Sub.HBillNo_bak}', {oModel_Sub.HEntryID}, 
                '{oModel_Sub.HCloseMan}', '{oModel_Sub.HEntryCloseDate}', {oModel_Sub.HCloseType}, 
                '{oModel_Sub.HRemark}', {oModel_Sub.HSourceInterID}, {oModel_Sub.HSourceEntryID}, 
                '{oModel_Sub.HSourceBillNo}', '{oModel_Sub.HSourceBillType}', {oModel_Sub.HRelationQty}, 
                '{oModel_Sub.HRelationMoney}', {oModel_Sub.HItemSubID}, {oModel_Sub.HMaterID}, 
                {oModel_Sub.HVolume}, '{oModel_Sub.HPack}', {oModel_Sub.HUnitID}
            )
            ";
            oCn.RunProc(sql);
 
            return true;
        }
 
        // 添加子单据 费用
        public bool AddBillSub_Money(ref string sReturn)
        {
            string sql = $@"
            INSERT INTO {MvarItemKeySub} (
                HInterID, HBillNo_bak, HEntryID, HCloseMan, HEntryCloseDate, HCloseType,
                HRemark, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType,
                HRelationQty, HRelationMoney, HItemSubID, HMaterID, HVolume, HPack, HUnitID
            ) VALUES (
                {oModel_Sub.HInterID}, '{oModel_Sub.HBillNo_bak}', {oModel_Sub.HEntryID}, 
                '{oModel_Sub.HCloseMan}', '{oModel_Sub.HEntryCloseDate}', {oModel_Sub.HCloseType}, 
                '{oModel_Sub.HRemark}', {oModel_Sub.HSourceInterID}, {oModel_Sub.HSourceEntryID}, 
                '{oModel_Sub.HSourceBillNo}', '{oModel_Sub.HSourceBillType}', {oModel_Sub.HRelationQty}, 
                '{oModel_Sub.HRelationMoney}', {oModel_Sub.HItemSubID}, {oModel_Sub.HMaterID}, 
                {oModel_Sub.HVolume}, '{oModel_Sub.HPack}', {oModel_Sub.HUnitID}
            )
            ";
            oCn.RunProc(sql);
 
            return true;
        }
    }
}