zrg
2024-10-09 243e86af1a7c74c8bfda3bb41f29a11fef13c065
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using ViewAPI;
 
namespace WebAPI.DLL
{
    public class ClsSc_ICMOStepBillWorkQtyStatus_Tmp : DBUtility.ClsXt_BaseBill
    {
        //生产产量状态临时表
        public Models.ClsSc_ICMOBillWorkQtyStatus_Tmp omodel = new Models.ClsSc_ICMOBillWorkQtyStatus_Tmp();
 
        public ClsSc_ICMOStepBillWorkQtyStatus_Tmp()
        {
            base.MvarItemKeySub = "";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "Sc_ICMOBillWorkQtyStatus_Tmp";
            base.MvarReportTitle = "生产产量状态临时表(工序)";
            base.BillType = "3724";
        }
 
        #region 固定代码
 
        ~ClsSc_ICMOStepBillWorkQtyStatus_Tmp()
        {
        }
 
        #endregion   自定义方法
 
        //修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //
                oCn.BeginTran();
                //更新主表
                oCn.RunProc("UpDate Sc_ICMOBillWorkQtyStatus_Tmp set  " +
                "HSourceID=" + omodel.HSourceID.ToString() +
                ",HReportType=" + omodel.HReportType.ToString() +
                ",HPieceQty=" + omodel.HPieceQty.ToString() +
                ",HQty=" + omodel.HQty.ToString() +
                ",HBarCode='" + omodel.HBarCode + "'" +
                ",HAddr='" + omodel.HAddr + "'" +
                ",HSourceInterID=" + omodel.HSourceInterID.ToString() +
                ",HSourceEntryID=" + omodel.HSourceEntryID.ToString() +
                ",HSourceBillNo='" + omodel.HSourceBillNo + "'" +
                ",HSplitNO='" + omodel.HSplitNO + "'" +
                ",HSourceBillType='" + omodel.HSourceBillType + "'" +
                ",HRelationInterID=" + omodel.HRelationInterID.ToString() +
                ",HRelationEntryID=" + omodel.HRelationEntryID.ToString() +
                ",HRelationBillNo='" + omodel.HRelationBillNo + "'" +
                ",HReportEntryID=" + omodel.HReportEntryID.ToString() +
                ",HGroupID=" + omodel.HGroupID.ToString() +
                ",HWorkManID=" + omodel.HWorkManID.ToString() +
                ",HBadQty=" + omodel.HBadQty.ToString() +
                ",HWasterQty=" + omodel.HWasterQty.ToString() +
                " where HInterID=" + lngBillKey.ToString());
                //删除关联
                DeleteRelation(ref sReturn, lngBillKey);
 
                sReturn = "修改单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        //新增单据
        public override bool AddBill(ref string sReturn)
        {
            try
            {
                //得到mainid
                omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                //若MAINDI重复则重新获取
                oCn.BeginTran();
                //主表
 
                oCn.RunProc("Insert Into Sc_ICMOBillWorkQtyStatus_Tmp   " +
               "(HInterID,HBillType,HSourceID,HReportType,HPieceQty" +
               ",HMaterID,HGroupID,HWorkManID,HWorkReportDate,HDate" +
               ",HBillSubType,HBillNo,HICMOInterID,HICMOEntryID,HICMOBillNo" +
               ",HPlanQty,HQty,HBadQty,HWasterQty,HBarCode,HAddr,HMaker,HMakeDate" +
               ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSplitNO,HSourceBillType" +
               ",HRelationInterID,HRelationEntryID,HRelationBillNo,HReportEntryID,HProcID" +
               ") " +
                " values(" + omodel.HInterID.ToString() + ",'" + BillType + "'," + omodel.HSourceID.ToString() + "," + omodel.HReportType.ToString() + "," + omodel.HPieceQty.ToString() +
                "," + omodel.HMaterID.ToString() + ",'" + omodel.HGroupID + "','" + omodel.HWorkManID + "','" + omodel.HWorkReportDate + "','" + omodel.HDate + "'" +
                ",'" + omodel.HBillSubType.ToString() + "','" + omodel.HBillNo + "','" + omodel.HICMOInterID + "','" + omodel.HICMOEntryID + "','" + omodel.HICMOBillNo + "'" +
                "," + omodel.HPlanQty.ToString() + "," + omodel.HQty.ToString() + "," + omodel.HBadQty.ToString() + "," + omodel.HWasterQty.ToString() + ",'" + omodel.HBarCode + "','" + omodel.HAddr + "','" + omodel.HMaker + "','" + omodel.HMakeDate + "'" +
                "," + omodel.HSourceInterID.ToString() + "," + omodel.HSourceEntryID.ToString() + ",'" + omodel.HSourceBillNo + "','" + omodel.HSplitNO + "','" + omodel.HSourceBillType + "'" +
                "," + omodel.HRelationInterID.ToString() + "," + omodel.HRelationEntryID.ToString() + ",'" + omodel.HRelationBillNo + "'," + omodel.HReportEntryID.ToString() + ",'" + omodel.HProcID + "'" +
                ") ");
                //更新关联数量
                //AddNewRelation(ref sReturn, omodel.HInterID);
                //更新关联数量
                oCn.RunProc("exec h_p_Sc_UpDateICMOBillStepStatusRelation_Add " + omodel.HInterID);
                //回填 生产状态表  日计划  为 已完工 状态
                //oCn.RunProc("exec h_p_Sc_UpDateICMOBillQualityStatus " + omodel.HICMOStatusInterID.ToString() + ",3");
 
                //再次验证 保存是否 合理
                DataSet ds = oCn.RunProcReturn("exec h_p_JIT_ICMOBillWorkQtyStatus_SaveCtrl @HInterId=" + omodel.HInterID + "", "h_p_JIT_ICMOBillWorkQtyStatus_SaveCtrl");
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    sReturn = "无验证数据!";
                    oCn.RollBack();
                    return false;
                }
                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
                {
                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    oCn.RollBack();
                    return false;
                }
 
 
                sReturn = omodel.HInterID.ToString();
 
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        //显示单据
        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds;
                Ds = oCn.RunProcReturn("Select * from Sc_ICMOBillWorkQtyStatus_Tmp Where HInterID=" + lngBillKey.ToString(), "Sc_ICMOBillWorkQtyStatus_Tmp");
                if (Ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //赋值
                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
                omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
                omodel.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]);
                omodel.HReportType = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HReportType"]);
                omodel.HPieceQty = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPieceQty"]);
                omodel.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"]);
                omodel.HBarCode = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCode"]);
                omodel.HAddr = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAddr"]);
                omodel.HMaker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaker"]);
                omodel.HMakeDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMakeDate"]);
                omodel.HSourceInterID = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HSourceInterID"]);
                omodel.HSourceEntryID = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HSourceEntryID"]);
                omodel.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillNo"]);
                omodel.HSplitNO = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSplitNO"]);
                omodel.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillType"]);
                omodel.HRelationInterID = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HRelationInterID"]);
                omodel.HRelationEntryID = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HRelationEntryID"]);
                omodel.HRelationBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRelationBillNo"]);
                omodel.HReportEntryID = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HReportEntryID"]);
                omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
                omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
                omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
                omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
                omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
                omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
                omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
                omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
                omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
                omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
                omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
                omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
 
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
 
        //审核
        public bool CheckBill(int HSourceID, int HSourceInterID, int HSourceEntryID, string HSourceBillNo, int HICMOInterID, int HICMOEntryID, Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
        {
            string sql = "";
            DataSet ds;
            try
            {
                string HChecker = DBUtility.ClsPub.CurUserName;
                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
                oCn.BeginTran();
                oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='2',HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString());
                sReturn = "审核单据成功!";
 
                //审核后控制===============================================Begin================================================================
                sql = "exec " + procName + " " + lngBillKey + ",'" + HBillNo + "','" + sUser + "'";
                ds = oCn.RunProcReturn(sql, procName);
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "审核过程中出错,请与网络管理人员联系";
                    oCn.RollBack();
                    return false;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    oCn.RollBack();
                    return false;
                }
                //审核后控制===============================================End================================================================
 
                oCn.Commit();
                //生成调拨单
                //得到调拨单 mainid 单据号
                //long NewInterID = DBUtility.ClsPub.CreateBillID("1207", ref DBUtility.ClsPub.sExeReturnInfo);
                //string NewBillNo = DBUtility.ClsPub.CreateBillCode("1207", ref DBUtility.ClsPub.sExeReturnInfo, true);//得到新单号
                //oCn.RunProc("exec h_p_Kf_MoveStockBill_Add " + lngBillKey.ToString() + "," + NewInterID.ToString() + ",'" + NewBillNo + "','" + HChecker + "'");
                //
                sReturn = "";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //反审核
        public bool AbandonCheck(int HSourceID, int HSourceInterID, int HSourceEntryID, string HSourceBillNo, int HICMOInterID, int HICMOEntryID, Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
        {
            string sql = "";
            DataSet ds;
            try
            {
                string HChecker = DBUtility.ClsPub.CurUserName;
                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
                oCn.BeginTran();
                //还原单据状态为未审核状态
                oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='1',HChecker='',HCheckDate='' Where HInterID=" + lngBillKey.ToString());
                sReturn = "反审核单据成功!";
 
                //审核后控制===============================================Begin================================================================
                sql = "exec " + procName + " " + lngBillKey + ",'" + HBillNo + "','" + sUser + "'";
                ds = oCn.RunProcReturn(sql, procName);
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "反审核过程中出错,请与网络管理人员联系";
                    oCn.RollBack();
                    return false;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    oCn.RollBack();
                    return false;
                }
                //审核后控制===============================================End================================================================
 
                oCn.Commit();
                //生成调拨单
                //得到调拨单 mainid 单据号
                //long NewInterID = DBUtility.ClsPub.CreateBillID("1207", ref DBUtility.ClsPub.sExeReturnInfo);
                //string NewBillNo = DBUtility.ClsPub.CreateBillCode("1207", ref DBUtility.ClsPub.sExeReturnInfo, true);//得到新单号
                //oCn.RunProc("exec h_p_Kf_MoveStockBill_Add " + lngBillKey.ToString() + "," + NewInterID.ToString() + ",'" + NewBillNo + "','" + HChecker + "'");
                //
                sReturn = "";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //判断是否完工
        public bool IsEnded(long HInterID, ref string sReturn)
        {
            try
            {
                DataSet DS;
                DS = oCn.RunProcReturn("exec h_p_Sc_ICMOReportBill_WMSQty " + HInterID.ToString(), "Sc_ICMOReportBillSub_WMS");
                if (DS.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
                if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBool"]) != "")
                {
                    sReturn = "已完工!";
                    return true;
                }
                else
                {
                    sReturn = "未完工!";
                    return false;
                }
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
 
 
 
    }
}