ch
2022-05-30 f9ef44a67fbf73f073efe65600bc25e204fde04f
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public  class ClsCB_ItemMoneyBill_Tmp:DBUtility.ClsXt_BaseBill
    {
        public Model.CB_ItemMoneyBill_TmpMain omodel = new Model.CB_ItemMoneyBill_TmpMain();
 
        public ClsCB_ItemMoneyBill_Tmp()
        {
            base.MvarItemKeySub = "CB_ItemMoneyBill_Tmp";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "CB_ItemMoneyBill_Tmp";
            base.MvarReportTitle = "费用单明细记录";
            base.BillType = "18020"; 
        }
 
        #region 固定代码
 
        ~ClsCB_ItemMoneyBill_Tmp()
        {
 
        }
       
        #endregion   自定义方法
        //修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //
                oCn.BeginTran();
                //更新主表
                oCn.RunProc("UpDate CB_ItemMoneyBill_Tmp set  " +
                "HRoomID=" + omodel.HRoomID.ToString() +
                ",HItMoneyID=" + omodel.HItMoneyID.ToString() +
                ",HDate='" + omodel.HDate.ToShortDateString() + "'" +
                ",HBeginDate='" + omodel.HBeginDate.ToShortDateString() + "'" +
                ",HEndDate='" + omodel.HEndDate.ToShortDateString() + "'" +
                ",HQty=" + omodel.HQty.ToString() +
                ",HPrice=" + omodel.HPrice.ToString() +
                ",HMoney=" + omodel.HMoney.ToString() +
                ",HWaster=" + omodel.HWaster.ToString() +
                ",HBeginBalance=" + omodel.HBeginBalance.ToString() +
                ",HEndBalance=" + omodel.HEndBalance.ToString() +
                ",HTimes=" + omodel.HTimes.ToString() +
                ",HRelationQty=" + omodel.HRelationQty.ToString() +
                ",HRelationMoney=" + omodel.HRelationMoney.ToString() +
                ",HUpDater='" + omodel.HUpDater + "'" +
                ",HUpDateDate='" + omodel.HUpDateDate + "'" +
                ",HExplanation='" + omodel.HExplanation + "'" +
                ",HRemark='" + omodel.HRemark + "'" +
                " where HItemID=" + lngBillKey.ToString());
                //删除关联
                DeleteRelation(ref sReturn, lngBillKey);
                //
                sReturn = "修改单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
 
        public bool DeleteBill(Int64 lngBillKey, Int64 HYear, Int64 HPeriod, string HBillSubType, ref string sReturn)
        {
            try
            {
                oCn.BeginTran();
                //删除重复记录
                oCn.RunProc("Delete From CB_ItemMoneyBill_Tmp where HYear=" + HYear.ToString() + " and HPeriod=" + HPeriod.ToString() + " and HBillSubType='" + HBillSubType + "'");
                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);
                omodel.HInterID = 0;
                //若MAINDI重复则重新获取
                oCn.BeginTran();
                //主表
                oCn.RunProc("Insert Into CB_ItemMoneyBill_Tmp " +
                "(HBillType,HInterID,HDate,HBeginDate,HEndDate" +
                ",HYear,HPeriod,HBillSubType" +
                ",HMaker,HMakedate,HRoomID,HItMoneyID" +
                ",HQty,HPrice,HMoney,HWaster"+
                ",HBeginBalance,HEndBalance,HTimes" +
                ",HRelationQty,HRelationMoney" +
                ",HRemark,HExplanation" +
                ") " +
                " values('" + this.BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HDate.ToShortDateString() + "','" + omodel.HBeginDate.ToShortDateString() + "','" + omodel.HEndDate.ToShortDateString() + "'" +
                "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HBillSubType + "'" +
                ",'" + DBUtility.ClsPub.CurUserName + "',getdate()," + omodel.HRoomID.ToString() + "," + omodel.HItMoneyID.ToString() +
                "," + omodel.HQty.ToString() + "," + omodel.HPrice.ToString() + "," + omodel.HMoney.ToString() + "," + omodel.HWaster.ToString() +
                "," + omodel.HBeginBalance.ToString() + "," + omodel.HEndBalance.ToString() + "," + omodel.HTimes.ToString() +
                "," + omodel.HRelationQty.ToString() + "," + omodel.HRelationMoney.ToString() +
                ",'" + omodel.HRemark + "','" + omodel.HExplanation + "'" +
                ") ");
                //
                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 CB_ItemMoneyBill_Tmp Where HItemID=" + lngBillKey.ToString(), "CB_ItemMoneyBill_Tmp");
                if(Ds.Tables[0].Rows.Count==0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //赋值
                omodel.HItemID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]);
                omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
                omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
                omodel.HDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["HDate"]);
                omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
                omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]);
 
                omodel.HBeginDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["HBeginDate"]);
                omodel.HEndDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["HEndDate"]);
                omodel.HItMoneyID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
                omodel.HRoomID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HRoomID"]);
 
                omodel.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"]);
                omodel.HPrice = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPrice"]);
                omodel.HMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HMoney"]);
                omodel.HWaster = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HWaster"]);
                omodel.HBeginBalance = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HBeginBalance"]);
                omodel.HEndBalance = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HEndBalance"]);
                omodel.HTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HTimes"]);
                omodel.HRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HRelationQty"]);
                omodel.HRelationMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HRelationMoney"]);
                //
                omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
                omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
                omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
                omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
                omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
                omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
                omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
                omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
                omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
                omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
                omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
                omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim(); 
                //
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
       
        
    }
 
}