protected void btnFix_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtDOC_NBR.Text.Trim())) { KYTJsonDict dict = null; JObject joInnerText = null; string TASK_ID = ""; using (SqlDataAdapter sda = new SqlDataAdapter(@" SELECT TOP 1 * FROM TB_WKF_TASK WHERE DOC_NBR = @DOC_NBR ", new DatabaseHelper().Command.Connection.ConnectionString)) using (DataSet ds = new DataSet()) { sda.SelectCommand.Parameters.AddWithValue("@DOC_NBR", txtDOC_NBR.Text.Trim()); try { if (sda.Fill(ds) > 0) { DataRow dr = ds.Tables[0].Rows[0]; XmlDocument doc = new XmlDocument(); doc.LoadXml(dr["CURRENT_DOC"].ToString()); XmlNode node = doc.SelectSingleNode("//Form/FormFieldValue/FieldItem[@fieldId='KYTI_SCSHR_TRAVEL']"); // 取出外掛欄位資料 dict = JsonConvert.DeserializeObject <KYTJsonDict>(HttpUtility.HtmlDecode(node.InnerText)); joInnerText = JObject.Parse(HttpUtility.HtmlDecode(node.InnerText)); TASK_ID = dr["TASK_ID"].ToString(); } } catch (Exception ex) { string message = string.Format(@"Temp_FixTravelTBY.btnFix_Click.TB_WKF_TASK.SELECT.ERROR:{0}", ex.Message); DebugLog.Log(DebugLog.LogLevel.Error, message); } DataTable _dtPLs = dict.GetDataTable("gvPLs"); foreach (DataRow dr in _dtPLs.Rows) { dr["TBY"] = "高鐵"; } if (joInnerText != null) { using (MemoryStream ms = new MemoryStream()) { BinaryFormatter formatter = new BinaryFormatter(); try { formatter.Serialize(ms, _dtPLs); joInnerText["gvPLs"]["FieldValue"] = Convert.ToBase64String(ms.ToArray()); } catch (Exception ex) { DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"Temp_FixTravelTBY.btnFix_Click.MemoryStream.Serialize._dtPLs.ERROR:{0}", ex.Message)); } } } JGlobalLibs.UOFUtils.ReplaceDocumentContent(TASK_ID, "KYTI_SCSHR_TRAVEL", JsonConvert.SerializeObject(joInnerText)); } } }
private DataTable getDetailData(string DOC_NBR) { DataTable dtReturn = new DataTable(); KYTJsonDict dict = null; bool isRightField = false; using (SqlDataAdapter sda = new SqlDataAdapter(@" SELECT * FROM TB_WKF_TASK WHERE DOC_NBR = @DOC_NBR ", ConnectionString)) using (DataSet ds = new DataSet()) { sda.SelectCommand.Parameters.AddWithValue("@DOC_NBR", DOC_NBR); try { if (sda.Fill(ds) > 0) { DataRow dr = ds.Tables[0].Rows[0]; XmlDocument doc = new XmlDocument(); doc.LoadXml(dr["CURRENT_DOC"].ToString()); XmlNode node = doc.SelectSingleNode("//Form/FormFieldValue/FieldItem[@fieldId='KYTI_SCSHR_OVERTIME_BATCH']"); // 取出外掛欄位資料 isRightField = node != null; if (isRightField) { dict = JsonConvert.DeserializeObject <KYTJsonDict>(HttpUtility.HtmlDecode(node.InnerText)); } } } catch (Exception ex) { DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"WEB_KYTI_SCSHR_OVERTIME_BATCH_ERR_FIX.getDetailData.TB_WKF_TASK.ERROR:{0}", ex.Message)); } if (isRightField) { dtReturn = dict.GetDataTable("gvOVs"); dtReturn.Columns.Add(new DataColumn("SUB_DOC_NBR", typeof(string))); dtReturn.Columns.Add(new DataColumn("ZTABLE_STATUS", typeof(string))); dtReturn.Columns.Add(new DataColumn("WS_STATUS", typeof(string))); for (int i = 0; i < dtReturn.Rows.Count; i++) { DataRow dr = dtReturn.Rows[i]; dr["SUB_DOC_NBR"] = DOC_NBR + (i + 1).ToString("00"); } } } return(dtReturn); }
protected void gvLVH_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { GridViewRow gr = e.Row; if (gr.RowType == DataControlRowType.DataRow) { KYTJsonDict dict = null; DataRowView row = (DataRowView)e.Row.DataItem; Label lblZTABLE_STATUS = gr.FindControl("lblZTABLE_STATUS") as Label; Label lblWS_STATUS = gr.FindControl("lblWS_STATUS") as Label; Label lblDOC_NBR = gr.FindControl("lblDOC_NBR") as Label; Label lblLEAEMP = gr.FindControl("lblLEAEMP") as Label; Label lblAPPLICANTDATE = gr.FindControl("lblAPPLICANTDATE") as Label; Label lblLEAAGENT = gr.FindControl("lblLEAAGENT") as Label; Label lblLEACODE = gr.FindControl("lblLEACODE") as Label; Label lblLEACODENAME = gr.FindControl("lblLEACODENAME") as Label; Label lblSTARTTIME = gr.FindControl("lblSTARTTIME") as Label; Label lblENDTIME = gr.FindControl("lblENDTIME") as Label; Label lblLEAHOURS = gr.FindControl("lblLEAHOURS") as Label; Label lblLEADAYS = gr.FindControl("lblLEADAYS") as Label; bool isRightField = false; string DOC_NBR = row["DOC_NBR"].ToString(); using (SqlDataAdapter sda = new SqlDataAdapter(@" SELECT TOP 1 * FROM TB_WKF_TASK WHERE DOC_NBR = @DOC_NBR ", new DatabaseHelper().Command.Connection.ConnectionString)) using (DataSet ds = new DataSet()) { sda.SelectCommand.Parameters.AddWithValue("@DOC_NBR", DOC_NBR); try { if (sda.Fill(ds) > 0) { DataRow dr = ds.Tables[0].Rows[0]; XmlDocument doc = new XmlDocument(); doc.LoadXml(dr["CURRENT_DOC"].ToString()); XmlNode node = doc.SelectSingleNode("//Form/FormFieldValue/FieldItem[@fieldId='" + Field_ID + "']"); // 取出外掛欄位資料 isRightField = node != null; if (isRightField) { dict = JsonConvert.DeserializeObject <KYTJsonDict>(HttpUtility.HtmlDecode(node.InnerText)); } } } catch (Exception ex) { DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"WEB_KYTI_SCSHR_LEAVE_ERR_FIX.gvLVH_RowDataBound.TB_WKF_TASK.SELECT.ERROR:{0}", ex.Message)); } } if (isRightField) { string ZTABLE_STATUS = ReBuildSCSHRForm.CheckZTableHasData(DOC_NBR, Field_ID); string WS_STATUS = ReBuildSCSHRForm.CheckWSHasData(DOC_NBR, Field_ID); lblZTABLE_STATUS.Text = !string.IsNullOrEmpty(ZTABLE_STATUS) ? ZTABLE_STATUS == "0" ? "O" : "X" : "?"; lblZTABLE_STATUS.ForeColor = !string.IsNullOrEmpty(ZTABLE_STATUS) ? ZTABLE_STATUS == "0" ? Color.Green : Color.Red : Color.Yellow; lblWS_STATUS.Text = !string.IsNullOrEmpty(WS_STATUS) ? WS_STATUS == "0" ? "O" : "X" : "?"; lblWS_STATUS.ForeColor = !string.IsNullOrEmpty(WS_STATUS) ? WS_STATUS == "0" ? Color.Green : Color.Red : Color.Yellow; lblLEACODENAME.Text = ReBuildSCSHRForm.FindDropDownListText(dict.GetDataTable("kddlLEACODE"), dict.GetString("kddlLEACODE").ToString()); lblSTARTTIME.Text = (string)dict.GetString("kdtpSTARTTIME"); lblENDTIME.Text = (string)dict.GetString("kdtpENDTIME"); lblLEAEMP.Text = (string)dict.GetString("ktxtLEAEMP"); lblAPPLICANTDATE.Text = (string)dict.GetString("ktxtAPPLICANTDATE"); lblLEAAGENT.Text = (string)dict.GetString("ktxtLEAAGENT"); lblLEACODE.Text = (string)dict.GetString("kddlLEACODE"); lblLEAHOURS.Text = (string)dict.GetString("ktxtLEAHOURS"); lblLEADAYS.Text = (string)dict.GetString("ktxtLEADAYS"); } } }