33
jingh
2021-08-07 022c0469acd04cde5d6c9a22606b2e67f9269b51
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SQLHelper;
using Pub_Class;
 
namespace Kanban
{
    public partial class Sc_WorkBillProcTimeReportKB2 : Form
    {
        public Sc_WorkBillProcTimeReportKB2()
        {
            InitializeComponent();
        }
        public string ViewName = "h_p_Sc_WorkBillProcTimeReportKB2";
        public string sDeptID = "0";
        public int iRow = 0;
        public DateTime oBegintime = new DateTime();
        public DateTime otimeNow = new DateTime();
        public int oWorkTime = 0;
        public Int64 HICMOInterID = 0;
        DataSet DSet;
        bool sTrue = false;
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            //得到当前日期 时间
            lblTimeNow.Text = DBUtility.ClsPub.GetServerDate(-1);
        }
 
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (sTrue == false)
                return;
            //计算倒计时时间
 
            DataSet Ds;
            SQLHelper.ClsCN oCn = new ClsCN();
            oWorkTime = DBUtility.ClsPub.isInt(DSet.Tables[0].Rows[iRow]["HWorkTime"]) * 60;
            oBegintime = DBUtility.ClsPub.isDate(DSet.Tables[0].Rows[iRow]["HBeginTime"]);
            HICMOInterID = DBUtility.ClsPub.isLong(DSet.Tables[0].Rows[iRow]["HInterID"]) ;
            Ds = oCn.RunProcReturn("exec h_p_Sc_WorkBillProcTimeReportKB2_ByWorkTime " + sDeptID + "," + HICMOInterID + "," + oWorkTime + ",'" + oBegintime + "'", "Gy_WorkTime");
            string sZF = "";
            int HHour = 0;
            int HMinute = 0;
            int HSecond = 0;
            int HZF = 0;
            HHour = ClsPub.isInt(Ds.Tables[0].Rows[0]["HHOur"]);
            HMinute = ClsPub.isInt(Ds.Tables[0].Rows[0]["HMinute"]);
            HSecond = ClsPub.isInt(Ds.Tables[0].Rows[0]["HSecond"]);
            HZF = ClsPub.isInt(Ds.Tables[0].Rows[0]["HZF"]);
            if (HZF == 0)
            {
                sZF = "-";
            }
            else
            {
                sZF = "";
            } 
            TimeSpan ts = new TimeSpan(HHour, HMinute, HSecond);
            string sSeconds = DBUtility.ClsPub.isStrNull("00" + ts.Seconds.ToString());
            lblTimeCD.Text = sZF + (int)ts.TotalMinutes + ":" + sSeconds.Substring(sSeconds.Length - 2);
 
 
            //string sZF = "";
            //int cyDays = 0;
            //int cyDayseconds = 0;
            //int cySeconds = 0;
            //int EndTime = 0;
            //DateTime oAMSBTime2 = DBUtility.ClsPub.isDate(DateTime.Today.ToShortDateString() + " 00:00:01");
            //DateTime oAMSBTime = DBUtility.ClsPub.isDate(DateTime.Today.ToShortDateString() + " 08:00:00");
            //DateTime oAMXBTime = DBUtility.ClsPub.isDate(DateTime.Today.ToShortDateString() + " 11:30:00");
            //DateTime oPMSBTime = DBUtility.ClsPub.isDate(DateTime.Today.ToShortDateString() + " 12:30:00");
            //DateTime oPMXBTime = DBUtility.ClsPub.isDate(DateTime.Today.ToShortDateString() + " 17:00:00");
            //DateTime oPMXBTime2 = DBUtility.ClsPub.isDate(DateTime.Today.ToShortDateString() + " 23:59:59");
            //otimeNow = ClsPub.isDate(DBUtility.ClsPub.GetServerDate(-1));
            //oWorkTime = DBUtility.ClsPub.isInt(DSet.Tables[0].Rows[iRow]["HWorkTime"]) * 60;
            //oBegintime = DBUtility.ClsPub.isDate(DSet.Tables[0].Rows[iRow]["HBeginTime"]);
            //TimeSpan TsDate1 = otimeNow.Subtract(oBegintime);
            //cyDays = (int)TsDate1.TotalDays;
            //cyDayseconds = cyDays * 16 * 60 * 60;
            ////计算上班下班时间
            //if (otimeNow >= oAMSBTime2 && otimeNow < oAMSBTime)
            //{
            //    return;
            //    //otimeNow = DBUtility.ClsPub.isDate(DateTime.Today.AddDays(-1).ToShortDateString() + " 17:00:00");
            //}
            //if (otimeNow > oAMXBTime && otimeNow < oPMSBTime)
            //{
            //    return;
            //    //otimeNow = oPMXBTime;
            //}
            //if (otimeNow > oPMXBTime && otimeNow <= oPMXBTime2)
            //{
            //    return;
            //    //otimeNow = oPMXBTime;
            //}
            //TimeSpan TsDate = otimeNow.Subtract(oBegintime);
            //cySeconds = (int)TsDate.TotalSeconds;
            //EndTime = oWorkTime - cySeconds + cyDayseconds;
            //if (EndTime < 0)
            //{
            //    sZF = "-";
            //}
            //else
            //{
            //    sZF = "";
            //}
            //EndTime = System.Math.Abs(EndTime);
            //TimeSpan ts = new TimeSpan(0, 0, EndTime);
            //string sSeconds = DBUtility.ClsPub.isStrNull("00" + ts.Seconds.ToString());
            //lblTimeCD.Text = sZF + (int)ts.TotalMinutes + ":" + sSeconds.Substring(sSeconds.Length - 2);
        }
 
        private void timer3_Tick(object sender, EventArgs e)
        {
            DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();
            //全局刷新
            if (sTrue == false)
                return;
            lblICMOBillNo.Text = DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HBillNO"]);
            lblEmp.Text = "人员:" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HEmpName"]);
            lblMater.Text = DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HMaterName"]);
            lblWorkTime.Text = "标准工时(m):" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HWorkTime"]);
            lblBeginTime.Text = DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HBeginTime"]);
            lblTimeCD.Text = "0000:00";
            if (oEmp.GetInfoByID(DBUtility.ClsPub.isLong(DSet.Tables[0].Rows[iRow]["HEmpID"])))
            {
                //pEmpPic.Image = oEmp.omodel.HPic;
            }
            else
            {
                //pEmpPic.Image = null;
            }
            iRow = iRow + 1;
            if (iRow > DSet.Tables[0].Rows.Count - 1)
            {
                iRow = 0;
            }
        }
 
        private void Sc_WorkBillProcTimeReportKB2_Load(object sender, EventArgs e)
        {
            ClsIni oIni = new ClsIni();
            string sID = ClsIni.ReadIni("Dept", "DeptID", Pub_Class.ClsPub.AppPath + @"\" + "HXErp_SY.ini");
            sDeptID = sID;
            //
            int iHeight = 0;
            int iWidth = 0;
            iHeight = DBUtility.ClsPub.isInt(Math.Round(this.Height / 2.0, 0));
            iWidth = DBUtility.ClsPub.isInt(Math.Round(this.Width / 2.0, 0));
            pPic.Width = DBUtility.ClsPub.isInt(Math.Round(iWidth / 2.0, 0));
            pMater.Width = iWidth + 160;
            pEmp.Width = DBUtility.ClsPub.isInt(Math.Round(this.Width / 3.0, 0)) - 60;
            pBaseTime.Width = DBUtility.ClsPub.isInt(Math.Round(this.Width / 3.0, 0)) - 30;
            //
            pBillNo.Height = DBUtility.ClsPub.isInt(Math.Round(iHeight / 5.0, 0));
            panel2.Height = DBUtility.ClsPub.isInt(Math.Round(iHeight / 3.0, 0)) + 60;
            splitContainer1.Height = iHeight;
            splitContainer1.SplitterDistance= DBUtility.ClsPub.isInt(Math.Round(this.Width / 3.0, 0)) - 60;
            //
            Display();
            FirstShow();
            lblICMOBillNo.Focus();
        }
 
        private void FirstShow()
        {
            DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();
            //全局刷新
            if (sTrue == false)
                return;
            lblICMOBillNo.Text = DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HBillNO"]);
            lblEmp.Text = "人员:" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HEmpName"]);
            lblMater.Text = DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HMaterName"]);
            lblWorkTime.Text = "标准工时(m):" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HWorkTime"]);
            lblBeginTime.Text = DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[iRow]["HBeginTime"]);
            lblTimeCD.Text = "0000:00";
            if (oEmp.GetInfoByID(DBUtility.ClsPub.isLong(DSet.Tables[0].Rows[iRow]["HEmpID"])))
            {
                //pEmpPic.Image = oEmp.omodel.HPic;
            }
            else
            {
                //pEmpPic.Image = null;
            }
 
            if (iRow > DSet.Tables[0].Rows.Count - 1)
            {
                iRow = 0;
            }
        }
 
        private void Display()
        {
            try
            {
                ClsCN SubCn = new ClsCN();
                string sSql = "";
                string sWhere = "";
                //过滤条件
                //if (frmCondition.SqlStr.Trim().Length == 0)
                //    return;
                //sSql = frmCondition.SqlStr + sWhere + " order by HStatus,HDate   ";
                sSql = "exec h_p_Sc_WorkBillProcTimeReportKB2 " + sDeptID;
                //
                DSet = SubCn.RunProcReturn(sSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
                //生成首行标题
                if (DSet == null || DSet.Tables[0].Rows.Count == 0)
                {
                    sTrue = false;
                    //MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
                    SubCn.CnClose();
                    SubCn.CnDispose();
                    return;
                }
                sTrue = true;
                SubCn.CnClose();
                SubCn.CnDispose();
            }
            catch (Exception e)
            {
                return;
            }
        }
 
        //下拉式 选择框  GRID
        bool enterkey;
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            enterkey = false;
            if (keyData == Keys.Left)    //监听方向键 左 事件        
            {
                iRow = iRow - 1;
                if (iRow > DSet.Tables[0].Rows.Count - 1)
                {
                    iRow = 0;
                }
                if (iRow < 0)
                {
                    iRow = 0;
                }
                FirstShow();
            }
            if (keyData == Keys.Right)    //监听方向键 右 事件        
            {
                iRow = iRow + 1;
                if (iRow > DSet.Tables[0].Rows.Count - 1)
                {
                    iRow = 0;
                }
                if (iRow < 0)
                {
                    iRow = 0;
                }
                FirstShow();
            }
            //继续原来base.ProcessCmdKey中的处理               
            return base.ProcessCmdKey(ref msg, keyData);
        }
 
        private void timer4_Tick(object sender, EventArgs e)
        {
            Display();
        }
 
 
 
 
    }
}