yusijie
2024-04-10 99136e90515aae6031bf6ba870835774735172b4
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public class ClsSc_ICMOBillStatus_Tmp : DBUtility.ClsXt_BaseBill 
    {
        //Éú²ú״̬ÁÙʱ±í
        public Model.ClsSc_ICMOBillStatus_Tmp omodel = new Model.ClsSc_ICMOBillStatus_Tmp(); 
 
        public ClsSc_ICMOBillStatus_Tmp()
        {
            base.MvarItemKeySub = "";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "Sc_ICMOBillStatus_Tmp";
            base.MvarReportTitle="Éú²ú״̬ÁÙʱ±í";
            base.BillType = "3722"; 
        }
 
        #region ¹Ì¶¨´úÂë
 
        ~ClsSc_ICMOBillStatus_Tmp()
        { 
        }
       
        #endregion   ×Ô¶¨Òå·½·¨
        //Ð޸ĵ¥¾Ý
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //
                oCn.BeginTran();
                //¸üÐÂÖ÷±í
                oCn.RunProc("UpDate Sc_ICMOBillStatus_Tmp set  " +
                " HYear=" + omodel.HYear.ToString() +
                ",HPeriod=" + omodel.HPeriod.ToString() +
                ",HBillType='" + omodel.HBillType + "'" +
                ",HDate='" + omodel.HDate.ToShortDateString() + "'" +
                ",HICMOInterID=" + omodel.HICMOInterID.ToString() +
                ",HICMOBillNo='" + omodel.HICMOBillNo + "'" +
                ",HSplitNO='" + omodel.HSplitNO + "'" +
                ",HICMOStatus=" + omodel.HICMOStatus.ToString() +
                ",HMaterID=" + omodel.HMaterID.ToString() +
                ",HMaterNumber='" + omodel.HMaterNumber + "'" +
                ",HUnitID=" + omodel.HUnitID.ToString() +
                ",HUnitNumber='" + omodel.HUnitNumber + "'" +
                ",HSourceID=" + omodel.HSourceID.ToString() +
                ",HSourceNumber='" + omodel.HSourceNumber + "'" +
                ",HPlanQty=" + omodel.HPlanQty.ToString() +
                ",HSplitPlanQty=" + omodel.HSplitPlanQty.ToString() +
                ",HSplitRelationQty=" + omodel.HSplitRelationQty.ToString() +
                ",HDatePlanQty=" + omodel.HDatePlanQty.ToString() +
                ",HUnitFinishQty=" + omodel.HUnitFinishQty.ToString() +
                ",HDateFinishQty=" + omodel.HDateFinishQty.ToString() +
                ",HBadQty=" + omodel.HBadQty.ToString() +
                ",HUnitBadQty=" + omodel.HUnitBadQty.ToString() +
                ",HWasterQty=" + omodel.HWasterQty.ToString() +
                ",HSumTimes=" + omodel.HSumTimes.ToString() +
                ",HFinishFlag=" + DBUtility.ClsPub.BoolToString(omodel.HFinishFlag) +
                ",HCurWorkFlag=" + DBUtility.ClsPub.BoolToString(omodel.HCurWorkFlag) +
                ",HCurQualityFlag=" + DBUtility.ClsPub.BoolToString(omodel.HCurQualityFlag) +
                ",HBeginDate='" + omodel.HBeginDate.ToShortDateString() + "'" +
                ",HEndDate='" + omodel.HEndDate.ToShortDateString() + "'" +
                ",HRemark='" + omodel.HRemark + "'" +
                ",HSourceInterID=" + omodel.HSourceInterID.ToString() +
                ",HSourceEntryID=" + omodel.HSourceEntryID.ToString() +
                ",HSourceBillNo='" + omodel.HSourceBillNo + "'" +
                ",HSourceBillType='" + omodel.HSourceBillType + "'" +
                ",HRelationInterID=" + omodel.HRelationInterID.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_ICMOBillStatus_Tmp   " +
                "(HYear,HPeriod,HBillType,HDate,HICMOInterID" +
                ",HICMOBillNo,HSplitNO,HICMOStatus,HMaterID,HMaterNumber" +
                ",HUnitID,HUnitNumber,HSourceID,HSourceNumber,HPlanQty" +
                ",HSplitPlanQty,HSplitRelationQty,HDatePlanQty,HUnitFinishQty,HDateFinishQty" +
                ",HBadQty,HUnitBadQty,HWasterQty,HSumTimes,HFinishFlag" +
                ",HCurWorkFlag,HCurQualityFlag,HBeginDate,HEndDate,HRemark" +
                ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationInterID" +
                ") " +
                " values(" + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HBillType + "','" + omodel.HDate.ToShortDateString() + "'," + omodel.HICMOInterID.ToString() +
                ",'" + omodel.HICMOBillNo + "','" + omodel.HSplitNO + "'," + omodel.HICMOStatus.ToString() + "," + omodel.HMaterID.ToString() + ",'" + omodel.HMaterNumber + "'" +
                "," + omodel.HUnitID.ToString() + ",'" + omodel.HUnitNumber + "'," + omodel.HSourceID.ToString() + ",'" + omodel.HSourceNumber + "'," + omodel.HPlanQty.ToString() +
                "," + omodel.HSplitPlanQty.ToString() + "," + omodel.HSplitRelationQty.ToString() + "," + omodel.HDatePlanQty.ToString() + "," + omodel.HUnitFinishQty.ToString() + "," + omodel.HDateFinishQty.ToString() +
                "," + omodel.HBadQty.ToString() + "," + omodel.HUnitBadQty.ToString() + "," + omodel.HWasterQty.ToString() + "," + omodel.HSumTimes.ToString() + "," + DBUtility.ClsPub.BoolToString(omodel.HFinishFlag) +
                "," + DBUtility.ClsPub.BoolToString(omodel.HCurWorkFlag) + "," + DBUtility.ClsPub.BoolToString(omodel.HCurQualityFlag) + ",'" + omodel.HBeginDate.ToShortDateString() + "','" + omodel.HEndDate.ToShortDateString() + "','" + omodel.HRemark + "'" +
                "," + omodel.HSourceInterID.ToString() + "," + omodel.HSourceEntryID.ToString() + ",'" + omodel.HSourceBillNo + "','" + omodel.HSourceBillType + "'," + omodel.HRelationInterID.ToString() +
                ") ");
                 
                sReturn = "ÐÂÔöµ¥¾Ý³É¹¦£¡";
                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_ICMOBillStatus_Tmp Where HInterID=" + lngBillKey.ToString(), "Sc_ICMOBillStatus_Tmp");
                if(Ds.Tables[0].Rows.Count==0)
                {
                    sReturn = "µ¥¾ÝδÕÒµ½£¡";
                    return false;
                }
                //¸³Öµ
                omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
                omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
                omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
                omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
                omodel.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]);
                omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HICMOBillNo"]);
                omodel.HSplitNO = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSplitNO"]);
                omodel.HICMOStatus = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOStatus"]);
                omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
                omodel.HMaterNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterNumber"]);
                omodel.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]);
                omodel.HUnitNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUnitNumber"]);
                omodel.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]);
                omodel.HSourceNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceNumber"]);
                omodel.HPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPlanQty"]);
                omodel.HSplitPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HSplitPlanQty"]);
                omodel.HSplitRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HSplitRelationQty"]);
                omodel.HDatePlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HDatePlanQty"]);
                omodel.HUnitFinishQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HUnitFinishQty"]);
                omodel.HDateFinishQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HDateFinishQty"]);
                omodel.HBadQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HBadQty"]);
                omodel.HUnitBadQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HUnitBadQty"]);
                omodel.HWasterQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HWasterQty"]);
                omodel.HSumTimes = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSumTimes"]);
                omodel.HFinishFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HFinishFlag"]);
                omodel.HCurWorkFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCurWorkFlag"]);
                omodel.HCurQualityFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCurQualityFlag"]);
                omodel.HBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HBeginDate"]);
                omodel.HEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HEndDate"]);
                omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
                omodel.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceInterID"]);
                omodel.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceEntryID"]);
                omodel.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillNo"]);
                omodel.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillType"]);
                omodel.HRelationInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HRelationInterID"]);
                //
                
                 
                sReturn = "ÏÔʾµ¥¾Ý³É¹¦£¡";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //ÅжÏÊÇ·ñ¿ª¹¤
        public bool IsStarted(long HInterID,long HEntryID, ref string sReturn)
        {
            try
            {
                DataSet DS;
                DS = oCn.RunProcReturn("select HBeginDate from Sc_ICMOBillStatus_Tmp where HInterID=" + HInterID.ToString() + " ", "Sc_ICMOBillStatus_Tmp");
                if (DS.Tables[0].Rows.Count == 0)
                {
                    sReturn = "µ¥¾ÝδÕÒµ½£¡";
                    return false;
                }
                if (DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HBeginDate"]) > DBUtility.ClsPub.isDate("1900-01-01"))
                {
                    sReturn = "ÒÑ¿ª¹¤£¡";
                    return true;
                }
                else
                {
                    sReturn = "먦¹¤£¡";
                    return false;
                }
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //UPDATEÉú²ú״̬±í ÉèÖÿªÊ¼Ê±¼ä¡¢µ±Ç°Éú²ú±ê¼Ç¡¢ÈÎÎñµ¥×´Ì¬1£©
        public bool Fun_SetStart(long HInterID, long HEntryID,long HSourceID, ref string sReturn)
        {
            try
            {
                //
                oCn.BeginTran();
                //¸üб¾Éú²ú×ÊÔ´È«²¿ ²»Êǵ±Ç°±ê¼Ç
                oCn.RunProc("UpDate Sc_ICMOBillStatus_Tmp set " +
                "HCurWorkFlag=0" +
                " where HSourceID=" + HSourceID.ToString() + " ");
                //¸üР
                oCn.RunProc("UpDate Sc_ICMOBillStatus_Tmp set " +
                "HICMOStatus=1" +
                ",HCurWorkFlag=1" +
                ",HBeginDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" +
                " where HInterID=" + HInterID.ToString() + " ");
                //
                sReturn = "Ð޸ĵ¥¾Ý³É¹¦£¡";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
 
 
        //ÅжÏÊÇ·ñÍ깤
        public bool IsEnded(long HInterID, long HEntryID, ref string sReturn)
        {
            try
            {
                DataSet DS;
                DS = oCn.RunProcReturn("select HEndDate from Sc_ICMOBillStatus_Tmp where HInterID=" + HInterID.ToString() + " ", "Sc_ICMOBillStatus_Tmp");
                if (DS.Tables[0].Rows.Count == 0)
                {
                    sReturn = "µ¥¾ÝδÕÒµ½£¡";
                    return false;
                }
                if (DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HEndDate"]) > DBUtility.ClsPub.isDate("1900-01-01"))
                {
                    sReturn = "ÒÑÍ깤£¡";
                    return true;
                }
                else
                {
                    sReturn = "δÍ깤£¡";
                    return false;
                }
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //UPDATEÉú²ú״̬±í ÉèÖÿªÊ¼Ê±¼ä¡¢µ±Ç°Éú²ú±ê¼Ç¡¢Í깤±ê¼Ç1¡¢ÈÎÎñµ¥×´Ì¬3£©
        public bool Fun_SetEnd(long HInterID, long HEntryID, ref string sReturn)
        {
            try
            {
                //
                oCn.BeginTran();
                //¸üÐÂÖ÷±í
                oCn.RunProc("UpDate Sc_ICMOBillStatus_Tmp set " +
                "HICMOStatus=3" +
                ",HCurWorkFlag=0" +
                ",HFinishFlag=1" +
                ",HEndDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" +
                " where HInterID=" + HInterID.ToString() + " ");
                //
                sReturn = "Ð޸ĵ¥¾Ý³É¹¦£¡";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
       
    } 
    
}