protected void btnCheck_Click(object sender, EventArgs e)
 {
     lblAPIResultError.Text = "";
     hidAPIResult.Value     = "";
     if ((!string.IsNullOrEmpty(kddlFOPUNCHTYPE.SelectedValue) &&
          !string.IsNullOrEmpty(kdtpFOPUNCH_TIME.Text)) ||
         (!string.IsNullOrEmpty(kddlFOPUNCHTYPE_OFF.SelectedValue) &&
          !string.IsNullOrEmpty(kdtpFOPUNCH_TIME_OFF.Text)))
     {
         DataTable dtResult     = null;
         bool      resultStatus = false;
         hidAPIResult.Value = ""; // 清空之前的API查詢結果
         // 資料檢核
         DateTime dtAttend_START = DateTime.MinValue;
         DateTime.TryParse(kdtpFOPUNCH_TIME.Text, out dtAttend_START);   // 上班補卡時間
         DateTime dtAttend_OFF = DateTime.MinValue;
         DateTime.TryParse(kdtpFOPUNCH_TIME_OFF.Text, out dtAttend_OFF); // 下班補卡時間
         // 表頭
         JArray  jaTable  = new JArray();
         JObject _joTable = new JObject();
         _joTable.Add(new JProperty("USERNO", "1"));                                                                                   // 自訂序號
         _joTable.Add(new JProperty("SYS_VIEWID", ""));                                                                                // 編號
         _joTable.Add(new JProperty("SYS_DATE", DateTime.Parse(ktxtAPPLICANTDATE.Text).ToString("yyyyMMdd")));                         // 日期
         //_joTable.Add(new JProperty("TMP_EMPLOYEEID", hidAPPLICANTAccount.Value)); // 人員編號
         _joTable.Add(new JProperty("TMP_EMPLOYEEID", new KYT_UserPO().GetUserDetailByAccount(hidAPPLICANTAccount.Value).EmployeeNo)); // 人員編號
         _joTable.Add(new JProperty("TMP_DEPARTID", hidAPPLICANTDEPT_GROUPCODE.Value));                                                // 部門編號
         _joTable.Add(new JProperty("TMP_REASONID", kddlFOPUNCH_REASON.SelectedValue));                                                // 補卡原因
         _joTable.Add(new JProperty("ISAGREE", kchbox.Checked ? "1" : "0"));                                                           // 我已明確了解以下說明,並且同意遵守所有規定
         _joTable.Add(new JProperty("NOTE", ktxtREMARK.Text));                                                                         // 備註
         jaTable.Add(_joTable);
         DataTable dtHeadSource = JGlobalLibs.SQLUtils.jsonToTable(jaTable);
         dtHeadSource.TableName = SCSHRConfiguration.SCSSPunchProgID;
         // 表身 SUB
         //int sub_userno = 1;
         jaTable = new JArray();
         if (!string.IsNullOrEmpty(kddlFOPUNCHTYPE.SelectedValue))
         {
             _joTable = new JObject();
             _joTable.Add(new JProperty("USERNO", "1"));                                     // 自訂序號
             _joTable.Add(new JProperty("STATUS", kddlFOPUNCHTYPE.SelectedValue));           // 補刷卡狀態
             _joTable.Add(new JProperty("ATTENDDATE", dtAttend_START.ToString("yyyyMMdd"))); // 補刷卡日期
             _joTable.Add(new JProperty("ATTENDTIME", dtAttend_START.ToString("HHmm")));     // 補刷卡時間
             _joTable.Add(new JProperty("REASON", kddlFOPUNCH_REASON.SelectedValue));        // 補刷卡原因
             jaTable.Add(_joTable);
         }
         if (!string.IsNullOrEmpty(kddlFOPUNCHTYPE_OFF.SelectedValue))
         {
             _joTable = new JObject();
             _joTable.Add(new JProperty("USERNO", "1"));                                   // 自訂序號
             _joTable.Add(new JProperty("STATUS", kddlFOPUNCHTYPE_OFF.SelectedValue));     // 補刷卡狀態
             _joTable.Add(new JProperty("ATTENDDATE", dtAttend_OFF.ToString("yyyyMMdd"))); // 補刷卡日期
             _joTable.Add(new JProperty("ATTENDTIME", dtAttend_OFF.ToString("HHmm")));     // 補刷卡時間
             _joTable.Add(new JProperty("REASON", kddlFOPUNCH_REASON.SelectedValue));      // 補刷卡原因
             jaTable.Add(_joTable);
         }
         DataTable dtSubSource = JGlobalLibs.SQLUtils.jsonToTable(jaTable);
         dtSubSource.TableName = string.Format(@"{0}{1}", SCSHRConfiguration.SCSSPunchProgID, "SUB");
         // 建立DataSet
         DataSet dsSource = new DataSet(SCSHRConfiguration.SCSSPunchProgID);
         dsSource.Tables.Add(dtHeadSource);
         dsSource.Tables.Add(dtSubSource);
         DebugLog.Log(DebugLog.LogLevel.Info, string.Format("UC_KYTI_SCSHR_FOPUNCH::btnCheck_Click::BOImportWS::dsSource:{0}", JsonConvert.SerializeObject(dsSource)));
         Exception ex = null;
         dtResult = service.BOImport(SCSHRConfiguration.SCSSPunchProgID, true, SCSHR.net.azurewebsites.scsservices_beta.EFormFlowAction.Draft, true, dsSource, out ex);
         if (ex != null)
         {
             DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"UC_KYTI_SCSHR_FOPUNCH.btnCheck_Click.BOImport.ERROR:{0}", ex.Message));
         }
         DebugLog.Log(DebugLog.LogLevel.Info, string.Format("UC_KYTI_SCSHR_FOPUNCH::btnCheck_Click::BOImportWS::dtResult:{0}", JsonConvert.SerializeObject(dtResult)));
         if (dtResult != null &&
             dtResult.Rows.Count > 0)
         {
             resultStatus = dtResult.Rows[0]["_STATUS"].ToString() == "0";
             if (!resultStatus)
             {
                 lblAPIResultError.Text = dtResult.Rows[0]["_MESSAGE"].ToString();
             }
         }
         hidAPIResult.Value = string.IsNullOrEmpty(lblAPIResultError.Text) ? "OK" : lblAPIResultError.Text;
         // 為了滿足檢查完畢後需出現檢查成功
         lblAPIResultError.Text = string.IsNullOrEmpty(lblAPIResultError.Text) ? "檢查成功" : lblAPIResultError.Text;
     }
     else
     {
         lblAPIResultError.Text = "無法進行檢核";
     }
 }
Пример #2
0
    protected void btnRead_Click(object sender, EventArgs e)
    {
        ktxtMessage.Text       = "";
        ktxtAPPLICANTDEPT.Text = "";
        ktxtAPPLICANTDATE.Text = "";
        hidCompanyNo.Value     = "";
        hidGROUPCODE.Value     = "";
        ktxtLEAEMP.Text        = "";
        hidLEAEMP.Value        = "";
        ktxtLEAAGENT.Text      = "";
        hidLEAAGENT.Value      = "";
        ktxtLEACODE.Text       = "";
        hidLEACODE.Value       = "";
        ktxtSP_DATE.Text       = "";
        ktxtSP_NAME.Text       = "";
        kdtpSTARTTIME.Text     = "";
        kdtpENDTIME.Text       = "";
        ktxtLEAHOURS.Text      = "";
        ktxtLEADAYS.Text       = "";
        ktxtREMARK.Text        = "";
        if (!string.IsNullOrEmpty(ktxtDOC_NBR_Ori.Text))
        {
            Exception ex           = null; // 初始化
            bool      resultStatus = false;
            hidAPIResult.Value = "";       // 清空之前的API查詢結果
            DataTable dtOSource = getCurrentValue(ktxtDOC_NBR_Ori.Text);
            foreach (DataRow dr in dtOSource.Rows)
            {
                DateTime dtStart = DateTime.MinValue;
                DateTime.TryParse(dr["STARTTIME"].ToString(), out dtStart);
                DateTime dtEnd = DateTime.MinValue;
                DateTime.TryParse(dr["ENDTIME"].ToString(), out dtEnd);
                // 計為在途銷假單
                JArray  jaTable  = new JArray();
                JObject _joTable = new JObject();
                _joTable.Add(new JProperty("USERNO", "1"));
                _joTable.Add(new JProperty("SYS_VIEWID", ""));
                _joTable.Add(new JProperty("SYS_DATE", DateTime.Now.ToString("yyyyMMdd")));
                //_joTable.Add(new JProperty("TMP_EMPLOYEEID", JGlobalLibs.UOFUtils.getUserAccount(dr["LEAEMP"].ToString())));
                _joTable.Add(new JProperty("TMP_EMPLOYEEID", new KYT_UserPO().GetUserDetailByUserGuid(dr["LEAEMP"].ToString()).EmployeeNo));
                _joTable.Add(new JProperty("TMP_DEPARTID", dr["GROUP_CODE"].ToString()));
                _joTable.Add(new JProperty("TMP_LEAVEID", ktxtDOC_NBR_Ori.Text));
                _joTable.Add(new JProperty("STARTDATE", dtStart.ToString("yyyyMMdd")));
                _joTable.Add(new JProperty("STARTTIME", dtStart.ToString("HHmm")));
                _joTable.Add(new JProperty("ENDDATE", dtEnd.ToString("yyyyMMdd")));
                _joTable.Add(new JProperty("ENDTIME", dtEnd.ToString("HHmm")));
                _joTable.Add(new JProperty("REASON", ktxtCANCEL_REASON.Text));
                jaTable.Add(_joTable);
                DebugLog.Log(DebugLog.LogLevel.Info, string.Format(@"UC_KYTI_SCSHR_CLEAVE.btnRead_Click.jaTable:{0}", jaTable));
                DataTable dtSource = JGlobalLibs.SQLUtils.jsonToTable(jaTable);
                dtSource.TableName = SCSHRConfiguration.SCSSCLProgID;
                DataSet dsSource = new DataSet(SCSHRConfiguration.SCSSCLProgID);
                dsSource.Tables.Add(dtSource);
                DataTable dtResult = service.BOImport(SCSHRConfiguration.SCSSCLProgID, true, SCSHR.net.azurewebsites.scsservices_beta.EFormFlowAction.Draft, true, dsSource, out ex);
                DebugLog.Log(DebugLog.LogLevel.Info, string.Format(@"UC_KYTI_SCSHR_CLEAVE.btnRead_Click.dtResult:{0}", Newtonsoft.Json.JsonConvert.SerializeObject(dtResult)));

                if (ex != null)
                {
                    ktxtMessage.Text = ex.Message;
                    DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"UC_KYTI_SCSHR_CLEAVE.btnRead_Click.BOImport.ERROR:{0}", ex.Message));
                    DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"UC_KYTI_SCSHR_CLEAVE::btnRead_Click::BOImportWS::StackTrace::{0}::ERROR::{1}", ex.StackTrace, ex.Message));
                }
                if (dtResult != null &&
                    dtResult.Rows.Count > 0)
                {
                    resultStatus = dtResult.Rows[0]["_STATUS"].ToString() == "0";
                    if (!resultStatus)
                    {
                        ktxtMessage.Text   = dtResult.Rows[0]["_MESSAGE"].ToString();
                        hidAPIResult.Value = ktxtMessage.Text;
                    }
                }

                if (resultStatus)
                {
                    hidAPIResult.Value = "OK";

                    ktxtMessage.Text       = "";
                    ktxtAPPLICANTDEPT.Text = dr["GROUP_NAME"].ToString();
                    ktxtAPPLICANTDATE.Text = dr["APPLICANTDATE"].ToString();
                    hidCompanyNo.Value     = dr["APPLICANTCOMP"].ToString();
                    hidGROUPCODE.Value     = dr["GROUP_CODE"].ToString();
                    ktxtLEAEMP.Text        = dr["LEAEMP_NAME"].ToString();
                    hidLEAEMP.Value        = dr["LEAEMP"].ToString();
                    ktxtLEAAGENT.Text      = dr["LEAAGENT_NAME"].ToString();
                    hidLEAAGENT.Value      = dr["LEAAGENT"].ToString();
                    ktxtLEACODE.Text       = dr["LEACODENAME"].ToString();
                    hidLEACODE.Value       = dr["LEACODE"].ToString();
                    ktxtSP_DATE.Text       = dr["SP_DATE"].ToString();
                    ktxtSP_NAME.Text       = dr["SP_NAME"].ToString();
                    kdtpSTARTTIME.Text     = dr["STARTTIME"].ToString();
                    kdtpENDTIME.Text       = dr["ENDTIME"].ToString();
                    ktxtLEAHOURS.Text      = dr["LEAHOURS"].ToString();
                    ktxtLEADAYS.Text       = dr["LEADAYS"].ToString();
                    ktxtREMARK.Text        = dr["REMARK"].ToString();
                }
                ktxtMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
    }