yangle
2022-12-09 526f787a2dfb97f6492912a73376b5a5551a432c
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
 
namespace DAL
{
    public class ClsK3_SeOrderBill_CheckExtend_Ctl : DBUtility.ClsXt_BaseBill
    {
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public ClsK3_SeOrderBill_CheckExtend_Model omodel = new ClsK3_SeOrderBill_CheckExtend_Model();
 
        public ClsK3_SeOrderBill_CheckExtend_Ctl()
        {
            base.MvarItemKeySub = "";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "K3_SeOrderBill_CheckExtend";
            base.MvarReportTitle = "销售订单评审";
            base.BillType = "";
            base.HBillSubType = "";
 
        }
 
        //修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            return true;
            //try
            //{
            //    //
            //    oCn.BeginTran();
            //    //更新主表
            //    oCn.RunProc("UpDate Kf_ICStockBillMain set  " +
            //    " HBillNo='" + omodel.HBillNo + "'" +  //固定赋值===============
            //    ",HDate='" + omodel.HDate + "'" +
            //    ",HYear='" + omodel.HYear.ToString() + "'" +
            //    ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
            //    ",HRemark='" + omodel.HRemark + "'" +
            //    ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
            //    ",HUpDateDate=getdate()" +
            //        //========================================
            //    ",HSupID=" + omodel.HSupID.ToString() +
            //    ",HWHID=" + omodel.HWHID.ToString() +
            //    ",HSCWHID=" + omodel.HSCWHID.ToString() +
            //    ",HManagerID=" + omodel.HMangerID.ToString() +
            //    ",HSecManagerID=" + omodel.HSecManagerID.ToString() +
            //    ",HKeeperID=" + omodel.HKeeperID.ToString() +
            //    ",HDeptID=" + omodel.HDeptID.ToString() +
            //    ",HExplanation='" + omodel.HExplanation + "'" +
            //    ",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
            //    ",HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
            //    " where HInterID=" + lngBillKey.ToString());
            //    //删除关联
            //    DeleteRelation(ref sReturn, lngBillKey);
            //    //删除子表
            //    DeleteBillSub(lngBillKey);
            //    //插入子表
            //    omodel.HInterID = lngBillKey;
            //    foreach (Model.ClsKf_EntrustInBillSub oSub in DetailColl)
            //    {
            //        oCn.RunProc("Insert into Kf_ICStockBillSub " +
            //          " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
            //          ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
            //          ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
            //          ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
            //          ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
            //          ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
            //          ") values("
            //          + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
            //          "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
            //          "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
            //          "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
            //          "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" +
            //          "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
            //          ") ");
            //    }
            //    //
            //    //foreach (Model.ClsKf_EntrustInBillSub oSub in DetailColl)
            //    //{
            //    //    Ds = oCn.RunProcReturn("exec h_p_Kf_EntrustInBill_Qty " + oSub.HICMOInterID, "");
            //    //    if (Ds.Tables[0].Rows.Count == 0)
            //    //        return;
            //    //    if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y")
            //    //    {
            //    //        sReturn = "汇报数量超过计划数量!不允许保存";
            //    //        return false;
            //    //    }
            //    //}
            //    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.HItemID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                //若MAINDI重复则重新获取
                DataSet Ds;
                oCn.BeginTran();
                //主表
                oCn.RunProc("Insert Into K3_SeOrderBill_CheckExtend   " +
                "(HBillNo,HInterID,HCusID,HCusNumber" +
                ",HDataChecker,HDataCheckDate,HDataCheckNote,HStatus" +
                ") " +
                " values('" + omodel.HBillNo + "'," + omodel.HInterID.ToString() + "," + omodel.HCusID.ToString() + ",'" + omodel.HCusNumber + "'" +
                ",'" + omodel.HDataChecker + "','" + omodel.HDataCheckDate + "','" + omodel.HDataCheckNote + "'," + omodel.HStatus.ToString() +
                ") ");
                //
                Ds = oCn.RunProcReturn("exec h_p_GetNextChecker_Order " + omodel.HInterID.ToString(), "Gy_Czygl");
                if (Ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "创建审核流失败!";
                    oCn.RollBack();
                    return false;
                }
                if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) != 99)
                {
                    sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0][1]);
                    oCn.RollBack();
                    return false;
                }
                sReturn = "新增单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        //显示单据
        public bool ShowBill(long lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds;
                Ds = oCn.RunProcReturn("Select * from K3_SeOrderBill_CheckExtend Where HInterID=" + lngBillKey.ToString(), "K3_SeOrderBill_CheckExtend");
                if (Ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //固定赋值===========================================
                omodel.HItemID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]);
                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
                omodel.HBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]);
                omodel.HCusID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCusID"]);
                omodel.HCusNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCusNumber"]);
                omodel.HBacker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBacker"]);
                omodel.HBackDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HBackDate"]);
 
                omodel.HDataChecker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDataChecker"]);
                omodel.HDataCheckDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDataCheckDate"]).ToShortDateString();
                omodel.HDataCheckNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDataCheckNote"]);
                omodel.HOverRateChecker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HOverRateChecker"]);
                omodel.HOverRateCheckDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HOverRateCheckDate"]).ToShortDateString();
                omodel.HOverRateCheckNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HOverRateCheckNote"]);
                omodel.HProdAbilityChecker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProdAbilityChecker"]);
                omodel.HProdAbilityCheckDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HProdAbilityCheckDate"]).ToShortDateString();
                omodel.HProdAbilityCheckNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProdAbilityCheckNote"]);
                omodel.HCostChecker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCostChecker"]);
                omodel.HCostCheckDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HCostCheckDate"]).ToShortDateString();
                omodel.HCostCheckNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCostCheckNote"]);
                omodel.HAccAgeChecker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAccAgeChecker"]);
                omodel.HAccAgeCheckDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HAccAgeCheckDate"]).ToShortDateString();
                omodel.HAccAgeCheckNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAccAgeCheckNote"]);
                omodel.HStatus = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HStatus"]);
                //========================================================
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        public override bool DeleteBill(long lngBillKey, ref string sReturn)
        {
            try
            {
                oCn.BeginTran();
                //删除主表
                oCn.RunProc("Delete From K3_SeOrderBill_CheckExtend  where HItemID=" + lngBillKey.ToString());
                sReturn = "删除单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
 
        //审核
        public bool CheckBill(long lngBillKey, long sStatus, string sNote, ref string sReturn)
        {
 
            try
            {
                string HChecker = DBUtility.ClsPub.CurUserName;
                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
                if (sStatus == 1)
                {
                    oCn.RunProc(" Update K3_SeOrderBill_CheckExtend set HDataChecker='" + HChecker + "',HDataCheckDate='" + HCheckDate + "',HDataCheckNote='" + sNote + "'  Where HInterID=" + lngBillKey.ToString());
                }
                else if (sStatus == 2)
                {
                    oCn.RunProc(" Update K3_SeOrderBill_CheckExtend set HOverRateChecker='" + HChecker + "',HOverRateCheckDate='" + HCheckDate + "',HOverRateCheckNote='" + sNote + "'  Where HInterID=" + lngBillKey.ToString());
                }
                else if (sStatus == 3)
                {
                    oCn.RunProc(" Update K3_SeOrderBill_CheckExtend set HProdAbilityChecker='" + HChecker + "',HProdAbilityCheckDate='" + HCheckDate + "',HProdAbilityCheckNote='" + sNote + "'  Where HInterID=" + lngBillKey.ToString());
                }
                else if (sStatus == 4)
                {
                    oCn.RunProc(" Update K3_SeOrderBill_CheckExtend set HCostChecker='" + HChecker + "',HCostCheckDate='" + HCheckDate + "',HCostCheckNote='" + sNote + "'  Where HInterID=" + lngBillKey.ToString());
                }
                else if (sStatus == 5)
                {
                    oCn.RunProc(" Update K3_SeOrderBill_CheckExtend set HAccAgeChecker='" + HChecker + "',HAccAgeCheckDate='" + HCheckDate + "',HAccAgeCheckNote='" + sNote + "'  Where HInterID=" + lngBillKey.ToString());
                }
                sReturn = "审核成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //关闭
        public bool CloseBill(long lngBillKey, ref string sReturn)
        {
 
            try
            {
                string HCloseMan = DBUtility.ClsPub.CurUserName;
                string HCloseDate = DBUtility.ClsPub.GetServerDate(-1);
                oCn.RunProc(" Update K3_SeOrderBill_CheckExtend set HBacker='" + HCloseMan + "',HBackDate='" + HCloseDate + "' Where HInterID=" + lngBillKey.ToString());
                sReturn = "";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
 
 
 
 
    }
}