王 垚
2022-06-27 2ffc4b7794e47bd8cf9f7b9662b0f92322406bb7
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    /// <summary>
    /// 资源能力
    /// </summary>
    public class ClsGy_PlanShifts_View
    {
        
        //
        public string MvarItemKey;
        public string MvarReportTitle;
        public string SQLName;
        public Model.ClsGy_PlanShifts_Model omodel = new Model.ClsGy_PlanShifts_Model();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); 
 
        public ClsGy_PlanShifts_View()
        {
            MvarReportTitle = "资源能力设置";
            MvarItemKey = "Gy_PlanShifts";
            SQLName = "Select HItemID,HNumber 资源能力代码,HName 资源能力 from Gy_PlanShifts where HStopflag=0 Order by HItemID ";
        }
        //
        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }
        //
         
       
        //根据代码返回项目信息
        public bool GetInfoByDate(Int64 sSourceID,string sDate)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HDate='" + sDate + "' and HSourceID="+sSourceID.ToString(), 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 GetInfoByDate_Line(Int64 sSourceID, string sDate)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HDate='" + sDate + "' and HSourceID=" + sSourceID.ToString(), MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //根据资源得到工作中心的工时
        public Single GetInfoBySource(Int64 sSourceID)
        {
            try
            {
                DataSet DS;
                DS = oCn.RunProcReturn(" select b.HWorkTimes from Gy_Source a inner join Gy_WorkCenter b on a.HCenterID=b.HItemID " +
                        " where a.HitemID=" + sSourceID.ToString(), "Gy_Source", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                {
                    return 0;
                }
                else
                {
                    return DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HWorkTimes"]);
                }
            }
            catch (Exception e)
            {
                return 0;
            }
        }
 
        //根据资源得到工作中心的工时
        public Single GetInfoBySource_Line(Int64 sSourceID)
        {
            try
            {
                DataSet DS;
                DS = oCn.RunProcReturn(" select HWorkTimes=a.HWorkTimes*a.HClassCount from Gy_Source a " +
                        " where a.HitemID=" + sSourceID.ToString(), "Gy_Source", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                {
                    return 0;
                }
                else
                {
                    return DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HWorkTimes"]);
                }
            }
            catch (Exception e)
            {
                return 0;
            }
        } 
 
        //返回项目信息
        public bool GetInfo(DataSet DS)
        {
            try
            {
                omodel = new Model.ClsGy_PlanShifts_Model();
                omodel.HItemID = Convert.ToInt64(DS.Tables[0].Rows[0]["HItemID"]);
                omodel.HDate = DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HDate"]);
                omodel.HOverTimes = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HOverTimes"]);
                omodel.HRemark = DS.Tables[0].Rows[0]["HRemark"].ToString().Trim();
                omodel.HShiftsID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HShiftsID"]);
                omodel.HSourceID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HSourceID"]); 
                return true;
 
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
    }
}