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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Drawing;
using System.Data.SqlClient;
using System.IO;
 
namespace DAL
{
    public class ClsK3_Employee_View:DBUtility.ClsGy_Base_View
    {
        
        //
        public Model.ClsK3_Employee_Model omodel = new Model.ClsK3_Employee_Model();
        public List<Model.ClsK3_Employee_Model> oEmpList;
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); 
 
        public ClsK3_Employee_View()
        {
            base.MvarReportTitle = "职员设置";
            base.MvarItemKey = "h_v_K3_Employee";
            base.SQLName = "Select HItemID,HNumber 职员代码,HName 职员,HEmpNo 工号 from h_v_K3_Employee where HStopflag=0   ";
            base.SQLOrder = " order by HNumber";
            base.SQLList = "Select * from " + MvarItemKey + " ";
            //下拉SQL
            base.SQLNameForDown = " Select top 30 HItemID,HNumber 职员代码,HName 职员 from h_v_K3_Employee ";
            base.SQLOrderForDown = "  Order by HNumber ";
            base.SQLWhereForDown = "  where HStopflag=0  ";
        }
        //
        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }
        //
         
        //返回项目信息
        public override bool GetInfoByID(Int64 sItemID)
        {
            DataSet DS ;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HItemID='" + sItemID + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count  == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //根据代码返回项目信息
        public override bool GetInfoByNumber(string sNumber)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HNumber='" + sNumber + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //根据考勤号返回项目信息
        public bool GetInfoByEmpNo(string sNumber)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HEmpNo='" + sNumber + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //返回职员根据班组oEmpList
        public bool GetInfoByGroup(long sGroupID)
        {
            oEmpList = new List<Model.ClsK3_Employee_Model>();
            oEmpList.Clear();
            try
            {
                DataSet DS;
                DS = oCn.RunProcReturn("Select * from  " + MvarItemKey + " Where HStopFlag=0 and HGroupID='" + sGroupID + "' order by HNumber", "Gy_Employee");
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    for (int i = 0; i < DS.Tables[0].Rows.Count; i++)
                    {
                        omodel = new Model.ClsK3_Employee_Model();
                        omodel.HItemID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[i]["HItemID"]);
                        omodel.HNumber = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[i]["HNumber"]);
                        omodel.HName = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[i]["HName"]);
                        omodel.HEmpRate = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[i]["HEmpRate"]);
                        omodel.HPostID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[i]["HPostID"]);
                        omodel.HEmpType = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[i]["HEmpType"].ToString());
                        oEmpList.Add(omodel);
                    }
                    DS.Dispose();
                    DS = null;
                    return true;
                }
            }
            catch (Exception e)
            {
                return false;
            }
        }
 
 
 
        //返回职员根据部门oEmpList
        public bool GetInfoByDept(long sDeptID, Int64 sYear, Int64 sPeriod)
        {
            oEmpList = new List<Model.ClsK3_Employee_Model>();
            oEmpList.Clear();
            try
            {
                DataSet DS;
                DS = oCn.RunProcReturn("exec  h_p_Pay_GetEmpInfoByDept  " + sDeptID.ToString() + "," + sYear.ToString() + "," + sPeriod.ToString(), "h_v_K3_Employee");
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    for (int i = 0; i < DS.Tables[0].Rows.Count; i++)
                    {
                        omodel = new Model.ClsK3_Employee_Model();
                        omodel.HItemID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[i]["HItemID"]);
                        omodel.HNumber = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[i]["HNumber"]);
                        omodel.HName = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[i]["HName"]);
                        omodel.HEmpNo = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[i]["HEmpNo"]);
                        omodel.HEmpRate = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[i]["HEmpRate"]);
                        //omodel.HPostID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[i]["HPostID"]);
                        //omodel.HEmpType = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[i]["HEmpType"].ToString());
                        oEmpList.Add(omodel);
                    }
                    DS.Dispose();
                    DS = null;
                    return true;
                }
            }
            catch (Exception e)
            {
                return false;
            }
        }
 
        //返回项目信息
        public override bool GetInfo(DataSet DS)
        {
            try
            {
                omodel = new Model.ClsK3_Employee_Model();
                omodel.HItemID = Convert.ToInt64(DS.Tables[0].Rows[0]["HItemID"]);
                omodel.HNumber =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HNumber"]) ;
                omodel.HName = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HName"]);
                //omodel.HShortNumber =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HShortNumber"] );
                //omodel.HLevel =DBUtility.ClsPub.isInt(DS.Tables[0].Rows[0]["HLevel"]);
                //omodel.HEmpRate = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HEmpRate"]);
                //omodel.HBasePay = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HBasePay"]);
                //omodel.HExamRate = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HExamRate"]);
                //omodel.HInsurance = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HInsurance"]);
                //omodel.HMedicare = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HMedicare"]);
                //omodel.HOtherDeduct3 = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HOtherDeduct3"]);
                //omodel.HDrydock = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HDrydock"]);
                omodel.HParentID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HParentID"]);
                //omodel.HEndflag = (bool)DS.Tables[0].Rows[0]["HEndflag"];
                //omodel.HNoBrushFlag = DBUtility.ClsPub.isBool(DS.Tables[0].Rows[0]["HNoBrushFlag"]);
                omodel.HStopflag = DBUtility.ClsPub.isBool(DS.Tables[0].Rows[0]["HStopflag"]);
                //omodel.HShiftFlag =DBUtility.ClsPub.isBool(DS.Tables[0].Rows[0]["HShiftFlag"]);
                omodel.HRemark = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HRemark"]);
                //omodel.HHelpCode = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HHelpCode"]  );
                //omodel.HOverType = DBUtility.ClsPub.isBool(DS.Tables[0].Rows[0]["HOverType"]); //(bool)DS.Tables[0].Rows[0]["HOverType"];
                //omodel.HStopwagesFlag = DBUtility.ClsPub.isBool(DS.Tables[0].Rows[0]["HStopwagesFlag"]); // (bool)DS.Tables[0].Rows[0]["HStopwagesFlag"];
 
                //omodel.HBirthDay = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HBirthDay"]);
                //omodel.HGradDate = Convert.ToDateTime(DS.Tables[0].Rows[0]["HGradDate"].ToString().Trim());
                //omodel.HInsuranceDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HInsuranceDate"]);
                //omodel.HContractBDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HContractBDate"]);
                //omodel.HContractEDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HContractEDate"]);
                //omodel.HJobCardEDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HJobCardEDate"]);
                //omodel.HCheckCardEDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HCheckCardEDate"]);
                //omodel.HStayCardEDate = Convert.ToDateTime(DS.Tables[0].Rows[0]["HStayCardEDate"].ToString().Trim());
                //omodel.HHealthCardEDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HHealthCardEDate"]);
 
                //omodel.HDutyID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HDutyID"].ToString());
                //omodel.HDormID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HDormID"].ToString());
                //omodel.HAge = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HAge"].ToString());
                //omodel.HContractYear = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HContractYear"].ToString());
                //omodel.HInsuranceStatus = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HInsuranceStatus"].ToString());
                //omodel.HSignStatus = DBUtility.ClsPub.isBool(DS.Tables[0].Rows[0]["HSignStatus"].ToString());
                
                //omodel.HEmpType =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HEmpType"] );
                //omodel.HPayType = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HPayType"] );
                //omodel.HWorkType = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HWorkType"] );
                //omodel.HDimissionReason =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HDimissionReason"] );
                //omodel.HSalaryLev = DS.Tables[0].Rows[0]["HSalaryLev"].ToString().Trim();
                //omodel.HMarr =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HMarr"] );
                //omodel.HBlighty = DS.Tables[0].Rows[0]["HBlighty"].ToString().Trim();
                //omodel.HNation = DS.Tables[0].Rows[0]["HNation"].ToString().Trim();
                //omodel.HBlightyType = DS.Tables[0].Rows[0]["HBlightyType"].ToString().Trim();
                //omodel.HGovStatus = DS.Tables[0].Rows[0]["HGovStatus"].ToString().Trim();
                //omodel.HBloodType = DS.Tables[0].Rows[0]["HBloodType"].ToString().Trim();
                //omodel.HStature = DS.Tables[0].Rows[0]["HStature"].ToString().Trim();
                //omodel.HAvoird = DS.Tables[0].Rows[0]["HAvoird"].ToString().Trim();
                //omodel.HKnowLev = DS.Tables[0].Rows[0]["HKnowLev"].ToString().Trim();
                //omodel.HProTitleID = DS.Tables[0].Rows[0]["HProTitleID"].ToString().Trim();
                //omodel.HGradSchool = DS.Tables[0].Rows[0]["HGraDSchool"].ToString().Trim();
                //omodel.HEngLev = DS.Tables[0].Rows[0]["HEngLev"].ToString().Trim();
                //omodel.HCompLev = DS.Tables[0].Rows[0]["HCompLev"].ToString().Trim();
                //omodel.HSpec = DS.Tables[0].Rows[0]["HSpec"].ToString().Trim();
                //omodel.HNowAdd =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HNowAdd"] );
                //omodel.HHomeAdd =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HHomeAdd"] );
                //omodel.HOldCompany = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HOldCompany"]);
                //omodel.HInsuranceNo =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HInsuranceNo"] );
                //omodel.HJobCardNo = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HJobCardNo"] );
                //omodel.HArchivesNo = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HArchivesNo"] );
 
                //omodel.HInComDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HInComDate"]);
                //omodel.HRelDate = Convert.ToDateTime(DS.Tables[0].Rows[0]["HRelDate"].ToString().Trim());
                //omodel.HDimissionDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HDimissionDate"]);
                //omodel.HLinkPhone =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HLinkPhone"] );
                omodel.HSex = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HSex"]);
                //omodel.HIDCard =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HIDCard"] );
                //omodel.HBirthDay = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HBirthDay"]);
                //omodel.HPostID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HPostID"].ToString());
                //omodel.HMobilePhone =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HMobilePhone"] );
                //omodel.HFax = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HFax"] );
                //omodel.HPostalCode =DBUtility.ClsPub.isStrNull( DS.Tables[0].Rows[0]["HPostalCode"] );
                //omodel.HEmail = DS.Tables[0].Rows[0]["HEmail"].ToString().Trim();HPostID
                //omodel.HBank = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBank"] );
                //omodel.HBankAccount = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBankAccount"] );
                omodel.HGroupID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HGroupID"].ToString());
                omodel.HGroupName = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HGroupName"]);
                omodel.HDeptID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HDeptID"].ToString());
                //omodel.HCTPrjID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HCTPrjID"].ToString());
                //omodel.HWorkTypeID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HWorkTypeID"].ToString());
                //omodel.HHighestPay = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HHighestPay"]);
                //omodel.HOverPayRate = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HOverPayRate"]);
                //omodel.HLeftMoneyRate = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HLeftMoneyRate"]);
                //omodel.HInsuranceSubsidy = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HInsuranceSubsidy"]);
                //omodel.HExamLevPostMoney = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HExamLevPostMoney"].ToString());
                //omodel.HEmpNo = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HEmpNo"]);
 
 
                List<Image> oList = Get_Image(" select * from Gy_EmpPic where HEmpID=" + omodel.HItemID.ToString(), "HPic");
                if (oList != null)
                {
                    foreach (Image i in oList)
                    {
                        omodel.HPic = i;
                    }
                }
                else
                {
                    omodel.HPic = null;
                }
 
                DS.Dispose();
                DS = null;
                return true;
 
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //读取 fieldName 该字段中符合条件的所有图片(sql SQL查询语句、fieldName 存储图片字段名)
        public List<Image> Get_Image(string sql, string fieldName)
        {
            List<Image> InformatoinCollection = new List<Image>();
            try
            {
                Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
                string s = "";
                SqlDataReader dr = oCn.RunReader(sql, "gy_czygl", ref s);
 
                if (!dr.HasRows)
                {
                    return null;
                }
 
                while (dr.Read())
                {
                    MemoryStream ms1 = new MemoryStream((byte[])dr[fieldName]);
                    Image image = Image.FromStream(ms1, true);
                    InformatoinCollection.Add(image);
                }
                dr.Close();
            }
            catch
            {
                InformatoinCollection = null;
            }
            return InformatoinCollection;
        }
    }
}