duhe
2024-12-28 3eb99e4cb8be5175840c2e28f5f9d8ffd96e1ea4
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public  class ClsXt_DefineBillMainSet : DBUtility.ClsXt_BaseBill
    {
        public Model.ClsXt_DefineBillMainSetMain omodel = new Model.ClsXt_DefineBillMainSetMain();
        public List<Model.ClsXt_DefineBillMainSetSub> DetailColl = new List<Model.ClsXt_DefineBillMainSetSub>();
 
        public ClsXt_DefineBillMainSet()
        {
            base.MvarItemKeyForWeb = "";
            base.MvarItemKeySubForWeb = "Xt_DefineBillMainSet";
            base.MvarItemKeySub = "Xt_DefineBillMainSetSub";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey= "Xt_DefineBillMainSetMain";
            base.MvarReportTitle="表头自定义单据";
            base.BillType="";
            base.HBillSubType = "";
 
        }
 
        #region 固定代码
 
        ~ClsXt_DefineBillMainSet()
        {
            DetailColl = null;
        }
 
        #endregion   自定义方法
 
        #region 修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                oCn.BeginTran();
                omodel.HInterID = lngBillKey;
                //更新主表
                string mainSql = "update Xt_DefineBillMainSetMain set  " +
                "HInterID = '" + omodel.HInterID + "'" +
                ",HModName = '" + omodel.HModName + "'" +
                ",HUser = '" + omodel.HUser + "'" +
                ",HTableName = '" + omodel.HTableName + "'" +
                ",HDataViewName = '" + omodel.HDataViewName + "'" +
                ",HDataProcName = '" + omodel.HDataProcName + "'" +
                ",HUpdater = '" + omodel.HUpDater + "'" +
                ",HUpdateDate = " + "getdate()" + "" +
                ",HRowElementCount = '" + omodel.HRowElementCount + "'" +
                " where HInterID=" + lngBillKey.ToString();
                oCn.RunProc(mainSql);
 
                //删除子表
                DeleteBillSub(lngBillKey);
 
                //插入子表
                int HEntryID = 1;
                foreach (Model.ClsXt_DefineBillMainSetSub oSub in DetailColl)
                {
                    string subSql = "Insert into Xt_DefineBillMainSetSub " +
                      " (HInterID,HEntryID,HArrangeOrder,HArrangeOrderSub,HIsHide,HIsDisabled,HIsMust,HParentElementID,HElementID" +
                      ",HElementLabel,HElementType,HFieldMaxLength,HDefaultValue,HFieldName,HFieldDataType,HRelateUrl,HSubWindowBackData" +
                      ",HSubWindowBackDataMethodName,HSelectContent" +
                      ") values(" +
                        "'" + omodel.HInterID + "'" +
                        ",'" + (HEntryID++) + "'" +
                        ",'" + oSub.HArrangeOrder + "'" +
                        ",'" + oSub.HArrangeOrderSub + "'" +
                        ",'" + (oSub.HIsHide ? 1 : 0) + "'" +
                        ",'" + (oSub.HIsDisabled ? 1 : 0) + "'" +
                        ",'" + (oSub.HIsMust ? 1 : 0) + "'" +
                        ",'" + oSub.HParentElementID + "'" +
                        ",'" + oSub.HElementID + "'" +
                        ",'" + oSub.HElementLabel + "'" +
                        ",'" + oSub.HElementType + "'" +
                        ",'" + oSub.HFieldMaxLength + "'" +
                        ",'" + oSub.HDefaultValue + "'" +
                        ",'" + oSub.HFieldName + "'" +
                        ",'" + oSub.HFieldDataType + "'" +
                        ",'" + oSub.HRelateUrl + "'" +
                        ",'" + oSub.HSubWindowBackData + "'" +
                        ",'" + oSub.HSubWindowBackDataMethodName + "'" +
                        ",'" + oSub.HSelectContent + "'" +
                        ") ";
                    oCn.RunProc(subSql);
                }
 
                sReturn = "修改单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        #endregion
 
        #region 新增单据
        public override bool AddBill(ref string sReturn)
        {
            try
            {
                
 
                string sql_0 = "select top(1)* from Xt_DefineBillMainSetMain order by HInterID desc";
                DataSet dataSet = oCn.RunProcReturn(sql_0, "Xt_DefineBillMainSetMain");
                if(dataSet!=null && dataSet.Tables[0].Rows.Count > 0)
                {
                    omodel.HInterID = DBUtility.ClsPub.isLong(dataSet.Tables[0].Rows[0]["HInterID"]) + 1;
                }
                else
                {
                    omodel.HInterID = 1;
                }
 
                oCn.BeginTran();
                //主表
                string mainSql = "Insert Into Xt_DefineBillMainSetMain" +
                "(HInterID,HModName,HUser,HTableName,HDataViewName,HDataProcName,HMaker,HMakeDate,HRowElementCount) " +
                " values(" +
                "'" + omodel.HInterID + "'" +
                ",'" + omodel.HModName + "'" +
                ",'" + omodel.HUser + "'" +
                ",'" + omodel.HTableName + "'" +
                ",'" + omodel.HDataViewName + "'" +
                ",'" + omodel.HDataProcName + "'" +
                ",'" + omodel.HMaker + "'" +
                "," + "getdate()" + "" +
                ",'" + omodel.HRowElementCount + "'" +
                ")";
                oCn.RunProc(mainSql);
 
                //插入子表
                int HEntryID = 1;
                foreach (Model.ClsXt_DefineBillMainSetSub oSub in DetailColl)
                {
                    string subSql = "Insert into Xt_DefineBillMainSetSub " +
                      " (HInterID,HEntryID,HArrangeOrder,HArrangeOrderSub,HIsHide,HIsDisabled,HIsMust,HParentElementID,HElementID" +
                      ",HElementLabel,HElementType,HFieldMaxLength,HDefaultValue,HFieldName,HFieldDataType,HRelateUrl,HSubWindowBackData" +
                      ",HSubWindowBackDataMethodName,HSelectContent" +
                      ") values(" +
                        "'" + omodel.HInterID + "'" +
                        ",'" + (HEntryID++) + "'" +
                        ",'" + oSub.HArrangeOrder + "'" +
                        ",'" + oSub.HArrangeOrderSub + "'" +
                        ",'" + (oSub.HIsHide?1:0) + "'" +
                        ",'" + (oSub.HIsDisabled?1:0) + "'" +
                        ",'" + (oSub.HIsMust?1:0) + "'" +
                        ",'" + oSub.HParentElementID + "'" +
                        ",'" + oSub.HElementID + "'" +
                        ",'" + oSub.HElementLabel + "'" +
                        ",'" + oSub.HElementType + "'" +
                        ",'" + oSub.HFieldMaxLength + "'" +
                        ",'" + oSub.HDefaultValue + "'" +
                        ",'" + oSub.HFieldName + "'" +
                        ",'" + oSub.HFieldDataType + "'" +
                        ",'" + oSub.HRelateUrl + "'" +
                        ",'" + oSub.HSubWindowBackData + "'" +
                        ",'" + oSub.HSubWindowBackDataMethodName + "'" +
                        ",'" + oSub.HSelectContent + "'" +
                        ") ";
                    oCn.RunProc(subSql);
                }
                
                sReturn = "新增单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        #endregion
 
        #region 显示单据
        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds ;
                Ds = oCn.RunProcReturn("Select * from Xt_DefineBillMainSetMain Where HInterID=" + lngBillKey.ToString(), "Xt_DefineBillMainSetMain");
                if(Ds.Tables[0].Rows.Count==0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //固定赋值===========================================
                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
                omodel.HModName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HModName"]);
                omodel.HUser = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUser"]);
                omodel.HTableName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HTableName"]);
                omodel.HDataViewName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDataViewName"]);
                omodel.HDataProcName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDataProcName"]);
                omodel.HMaker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaker"]);
                omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
                omodel.HUpDater = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUpDater"]);
                omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
                omodel.HRowElementCount = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HRowElementCount"]);
                
                //循环
                DataSet DsSub ;
                DsSub = oCn.RunProcReturn("Select * from Xt_DefineBillMainSetSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Xt_DefineBillMainSetSub");
                DetailColl.Clear();//清空
                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
                {
                    Model.ClsXt_DefineBillMainSetSub oSub = new Model.ClsXt_DefineBillMainSetSub();
                    // 固定赋值===============================================
                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
                    oSub.HArrangeOrder = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HArrangeOrder"]);
                    oSub.HArrangeOrderSub = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HArrangeOrderSub"]);
                    oSub.HIsHide = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HIsHide"])==1?true:false;
                    oSub.HIsDisabled = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HIsDisabled"]) == 1 ? true : false;
                    oSub.HIsMust = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HIsMust"]) == 1 ? true : false;
                    oSub.HParentElementID = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HParentElementID"]);
                    oSub.HElementID = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HElementID"]);
                    oSub.HElementLabel = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HElementLabel"]);
                    oSub.HElementType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HElementType"]);
                    oSub.HFieldMaxLength = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HFieldMaxLength"]);
                    oSub.HDefaultValue = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HDefaultValue"]);
                    oSub.HFieldName = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HFieldName"]);
                    oSub.HFieldDataType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HFieldDataType"]);
                    oSub.HRelateUrl = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HRelateUrl"]);
                    oSub.HSubWindowBackData = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSubWindowBackData"]);
                    oSub.HSubWindowBackDataMethodName = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSubWindowBackDataMethodName"]);
                    oSub.HSelectContent = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSelectContent"]);
                    DetailColl.Add(oSub);
                }
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
        #endregion
 
    }
 
}