沈泽
2021-08-20 d111e4321dcc4baa63f63597694f80d94e67ca11
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public class ClsGy_ClassTimePrjSub_Ctl:DBUtility.ClsGy_Base_Ctl 
    {
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); 
        //原代码 用于 替换子项目
        public string HOldNumber;
        public Model.ClsGy_ClassTimePrjSub_Model oModel = new Model.ClsGy_ClassTimePrjSub_Model();
        //新增
        public override bool AddNew()
        {
            
            try
            {
                oCn.BeginTran();
                oCn.RunProc("Insert into " + MvarItemKey + " " +
                    " (HInterID,HMaker,HMakeDate,HSumWorkTimes" +
                    ",HRate,HSumMoney,HYear,HPeriod" +
                    ",HOldRate) " +
                    " Values(" + oModel.HInterID + ",'" + oModel.HMaker + "','" + DBUtility.ClsPub.GetServerDate(-1) + "'," + oModel.HSumWorkTimes.ToString() +
                    "," + oModel.HRate + "," + oModel.HSumMoney.ToString() + "," + oModel.HYear.ToString() + "," + oModel.HPeriod.ToString() +
                    "," + oModel.HOldRate.ToString() + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                //修改上级为非末级代码
                //oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                oCn.RollBack();
                throw (e);
            }
        }
 
        //重复代码
        public bool HavSameNumber(long sItemID, string sNumber)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select HEntryID from Gy_ClassTimePrjSub Where HEntryID<>'" + sItemID + "' and HMaker='" + sNumber + "'", "Gy_ClassTimePrjSub");
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return true;
                }
            }
            catch (Exception e)
            {
                return false;
            }
        }
 
        //删除
        public bool DeleteByID(long sItemID)
        {
            try
            {
                oCn.RunProc("Delete from Gy_ClassTimePrjSub where HEntryID='" + sItemID + "'");
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
 
        //计算平均工资
        public bool GetAvgMoney(long HYear,long HPeriod,long HGroupID)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_Pay_GetAvgMoney " + HYear.ToString() + "," + HPeriod.ToString() + "," + HGroupID.ToString(), "gy_czygl");
                if (DS.Tables[0].Rows.Count == 0 || DS == null)
                {
                    return false;
                }
                oModel.HSumMoney = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HSumMoney"]);
                oModel.HSumWorkTimes = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HSumWorkTimes"]);
                oModel.HRate = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HRate"]);
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
 
        //构造函数
        public ClsGy_ClassTimePrjSub_Ctl()
        {
            MvarItemKey = "Gy_ClassTimePrjSub";
            MvarReportTitle = "月度核算记录";
            oModel = new Model.ClsGy_ClassTimePrjSub_Model();
        } 
    }
}