沈泽
2021-11-01 cb7d88df22d0e2a1aa6987c33c93c3378f1c2837
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public  class ClsGy_WorkCenterSourceBill:DBUtility.ClsXt_BaseBill
    {
        public Model.ClsSc_ProcProdMoveBillMain omodel = new Model.ClsSc_ProcProdMoveBillMain();
        public List<Model.ClsGy_WorkCenterSourceBillSub> DetailColl = new List<Model.ClsGy_WorkCenterSourceBillSub>();
 
        public ClsGy_WorkCenterSourceBill()
        {
            base.MvarItemKeySub = "Gy_WorkCenterSub";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey="Sc_ProcProdMoveBillMain";
            base.MvarReportTitle="工作中心下属资源";
            base.BillType="0"; 
        }
 
        #region 固定代码
 
        ~ClsGy_WorkCenterSourceBill()
        {
            DetailColl = null;
        }
       
        #endregion   自定义方法
        //修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //
                oCn.BeginTran();
                //
                //DeleteRelation(ref sReturn, lngBillKey);
                //删除子表
                //DeleteBillSub(lngBillKey);
                oCn.RunProc("delete from  Gy_WorkCenterSub where Hitemid=" + lngBillKey.ToString());
                //插入子表
                //omodel.HInterID = lngBillKey;
                foreach (Model.ClsGy_WorkCenterSourceBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Gy_WorkCenterSub " +
                  " (HCenterID,HSourceID,HSno,HUnionFlag" +
                  ") values("
                  + oSub.HCenterID.ToString() + "," + oSub.HSourceID.ToString() + "," + oSub.HSNo.ToString() + "," + Convert.ToString(oSub.HUnionFlag ? 1 : 0) +
                  ") ");
                }
                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();
                //插入子表
                foreach (Model.ClsGy_WorkCenterSourceBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Gy_WorkCenterSub " +
                  " (HCenterID,HSourceID,HSno,HUnionFlag" +
                  ") values("
                  + oSub.HCenterID.ToString() + "," + oSub.HSourceID.ToString() + ","  + oSub.HSNo.ToString() +"," + Convert.ToString(oSub.HUnionFlag ? 1 : 0) +
                  ") ");
                }
 
                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 DsSub ;
                omodel.HInterID = lngBillKey;
                DsSub = oCn.RunProcReturn("Select * from Gy_WorkCenterSub Where HItemID=" + lngBillKey.ToString(), "Gy_WorkCenterSub");
                DetailColl.Clear();//清空
                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
                {
                    Model.ClsGy_WorkCenterSourceBillSub oSub = new Model.ClsGy_WorkCenterSourceBillSub();
 
                    
                    oSub.HCenterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCenterID"]);
                    oSub.HSourceID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceID"]);
                    oSub.HSNo = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSNo"]);
                    oSub.HUnionFlag = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HUnionFlag"]);
                    //
                    DetailColl.Add(oSub);
                }
                sReturn = "显示成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
        //delete
        public override bool DeleteBill(long lngBillKey, ref string sReturn)
        {
            try
            {
                //
                oCn.BeginTran();
                //
                //DeleteRelation(ref sReturn, lngBillKey);
                //删除子表
                //DeleteBillSub(lngBillKey);
                oCn.RunProc("delete from  Gy_WorkCenterSub where Hitemid=" + lngBillKey.ToString());
                sReturn = "删除成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }    
        }
        //delete
 
        /// <summary>
        /// 根据转出工序,得到接收工序
        /// </summary>
        /// <returns></returns>
        public bool GetNextProcessPlan(long HMainID,long HSubID, ref string sReturn)
        {
            //DataSet DsSub;
            //DsSub = oCn.RunProcReturn("Select top 1 * from h_v_Sc_ProcessPlanList where hmainid=" + HMainID.ToString() + " and hsubid>" + HSubID.ToString() + " order by hsubid ", "h_v_Sc_ProcessPlanList");
            //if (DsSub.Tables[0].Rows.Count == 0)
            //{
            //    sReturn = "单据未找到!";
            //    return false;
            //}
            //omodel.HInProcID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[0]["hprocid"]);
            //DetailColl.Clear();//清空
            //for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
            //{
            //    Model.ClsGy_WorkCenterSourceBillSub oSub = new Model.ClsGy_WorkCenterSourceBillSub();
            //    //
            //    oSub.HInProcPlanBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["工序计划单号"]);
            //    oSub.HInProcPlanInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["hmainid"]);
            //    oSub.HInProcPlanEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["hsubid"]);
            //    oSub.HInCenterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCenterID"]);
            //    oSub.HInSourceID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceID"]);
            //    oSub.HSNo = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSNo"]);
            //    oSub.HUnionFlag = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HUnionFlag"]);
            //    //
            //    DetailColl.Add(oSub);
            //}
            return true;
        }
 
 
    }
 
}