public void subGetData() { Aattendant at = new Aattendant(); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); DataTable dt = null; double cntStart = 0; double cntEnd = 0; double cntTotal = 0; sb.Append(" SELECT * FROM ("); sb.Append(" SELECT OT.OTEmpID,OT.OTCompID,C.CompName,OT.DeptID,OT.DeptName,OT.OrganID,OT.OrganName,OT.OTFormNO,P.NameN,OT.OTRegisterID,PR.NameN AS RegisterNameN,OT.OTTxnID,OTT.CodeCName,ISNULL(AI.FileName,'') AS FileName,OT.OTStatus,OT.MealFlag,isnull(OT.MealTime,0)+isnull(OT2.MealTime,0) AS MealTime, OT.OTSeq,"); sb.Append(" Case OT.OTStatus WHEN '1' THEN '暫存' WHEN '2' THEN '送簽' WHEN '3' THEN '核准' WHEN '4' THEN '駁回' WHEN '5' THEN '刪除' WHEN '6' THEN '取消' WHEN '7' THEN '作廢' WHEN '9' THEN '計薪後收回' END AS OTStatusName,"); sb.Append(" CASE OT.SalaryOrAdjust WHEN '1' THEN '轉薪資' WHEN '2' THEN '轉補休' END AS SalaryOrAdjustName,OT.OTAttachment, "); sb.Append(" (OT.OTStartDate+'~'+isnull(OT2.OTEndDate,OT.OTEndDate)) AS OTDate,"); sb.Append(" (OT.OTStartTime+'~'+isnull(OT2.OTEndTime,OT.OTEndTime)) AS OTTime, OT.AdjustInvalidDate,"); //sb.Append(" ((CAST(OT.OTTotalTime AS FLOAT)-CAST(OT.MealTime AS FLOAT))/CAST(60 AS FLOAT))+((CAST(ISNULL(OT2.OTTotalTime,0) AS FLOAT)-CAST(ISNULL(OT2.MealTime,0) AS FLOAT))/CAST(60 AS FLOAT)) AS OTTotalTime,"); sb.Append(" Convert(Decimal(10,1),ROUND(Convert(Decimal(10,2),((CAST(OT.OTTotalTime AS FLOAT)-CAST(OT.MealTime AS FLOAT))/CAST(60 AS FLOAT))+((CAST(ISNULL(OT2.OTTotalTime,0) AS FLOAT)-CAST(ISNULL(OT2.MealTime,0) AS FLOAT))/CAST(60 AS FLOAT))),1)) AS OTTotalTime,"); sb.Append(" OT.LastChgID,PL.NameN AS LastChgNameN,OT.LastChgDate,OT.OTReasonMemo,OT.OTPayDate"); sb.Append(" FROM OverTimeDeclaration OT "); sb.Append(" LEFT JOIN OverTimeDeclaration OT2 on OT2.OTTxnID=OT.OTTxnID AND OT2.OTSeqNo=2 AND OT2.OverTimeFlag='1'"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Company] C ON C.CompID=OT.OTCompID AND C.InValidFlag = '0' And C.NotShowFlag = '0'"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] P ON P.CompID = OT.OTCompID AND P.EmpID=OT.OTEmpID"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] PR ON PR.CompID = OT.OTRegisterComp AND PR.EmpID=OT.OTRegisterID"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Company] C2 ON C2.CompID=OT.LastChgComp AND C2.InValidFlag = '0' And C2.NotShowFlag = '0'"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] PL ON PL.EmpID=OT.LastChgID AND PL.CompID = C2.CompID "); sb.Append(" LEFT JOIN AttachInfo AI ON AI.AttachID IS NOT NULL AND AI.AttachID <> '' AND AI.AttachID = OT.OTAttachment AND FileSize > 0"); sb.Append(" LEFT JOIN AT_CodeMap AS OTT ON OT.OTTypeID = OTT.Code AND OTT.TabName='OverTime' AND OTT.FldName='OverTimeType'"); sb.Append(" WHERE OT.OTSeqNo=1 AND OT.OTTxnID='" + _OTTxnID + "' AND OT.OverTimeFlag='1') A"); sb.Append(" WHERE 1=1 AND A.OTCompID = '" + _OTCompID + "' AND A.OTEmpID = '" + _EmpID + "'"); sb.Append(" AND A.OTDate='" + _OTStartDate + "~" + _OTEndDate + "'"); sb.Append(" AND A.OTTime='" + _OTStartTime + "~" + _OTEndTime + "'"); dt = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; btnAttachDownload.ucAttachDB = _DBName; btnAttachDownload.ucAttachID = dt.Rows[0]["OTAttachment"].ToString(); if (dt.Rows[0]["FileName"].ToString() == "") { btnAttachDownload.Visible = false; } else { lblAttachName.Text = dt.Rows[0]["FileName"].ToString(); } lblCompName.Text = dt.Rows[0]["CompName"].ToString(); lblDeptName.Text = dt.Rows[0]["DeptName"].ToString(); lblOrganName.Text = dt.Rows[0]["OrganName"].ToString(); lblEmpName.Text = dt.Rows[0]["OTEmpID"].ToString() + " " + dt.Rows[0]["NameN"].ToString(); lblOTRegisterName.Text = dt.Rows[0]["OTRegisterID"].ToString() + " " + dt.Rows[0]["RegisterNameN"].ToString(); lblOTDateValue.Text = _OTStartDate; lblOTDateValueEnd.Text = _OTEndDate; lblBeginTime.Text = _OTStartTime.Substring(0, 2) + ":" + _OTStartTime.Substring(2, 2); lblEndTime.Text = _OTEndTime.Substring(0, 2) + ":" + _OTEndTime.Substring(2, 2); chkMealFlag.Checked = (dt.Rows[0]["MealFlag"].ToString() == "1") ? true : false; lblMealTime.Text = dt.Rows[0]["MealTime"].ToString(); lblOTTotalTime.Text = Aattendant.GetNumString(dt.Rows[0]["OTTotalTime"].ToString(), 1); lblOTTypeID.Text = dt.Rows[0]["CodeCName"].ToString(); lblSalaryOrAdjust.Text = dt.Rows[0]["SalaryOrAdjustName"].ToString(); if (lblSalaryOrAdjust.Text == "轉補休") { lblAdjustInvalidDate.Visible = true; txtAdjustInvalidDate.Visible = true; } string ottxnid = dt.Rows[0]["OTTxnID"].ToString(); txtAdjustInvalidDate.Text = Convert.ToDateTime(dt.Rows[0]["AdjustInvalidDate"].ToString()).ToString("yyyy/MM/dd"); lblOTReasonMemo.Text = dt.Rows[0]["OTReasonMemo"].ToString(); lblLastChgID.Text = dt.Rows[0]["LastChgID"].ToString(); lblLastChgName.Text = dt.Rows[0]["LastChgNameN"].ToString(); lblLastChgDate.Text = Convert.ToDateTime(dt.Rows[0]["LastChgDate"].ToString()).ToString("yyyy/MM/dd HH:mm:ss"); if (dt.Rows[0]["OTPayDate"].ToString() == "0") { lblOTPayDate.Text = ""; } else { lblOTPayDate.Text = dt.Rows[0]["OTPayDate"].ToString(); } string otseq = dt.Rows[0]["OTSeq"].ToString(); SignData(); if (_OTStartDate == _OTEndDate) { cntTotal = (Convert.ToDouble(_OTEndTime.Substring(0, 2)) * 60 + Convert.ToDouble(_OTEndTime.Substring(2, 2))) - (Convert.ToDouble(_OTStartTime.Substring(0, 2)) * 60 + Convert.ToDouble(_OTStartTime.Substring(2, 2))); #region "計算時段" string returnPeriodCount = ""; bool bOTTimeStart = !string.IsNullOrEmpty(_OTStartTime); bool bOTTimeEnd = !string.IsNullOrEmpty(_OTEndTime); if (bOTTimeStart && bOTTimeEnd) { trTwo.Visible = false; int iOTTimeStart = 0; int iOTTimeEnd = 0; if (int.TryParse(_OTStartTime, out iOTTimeStart) && int.TryParse(_OTEndTime, out iOTTimeEnd)) { string mealFlag = chkMealFlag.Checked ? "1" : "0"; string sMealTime = string.IsNullOrEmpty(lblMealTime.Text) ? "0" : lblMealTime.Text.Trim(); int iMealTime = 0; int.TryParse(sMealTime, out iMealTime); bool bPeriodCount = at.PeriodCount("OverTimeDeclaration", _EmpID, cntTotal, 0, iOTTimeStart, iOTTimeEnd, _OTStartDate, 0, 0, "1900/01/01", iMealTime, mealFlag, ottxnid, out returnPeriodCount); if (bPeriodCount && !string.IsNullOrEmpty(returnPeriodCount) && returnPeriodCount.Split(';').Length > 0) { var sReturnPeriodList = returnPeriodCount.Split(';'); for (var i = 0; i < sReturnPeriodList.Length; i++) { var datas = sReturnPeriodList[i]; lblPeriod.Visible = true; tbTime.Visible = true; if (i == 0 && datas.Split(',').Length > 0 && datas.Split(',')[0] != "1900/01/01") { trOne.Visible = true; if (datas.Split(',').Length >= 1) { lblDateOne.Text = datas.Split(',')[0] == "1900/01/01" ? "-" : datas.Split(',')[0]; } if (datas.Split(',').Length >= 2) { lblDateOne_0.Text = datas.Split(',')[1] == "0.0" ? "-" : datas.Split(',')[1]; } if (datas.Split(',').Length >= 3) { lblDateOne_1.Text = datas.Split(',')[2] == "0.0" ? "-" : datas.Split(',')[2]; } if (datas.Split(',').Length >= 4) { lblDateOne_2.Text = datas.Split(',')[3] == "0.0" ? "-" : datas.Split(',')[3]; } } if (i == 1 && datas.Split(',').Length > 0 && datas.Split(',')[0] != "1900/01/01") { trTwo.Visible = true; if (datas.Split(',').Length >= 1) { lblDateTwo.Text = datas.Split(',')[0] == "1900/01/01" ? "-" : datas.Split(',')[0]; } if (datas.Split(',').Length >= 2) { lblDateTwo_0.Text = datas.Split(',')[1] == "0.0" ? "-" : datas.Split(',')[1]; } if (datas.Split(',').Length >= 3) { lblDateTwo_1.Text = datas.Split(',')[2] == "0.0" ? "-" : datas.Split(',')[2]; } if (datas.Split(',').Length >= 4) { lblDateTwo_2.Text = datas.Split(',')[3] == "0.0" ? "-" : datas.Split(',')[3]; } } } txtTotalDescription.Text = (lblMealTime.Text != "" && Convert.ToDouble(lblMealTime.Text) > 0 && chkMealFlag.Checked == true) ? "(已扣除用餐時數" + lblMealTime.Text + "分鐘)" : ""; txtTotalDescription.Visible = true; string meal = (chkMealFlag.Checked == false) ? "0" : lblMealTime.Text; lblOTTotalTime.Text = Convert.ToDouble((cntTotal - Convert.ToDouble(meal)) / 60).ToString("0.0"); } } } #endregion "計算時段" } else { cntStart = (23 - (Convert.ToDouble(_OTStartTime.Substring(0, 2)))) * 60 + (60 - Convert.ToDouble(_OTStartTime.Substring(2, 2))); cntEnd = (Convert.ToDouble(_OTEndTime.Substring(0, 2)) * 60 + Convert.ToDouble(_OTEndTime.Substring(2, 2))); #region "計算時段" string returnPeriodCount = ""; bool bOTTimeStart = !string.IsNullOrEmpty(_OTStartTime); bool bOTTimeEnd = !string.IsNullOrEmpty(_OTEndTime); if (bOTTimeStart && bOTTimeEnd) { trTwo.Visible = false; int iOTTimeStart = 0; int iOTTimeEnd = 0; if (int.TryParse(_OTStartTime, out iOTTimeStart) && int.TryParse(_OTEndTime, out iOTTimeEnd)) { string mealFlag = chkMealFlag.Checked ? "1" : "0"; string sMealTime = string.IsNullOrEmpty(lblMealTime.Text) ? "0" : lblMealTime.Text.Trim(); int iMealTime = 0; int.TryParse(sMealTime, out iMealTime); bool bPeriodCount = at.PeriodCount("OverTimeDeclaration", _EmpID, cntStart, cntEnd, iOTTimeStart, 2359, _OTStartDate, 0, iOTTimeEnd, _OTEndDate, iMealTime, mealFlag, ottxnid, out returnPeriodCount); if (bPeriodCount && !string.IsNullOrEmpty(returnPeriodCount) && returnPeriodCount.Split(';').Length > 0) { var sReturnPeriodList = returnPeriodCount.Split(';'); for (var i = 0; i < sReturnPeriodList.Length; i++) { var datas = sReturnPeriodList[i]; lblPeriod.Visible = true; tbTime.Visible = true; if (i == 0 && datas.Split(',').Length > 0 && datas.Split(',')[0] != "1900/01/01") { trOne.Visible = true; if (datas.Split(',').Length >= 1) { lblDateOne.Text = datas.Split(',')[0] == "1900/01/01" ? "-" : datas.Split(',')[0]; } if (datas.Split(',').Length >= 2) { lblDateOne_0.Text = datas.Split(',')[1] == "0.0" ? "-" : datas.Split(',')[1]; } if (datas.Split(',').Length >= 3) { lblDateOne_1.Text = datas.Split(',')[2] == "0.0" ? "-" : datas.Split(',')[2]; } if (datas.Split(',').Length >= 4) { lblDateOne_2.Text = datas.Split(',')[3] == "0.0" ? "-" : datas.Split(',')[3]; } } if (i == 1 && datas.Split(',').Length > 0 && datas.Split(',')[0] != "1900/01/01") { trTwo.Visible = true; if (datas.Split(',').Length >= 1) { lblDateTwo.Text = datas.Split(',')[0] == "1900/01/01" ? "-" : datas.Split(',')[0]; } if (datas.Split(',').Length >= 2) { lblDateTwo_0.Text = datas.Split(',')[1] == "0.0" ? "-" : datas.Split(',')[1]; } if (datas.Split(',').Length >= 3) { lblDateTwo_1.Text = datas.Split(',')[2] == "0.0" ? "-" : datas.Split(',')[2]; } if (datas.Split(',').Length >= 4) { lblDateTwo_2.Text = datas.Split(',')[3] == "0.0" ? "-" : datas.Split(',')[3]; } } } txtTotalDescription.Text = (lblMealTime.Text != "" && Convert.ToDouble(lblMealTime.Text) > 0 && chkMealFlag.Checked == true) ? "(已扣除用餐時數" + lblMealTime.Text + "分鐘)" : ""; txtTotalDescription.Visible = true; string meal = (chkMealFlag.Checked == false) ? "0" : lblMealTime.Text; lblOTTotalTime.Text = Convert.ToDouble((cntEnd + cntStart - Convert.ToDouble(meal)) / 60).ToString("0.0"); } } } #endregion "計算時段" } }
public void subGetData() { _CurrFlowCaseID = _CurrFlowLogID.Remove(14); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); Aattendant at = new Aattendant(); string strdata = ""; double cntStart = 0; double cntEnd = 0; double cntTotal = 0; sb.Append("SELECT OT.OTCompID,C.CompName,OT.DeptID,OT.DeptName,OT.OrganID,OT.OrganName,OT.SalaryOrAdjust,CONVERT(varchar(12),OT.AdjustInvalidDate,111) as AdjustInvalidDate,P.NameN,OT.OTRegisterID,PR.NameN AS RegisterNameN,"); sb.Append("OT.OTTxnID,OT.OTStartTime,"); sb.Append("isnull(OT1.OTEndTime,OT.OTEndTime) as OTEndTime,isnull(OT1.OTEndDate,OT.OTEndDate) as OTEndDate,"); sb.Append(" OT.MealFlag,OT.MealTime+isnull(OT1.MealTime,0) as MealTime,OT.OTTotalTime+isnull(OT1.OTTotalTime,0) as OTTotalTime,OTT.CodeCName as OTTypeID,OT.OTReasonID,OT.OTReasonMemo,"); //sb.Append(" OT.MealFlag,OT.MealTime+isnull(OT1.MealTime,0) as MealTime,OT.OTTotalTime+isnull(OT1.OTTotalTime,0) as OTTotalTime,OTT.OTTypeName as OTTypeID,OT.OTReasonID,OT.OTReasonMemo,"); sb.Append(" OT.LastChgID,PL.NameN AS LastChgNameN,CONVERT(varchar(12),OT.LastChgDate,111)+' '+CONVERT(varchar(8),OT.LastChgDate,108) as LastChgDate,ISNULL(AI.FileName,'') AS FileName,OT.OTAttachment,'A' as Input "); //時間分割 //sb.Append(" OT1.OTTotalTime as StartHr,OT.OTTotalTime as EndHr"); sb.Append(" FROM OverTimeAdvance OT"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Company] C ON C.CompID=OT.OTCompID AND C.InValidFlag = '0' And C.NotShowFlag = '0'"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] P ON P.CompID = OT.OTCompID AND P.EmpID=OT.OTEmpID"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] PR ON PR.CompID = OT.OTRegisterComp AND PR.EmpID=OT.OTRegisterID"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] PL ON PL.CompID = OT.LastChgComp AND PL.EmpID=OT.LastChgID"); //sb.Append(" LEFT JOIN AttachInfo AI ON AI.AttachID = OT.OTAttachment"); sb.Append(" LEFT JOIN AttachInfo AI ON AI.AttachID IS NOT NULL AND AI.AttachID <> '' AND AI.AttachID = OT.OTAttachment AND FileSize > 0");//20170209 leo modify -參考Judy的After //sb.Append(" LEFT JOIN OverTimeAdvance OT1 on OT1.OTCompID='" + _CurrOTCompID + "' AND OT1.OTEmpID='" + _CurrOTEmpID + "' AND OT1.OTStartDate='" + _CurrOTEndDate + "' AND OT1.OTSeqNo='" + 2 + "' AND OT1.OTEndDate='" + _CurrOTEndDate + "' AND OT1.FlowCaseID='" + _CurrFlowCaseID + "'"); sb.Append(" LEFT JOIN OverTimeAdvance OT1 on OT1.OTCompID='" + _CurrOTCompID + "' AND OT1.OTEmpID='" + _CurrOTEmpID + "' AND OT1.OTSeqNo='" + 2 + "' AND OT1.FlowCaseID='" + _CurrFlowCaseID + "'"); sb.Append(" LEFT JOIN AT_CodeMap OTT ON OTT.TabName='OverTime' and OTT.FldName='OverTimeType' and OT.OTTypeID = OTT.Code"); //sb.Append(" LEFT JOIN OverTimeType OTT ON OT.OTCompID = OTT.CompID and OT.OTTypeID = OTT.OTTypeId"); sb.Append(" WHERE OT.OTCompID='" + _CurrOTCompID + "'"); sb.Append(" AND OT.OTEmpID='" + _CurrOTEmpID + "'"); sb.Append(" AND OT.OTStartDate='" + _CurrOTStartDate + "'"); sb.Append(" AND OT.OTSeq='" + _CurrOTSeq + "'"); sb.Append(" AND OT.OTEndDate='" + _CurrOTStartDate + "'"); sb.Append(" AND OT.FlowCaseID='" + _CurrFlowCaseID + "'"); sb.Append(" UNION"); sb.Append(" SELECT OD.OTCompID,C.CompName,OD.DeptID,OD.DeptName,OD.OrganID,OD.OrganName,OD.SalaryOrAdjust,CONVERT(varchar(12),OD.AdjustInvalidDate,111) as AdjustInvalidDate,P.NameN,OD.OTRegisterID,PR.NameN AS RegisterNameN,"); sb.Append("OD.OTTxnID,OD.OTStartTime,"); //sb.Append(" OD.OTEndTime,OD.OTEndDate,"); sb.Append("isnull(OD1.OTEndTime,OD.OTEndTime) as OTEndTime,isnull(OD1.OTEndDate,OD.OTEndDate) as OTEndDate,"); sb.Append(" OD.MealFlag,OD.MealTime+isnull(OD1.MealTime,0) as MealTime,OD.OTTotalTime+isnull(OD1.OTTotalTime,0) as OTTotalTime,ODT.CodeCName as OTTypeID,OD.OTReasonID,OD.OTReasonMemo,"); sb.Append(" OD.LastChgID,PL.NameN AS LastChgNameN,CONVERT(varchar(12),OD.LastChgDate,111)+' '+CONVERT(varchar(8),OD.LastChgDate,108) as LastChgDate,ISNULL(AI.FileName,'') AS FileName,OD.OTAttachment,'D' as Input"); sb.Append(" FROM OverTimeDeclaration OD"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Company] C ON C.CompID=OD.OTCompID AND C.InValidFlag = '0' And C.NotShowFlag = '0'"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] P ON P.CompID = OD.OTCompID AND P.EmpID=OD.OTEmpID"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] PR ON PR.CompID = OD.OTRegisterComp AND PR.EmpID=OD.OTRegisterID"); sb.Append(" LEFT JOIN " + Util.getAppSetting("app://eHRMSDB_OverTime/") + ".[dbo].[Personal] PL ON PL.CompID = OD.LastChgComp AND PL.EmpID=OD.LastChgID"); //sb.Append(" LEFT JOIN AttachInfo AI ON AI.AttachID = OD.OTAttachment"); sb.Append(" LEFT JOIN AttachInfo AI ON AI.AttachID IS NOT NULL AND AI.AttachID <> '' AND AI.AttachID = OD.OTAttachment AND FileSize > 0");//20170209 leo modify -參考Judy的After sb.Append(" LEFT JOIN OverTimeDeclaration OD1 on OD1.OTCompID='" + _CurrOTCompID + "' AND OD1.OTEmpID='" + _CurrOTEmpID + "' AND OD1.OTSeqNo='" + 2 + "' AND OD1.FlowCaseID='" + _CurrFlowCaseID + "'"); sb.Append(" LEFT JOIN AT_CodeMap ODT ON ODT.TabName='OverTime' and ODT.FldName='OverTimeType' and OD.OTTypeID = ODT.Code"); //sb.Append(" LEFT JOIN OverTimeType ODT ON OD.OTCompID = ODT.CompID and OD.OTTypeID = ODT.OTTypeId"); sb.Append(" WHERE OD.OTCompID='" + _CurrOTCompID + "'"); sb.Append(" AND OD.OTEmpID='" + _CurrOTEmpID + "'"); sb.Append(" AND OD.OTStartDate='" + _CurrOTStartDate + "'"); sb.Append(" AND OD.OTSeq='" + _CurrOTSeq + "'"); sb.Append(" AND OD.OTEndDate='" + _CurrOTStartDate + "'"); sb.Append(" AND OD.FlowCaseID='" + _CurrFlowCaseID + "'"); DataTable dt = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; if (dt.Rows.Count > 0) { if (dt.Rows[0]["Input"].ToString() == "D") { Label3.Text = "月已申報時數合計: 送簽"; } //lblCompID.Text = dt.Rows[0]["OTCompID"].ToString(); lblCompName.Text = dt.Rows[0]["CompName"].ToString(); //lblDeptID.Text = dt.Rows[0]["DeptID"].ToString(); lblDeptName.Text = dt.Rows[0]["DeptName"].ToString(); //lblOrganID.Text = dt.Rows[0]["OrganID"].ToString(); lblOrganName.Text = dt.Rows[0]["OrganName"].ToString(); lblEmpID.Text = _CurrOTEmpID; lblSalaryOrAdjust.Text = dt.Rows[0]["SalaryOrAdjust"].ToString() == "2" ? "轉補休" : "轉薪資"; lblAdjustInvalidDate.Visible = dt.Rows[0]["SalaryOrAdjust"].ToString() == "2"; txtAdjustInvalidDate.Visible = dt.Rows[0]["SalaryOrAdjust"].ToString() == "2"; txtAdjustInvalidDate.Text = dt.Rows[0]["AdjustInvalidDate"].ToString(); lblEmpName.Text = dt.Rows[0]["NameN"].ToString(); lblOTRegisterID.Text = dt.Rows[0]["OTRegisterID"].ToString(); lblOTRegisterName.Text = dt.Rows[0]["RegisterNameN"].ToString(); lblOTDateValue.Text = _CurrOTStartDate; lblOTDateValueEnd.Text = dt.Rows[0]["OTEndDate"].ToString(); lblBeginTime.Text = dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2) + ":" + dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2); //lblBeginTime.Text = dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2) + ":" + dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2); lblEndTime.Text = dt.Rows[0]["OTEndTime"].ToString().Substring(0, 2) + ":" + dt.Rows[0]["OTEndTime"].ToString().Substring(2, 2); //lblEndTime.Text = dt.Rows[0]["OTEndTime"].ToString().Substring(0, 2) + ":" + dt.Rows[0]["OTEndTime"].ToString().Substring(2, 2); chkMealFlag.Checked = (dt.Rows[0]["MealFlag"].ToString() == "1") ? true : false; lblMealTime.Text = dt.Rows[0]["MealTime"].ToString(); //lblOTTotalTime.Text = (Convert.ToDouble(dt.Rows[0]["OTTotalTime"].ToString()) - Convert.ToDouble(dt.Rows[0]["MealTime"].ToString())/60).ToString("0.0").ToString(); //20170213 leo modify TotalTime 依照起訖時間分鐘計算 Double TotalTime = _CurrOTStartDate.ToString() == dt.Rows[0]["OTEndDate"].ToString() ? (Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(0, 2)) * 60) + Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(2, 2)) - (Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2)) * 60) - Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2)) : 1440.0 - (Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2)) * 60) - Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2)) + (Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(0, 2)) * 60) + Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(2, 2)); TotalTime = TotalTime - (chkMealFlag.Checked ? Convert.ToDouble(dt.Rows[0]["MealTime"].ToString()) : 0); //Double TotalTime = 0.0; //if (_CurrOTStartDate.ToString() == dt.Rows[0]["OTEndDate"].ToString()) // TotalTime = (Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(0, 2)) * 60) + Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(2, 2)) - (Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2)) * 60) - Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2)); //else //TotalTime = 1440.0 - (Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2)) * 60) - Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2)) + (Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(0, 2)) * 60) + Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(2, 2)); lblOTTotalTime.Text = Math.Round(TotalTime / 60, 1, MidpointRounding.AwayFromZero).ToString("0.0"); lblOTTypeID.Text = dt.Rows[0]["OTTypeID"].ToString(); lblOTReasonMemo.Text = dt.Rows[0]["OTReasonMemo"].ToString(); lblLastChgID.Text = dt.Rows[0]["LastChgID"].ToString(); lblLastChgName.Text = dt.Rows[0]["LastChgNameN"].ToString(); lblLastChgDate.Text = dt.Rows[0]["LastChgDate"].ToString(); ViewState["Input"] = dt.Rows[0]["Input"].ToString() == "A" ? "OverTimeAdvance" : "OverTimeDeclaration"; //StartHr = Convert.ToDouble(dt.Rows[0]["StartHr"].ToString()); //EndHr = Convert.ToDouble(dt.Rows[0]["EndHr"].ToString()); if (dt.Rows[0]["FileName"].ToString() == "") { btnAttachDownload.Visible = false; } else { lblAttachName.Text = dt.Rows[0]["FileName"].ToString(); btnAttachDownload.ucAttachDB = _DBName; btnAttachDownload.ucAttachID = dt.Rows[0]["OTAttachment"].ToString(); } SignData(); if (_CurrOTStartDate == dt.Rows[0]["OTEndDate"].ToString()) { if (dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2) == "00") { cntStart = Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2)); } else { cntStart = ((Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2))) * 60) + Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2)); } cntEnd = ((Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(0, 2))) * 60) + Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(2, 2)); cntTotal = cntEnd - cntStart; DataTable dt1 = at.QueryData("SUM(OTTotalTime) AS OTTotalTime", "OverTimeDeclaration", " AND OTStatus='3' AND OTStartDate='" + _CurrOTStartDate + "' AND OTEndDate='" + dt.Rows[0]["OTEndDate"].ToString() + "'"); double hr;//資料庫的加班總時數 if (dt1.Rows[0]["OTTotalTime"].ToString() == "") { hr = 0.0; } else { hr = Convert.ToDouble(dt.Rows[0]["OTTotalTime"].ToString()); } if (at.PeriodCount(ViewState["Input"].ToString(), _CurrOTEmpID, cntEnd - cntStart, 0, Convert.ToInt32(dt.Rows[0]["OTStartTime"]), Convert.ToInt32(dt.Rows[0]["OTEndTime"]), _CurrOTStartDate, 0, 0, "1900/01/01", Convert.ToDouble(dt.Rows[0]["MealTime"].ToString()), dt.Rows[0]["MealFlag"].ToString(), dt.Rows[0]["OTTxnID"].ToString(), out strdata)) { } else { Util.MsgBox("時段有問題"); } //strdata = at.OneDay(ViewState["Input"].ToString(), _CurrOTEmpID, cntTotal / 60, hr, _CurrOTStartDate, Convert.ToDouble(dt.Rows[0]["MealTime"].ToString()) / 60, dt.Rows[0]["MealFlag"].ToString(), dt.Rows[0]["OTStartTime"].ToString(), dt.Rows[0]["OTEndTime"].ToString(), _CurrOTSeq); //strdata = at.OneDay(cntTotal, hr, _CurrOTStartDate, Convert.ToDouble(dt.Rows[0]["MealTime"].ToString()), dt.Rows[0]["MealFlag"].ToString()); strdata = "0;0;" + strdata; trOne.Visible = true; lblDateOne.Text = (strdata.Split(';')[2]).Split(',')[0]; lblDateOne_0.Text = ((strdata.Split(';')[2]).Split(',')[1] == "0.0") ? "-" : (strdata.Split(';')[2]).Split(',')[1]; lblDateOne_1.Text = ((strdata.Split(';')[2]).Split(',')[2] == "0.0") ? "-" : (strdata.Split(';')[2]).Split(',')[2]; lblDateOne_2.Text = ((strdata.Split(';')[2]).Split(',')[3] == "0.0") ? "-" : (strdata.Split(';')[2]).Split(',')[3]; } else { cntStart = (23 - (Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(0, 2)))) * 60 + (60 - Convert.ToDouble(dt.Rows[0]["OTStartTime"].ToString().Substring(2, 2))); cntEnd = (Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(0, 2))) * 60 + Convert.ToDouble(dt.Rows[0]["OTEndTime"].ToString().Substring(2, 2)); DataTable dtStart = at.QueryData("SUM(OTTotalTime) AS OTTotalTime", "OverTimeDeclaration", " AND OTStatus='3' AND OTStartDate='" + _CurrOTStartDate + "' AND OTEndDate='" + _CurrOTStartDate + "'"); DataTable dtEnd = at.QueryData("SUM(OTTotalTime) AS OTTotalTime", "OverTimeDeclaration", " AND OTStatus='3' AND OTStartDate='" + dt.Rows[0]["OTEndDate"].ToString() + "' AND OTEndDate='" + dt.Rows[0]["OTEndDate"].ToString() + "'"); double hrStart;//資料庫的加班總時數 if (dtStart.Rows[0]["OTTotalTime"].ToString() == "") { hrStart = 0.0; } else { hrStart = Convert.ToDouble(dtStart.Rows[0]["OTTotalTime"].ToString()); } double hrEnd;//資料庫的加班總時數 if (dtEnd.Rows[0]["OTTotalTime"].ToString() == "") { hrEnd = 0.0; } else { hrEnd = Convert.ToDouble(dtEnd.Rows[0]["OTTotalTime"].ToString()); } if (at.PeriodCount(ViewState["Input"].ToString(), _CurrOTEmpID, cntStart, cntEnd, Convert.ToInt32(dt.Rows[0]["OTStartTime"]), 2359, _CurrOTStartDate, 0, Convert.ToInt32(dt.Rows[0]["OTEndTime"]), dt.Rows[0]["OTEndDate"].ToString(), Convert.ToDouble(dt.Rows[0]["MealTime"].ToString()), dt.Rows[0]["MealFlag"].ToString(), dt.Rows[0]["OTTxnID"].ToString(), out strdata)) { } else { Util.MsgBox("時段有問題"); } //strdata = at.TwoDay(ViewState["Input"].ToString(), _CurrOTEmpID, cntStart / 60, cntEnd / 60, hrStart / 60, hrEnd / 60, _CurrOTStartDate, dt.Rows[0]["OTEndDate"].ToString(), Convert.ToDouble(dt.Rows[0]["MealTime"].ToString()) / 60, dt.Rows[0]["MealFlag"].ToString(), dt.Rows[0]["OTTxnID"].ToString()); strdata = "0;0;" + strdata; trOne.Visible = true; trTwo.Visible = true; lblDateOne.Text = (strdata.Split(';')[2]).Split(',')[0]; lblDateOne_0.Text = ((strdata.Split(';')[2]).Split(',')[1] == "0.0") ? "-" : (strdata.Split(';')[2]).Split(',')[1]; lblDateOne_1.Text = ((strdata.Split(';')[2]).Split(',')[2] == "0.0") ? "-" : (strdata.Split(';')[2]).Split(',')[2]; lblDateOne_2.Text = ((strdata.Split(';')[2]).Split(',')[3] == "0.0") ? "-" : (strdata.Split(';')[2]).Split(',')[3]; lblDateTwo.Text = (strdata.Split(';')[3]).Split(',')[0]; lblDateTwo_0.Text = ((strdata.Split(';')[3]).Split(',')[1] == "0.0") ? "-" : (strdata.Split(';')[3]).Split(',')[1]; lblDateTwo_1.Text = ((strdata.Split(';')[3]).Split(',')[2] == "0.0") ? "-" : (strdata.Split(';')[3]).Split(',')[2]; lblDateTwo_2.Text = ((strdata.Split(';')[3]).Split(',')[3] == "0.0") ? "-" : (strdata.Split(';')[3]).Split(',')[3]; } } else { return; } string meal = (chkMealFlag.Checked == false) ? "0" : lblMealTime.Text; //lblOTTotalTime.Text = Convert.ToString(Convert.ToDouble(cntStart + cntEnd - Convert.ToDouble(meal)) / 60); txtTotalDescription.Text = (lblMealTime.Text != "" && Convert.ToDouble(lblMealTime.Text) > 0 && chkMealFlag.Checked == true) ? "(已扣除用餐時數" + lblMealTime.Text + "分鐘)" : ""; txtTotalDescription.Visible = true; }