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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public class ClsKf_WIPBal : DBUtility.ClsXt_BaseBill
    {
        public Model.ClsKf_WIPBal omodel = new Model.ClsKf_WIPBal();
 
        public ClsKf_WIPBal()
        {
            base.MvarItemKey = "Kf_WIPBal";
            base.MvarReportTitle = "在产品期初结存";
        }
 
        #region 固定代码
 
        ~ClsKf_WIPBal()
        {
 
        }
 
        #endregion   自定义方法
        //修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //oCn.BeginTran();
                ////更新主表
                //oCn.RunProc("UpDate " + MvarItemKey + " set " +
                //" HYear=" + omodel.HYear.ToString() +
                //",HPeriod=" + omodel.HPeriod.ToString() +
                //",HCostCenterID=" + omodel.HCostCenterID.ToString() +
                //",HWorkShopID=" + omodel.HWorkShopID.ToString() +
                //",HCostObjID=" + omodel.HCostObjID.ToString() +
                //",HMaterID=" + omodel.HMaterID.ToString() +
                //",HBatchNo='" + omodel.HBatchNo + "'" +
                //",HBeginQty=" + omodel.HBeginQty.ToString() +
                //",HReceive=" + omodel.HReceive.ToString() +
                //",HSend=" + omodel.HSend.ToString() +
                //",HYtdReceive=" + omodel.HYtdReceive.ToString() +
                //",HYtdSend=" + omodel.HYtdSend.ToString() +
                //",HEndQty=" + omodel.HEndQty.ToString() +
                //",HEndQty_Rel=" + omodel.HEndQty_Rel.ToString() +
                //",HBeginBal=" + omodel.HBeginBal.ToString() +
                //",HDebit=" + omodel.HDebit.ToString() +
                //",HCredit=" + omodel.HCredit.ToString() +
                //",HEndBal=" + omodel.HEndBal.ToString() +
                //",HEndBal_Rel=" + omodel.HEndBal_Rel.ToString() +
                //",HYtdDebit=" + omodel.HYtdDebit.ToString() +
                //",HYtdCredit=" + omodel.HYtdCredit.ToString() +
                //",HBeginDiff=" + omodel.HBeginDiff.ToString() +
                //",HReceiveDiff=" + omodel.HReceiveDiff.ToString() +
                //",HSendDiff=" + omodel.HSendDiff.ToString() +
                //",HEndDiff=" + omodel.HEndDiff.ToString() +
                //",HYtdReceiveDiff=" + omodel.HYtdReceiveDiff.ToString() +
                //",HYtdSendDiff=" + omodel.HYtdSendDiff.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
            {
                //若MAINDI重复则重新获取
                oCn.BeginTran();
                //主表
                oCn.RunProc("Insert Into " + MvarItemKey + " " +
                "(HMaker,HMakeDate" +
                ",HYear,HPeriod,HCostCenterID,HWorkShopID,HCostObjID" +
                ",HMaterID,HBatchNo,HBeginQty,HReceive,HSend" +
                ",HYtdReceive,HYtdSend,HEndQty,HEndQty_Rel,HBeginBal" +
                ",HDebit,HCredit,HEndBal,HEndBal_Rel,HYtdDebit" +
                ",HYtdCredit,HBeginDiff,HReceiveDiff,HSendDiff,HEndDiff" +
                ",HYtdReceiveDiff,HYtdSendDiff" +
                ") " +
                " values('" + DBUtility.ClsPub.CurUserName + "',getdate()" +
                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + "," + omodel.HCostCenterID.ToString() + "," + omodel.HWorkShopID.ToString() + "," + omodel.HCostObjID.ToString() +
                ", " + omodel.HMaterID.ToString() + ",'" + omodel.HBatchNo + "'," + omodel.HBeginQty.ToString() + "," + omodel.HReceive.ToString() + "," + omodel.HSend.ToString() +
                ", " + omodel.HYtdReceive.ToString() + "," + omodel.HYtdSend.ToString() + "," + omodel.HEndQty.ToString() + "," + omodel.HEndQty_Rel.ToString() + "," + omodel.HBeginBal.ToString() +
                ", " + omodel.HDebit.ToString() + "," + omodel.HCredit.ToString() + "," + omodel.HEndBal.ToString() + "," + omodel.HEndBal_Rel.ToString() + "," + omodel.HYtdDebit.ToString() +
                ", " + omodel.HYtdCredit.ToString() + "," + omodel.HBeginDiff.ToString() + "," + omodel.HReceiveDiff.ToString() + "," + omodel.HSendDiff.ToString() + "," + omodel.HEndDiff.ToString() +
                ", " + omodel.HYtdReceiveDiff.ToString() + "," + omodel.HYtdSendDiff.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 " + MvarItemKey + " Where HInterID=" + lngBillKey.ToString(), MvarItemKey);
                //if (Ds.Tables[0].Rows.Count == 0)
                //{
                //    sReturn = "单据未找到!";
                //    return false;
                //}
                //omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"].ToString());
                //omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"].ToString());
                //omodel.HCostCenterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCostCenterID"].ToString());
                //omodel.HWorkShopID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HWorkShopID"].ToString());
                //omodel.HCostObjID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCostObjID"].ToString());
                //omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"].ToString());
                //omodel.HBatchNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBatchNo"].ToString());
                //omodel.HBeginQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HBeginQty"].ToString());
                //omodel.HReceive = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HReceive"].ToString());
                //omodel.HSend = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HSend"].ToString());
                //omodel.HYtdReceive = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HYtdReceive"].ToString());
                //omodel.HYtdSend = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HYtdSend"].ToString());
                //omodel.HEndQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HEndQty"].ToString());
                //omodel.HEndQty_Rel = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HEndQty_Rel"].ToString());
                //omodel.HBeginBal = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HBeginBal"].ToString());
                //omodel.HDebit = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HDebit"].ToString());
                //omodel.HCredit = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HCredit"].ToString());
                //omodel.HEndBal = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HEndBal"].ToString());
                //omodel.HEndBal_Rel = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HEndBal_Rel"].ToString());
                //omodel.HYtdDebit = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HYtdDebit"].ToString());
                //omodel.HYtdCredit = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HYtdCredit"].ToString());
                //omodel.HBeginDiff = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HBeginDiff"].ToString());
                //omodel.HReceiveDiff = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HReceiveDiff"].ToString());
                //omodel.HSendDiff = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HSendDiff"].ToString());
                //omodel.HEndDiff = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HEndDiff"].ToString());
                //omodel.HYtdReceiveDiff = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HYtdReceiveDiff"].ToString());
                //omodel.HYtdSendDiff = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HYtdSendDiff"].ToString());
                ////
                //omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
                //omodel.HMakeDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HMakeDate"].ToString());
                //omodel.HCheckMan = Ds.Tables[0].Rows[0]["HCheckMan"].ToString().Trim();
                //omodel.HCheckDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HCheckDate"].ToString());
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
 
        //重复会计年+会计月+物料
        public bool HavBillCode(Int64 sHYear, Int64 sHPeriod, Int64 sHMater)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " where HYear='" + sHYear + "'and HPeriod='" + sHPeriod + "'and HMaterID='" + sHMater + "'", MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return true;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
    }
}