yxj
昨天 ebb5a4cabce43b6eff66a1f46f9adecb337ed820
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
 
namespace DAL
{
    public class ClsA3_SellOutBill_CheckExtend_Ctl : DBUtility.ClsXt_BaseBill
    {
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public ClsA3_SellOutBill_CheckExtend_Model omodel = new ClsA3_SellOutBill_CheckExtend_Model();
 
        public ClsA3_SellOutBill_CheckExtend_Ctl()
        {
            base.MvarItemKeySub = "";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "A3_SellOutBill_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 A3_SellOutBill_CheckExtend   " +
                "(HBillNo,HCusNumber,HReceiveStatus" +
                ",HReceiveType,HReceiveMoney" +
                ",HRequester,HRequesterDate,HRequesterNote,HStatus" +
                ") " +
                " values('" + omodel.HBillNo + "','" + omodel.HCusNumber + "','" + omodel.HReceiveStatus + "'" +
                ",'" + omodel.HReceiveType + "'," + omodel.HReceiveMoney.ToString() +
                ",'" + omodel.HRequester + "','" + omodel.HRequesterDate + "','" + omodel.HRequesterNote + "'," + omodel.HStatus.ToString() +
                ") ");
                //
                Ds = oCn.RunProcReturn("exec h_p_GetNextChecker_SellOut '" + omodel.HBillNo + "'", "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(string lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds;
                Ds = oCn.RunProcReturn("Select * from A3_SellOutBill_CheckExtend Where HBillNo='" + lngBillKey + "' and isnull(HBacker,'')=''", "A3_SellOutBill_CheckExtend");
                if (Ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //固定赋值===========================================
                omodel.HItemID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]);
                omodel.HBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]);
                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.HReceiveMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HReceiveMoney"]);
                omodel.HReceiveType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HReceiveType"]);
                omodel.HReceiveStatus = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HReceiveStatus"]);
                omodel.HRequester = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRequester"]);
                omodel.HRequesterDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HRequesterDate"]).ToShortDateString();
                omodel.HRequesterNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRequesterNote"]);
                omodel.HAccManager = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAccManager"]);
                omodel.HAccManagerDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HAccManagerDate"]).ToShortDateString();
                omodel.HAccManagerNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAccManagerNote"]);
                omodel.HLstManager = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HLstManager"]);
                omodel.HLstManagerDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HLstManagerDate"]).ToShortDateString();
                omodel.HLstManagerNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HLstManagerNote"]);
                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 A3_SellOutBill_CheckExtend  where HItemID=" + lngBillKey.ToString());
                sReturn = "删除单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
 
        //审核
        public bool CheckBill(string lngBillKey, DateTime sDate, string sHCheckItem, string sNote, ref string sReturn)
        {
 
            try
            {
                DataSet DsA;
                DataSet Ds;
                string HChecker = DBUtility.ClsPub.CurUserName;
                Ds = oCn.RunProcReturn("exec h_p_A3_SellOutBillExtend_Check '" + lngBillKey + "','" + sDate.ToShortDateString() + "','" + sHCheckItem + "','" + sNote + "','" + HChecker + "'", "Gy_Czygl");
                if (Ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "审核失败!";
                    return false;
                }
                sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0][0]);
                //
                DsA = oCn.RunProcReturn("exec h_p_GetNextChecker_SellOut '" + lngBillKey + "'", "Gy_Czygl");
                if (DsA.Tables[0].Rows.Count == 0 || DsA == null)
                {
                    sReturn = "创建审核流失败!";
                    return false;
                }
                if (DBUtility.ClsPub.isLong(DsA.Tables[0].Rows[0][0]) != 99)
                {
                    sReturn = DBUtility.ClsPub.isStrNull(DsA.Tables[0].Rows[0][1]);
                    return false;
                }
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //关闭
        public bool CloseBill(string lngBillKey, ref string sReturn)
        {
 
            try
            {
                string HCloseMan = DBUtility.ClsPub.CurUserName;
                string HCloseDate = DBUtility.ClsPub.GetServerDate(-1);
                oCn.RunProc(" Update A3_SellOutBill_CheckExtend set HBacker='" + HCloseMan + "',HBackDate='" + HCloseDate + "' Where HBillNo='" + lngBillKey + "'");
                //oCn.RunProc(" Delete from A3_SellOutBill_CheckExtend  Where HBillNo='" + lngBillKey + "'");
                DBUtility.ClsPub.Add_Log("", "退回发货单:" + lngBillKey, DBUtility.ClsPub.CurUserName);
                sReturn = "";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
 
 
 
 
    }
}