private void RefreshMainData(string EMPID, string LEVCODE, string LEVNAME, string LEVDATE_START, string LEVDATE_END, string IS_SPEC) { Exception ex = null; SCSHR.net.azurewebsites.scsservices_beta.Parameter[] parameters = service.BOExecFunc(SCSHRConfiguration.SCSSLeaveProgID, string.IsNullOrEmpty(IS_SPEC) ? "CheckLeaveLRData" : "GetLeaveSpecInfo", SCSHR.Types.SCSParameter.getPatameters(new { TMP_EmployeeID = EMPID, Tmp_svacationID = LEVCODE, StartDate = LEVDATE_START, EndDate = LEVDATE_END }), out ex); if (ex != null) { DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"listLEAVE_TIMES.RefreshMainData.CheckLeaveLRData.ERROR:{0}", ex.Message)); } if (parameters != null && parameters.Length > 0) { DebugLog.Log(DebugLog.LogLevel.Info, string.Format(@"listLEAVE_TIMES.RefreshMainData.CheckLeaveLRData.result:{0}", Newtonsoft.Json.JsonConvert.SerializeObject(parameters))); if (parameters[0].DataType.ToString() == "DataTable") { DataTable dtSource = SCSHRUtils.XmlToDataTable(parameters[0].Xml); dtSource.Columns.Add("LEVNAME", typeof(string)); foreach (DataRow dr in dtSource.Rows) { dr["LEVNAME"] = LEVNAME; } gvMain.DataSource = dtSource; gvMain.DataBind(); } } }
/// <summary> /// 按下查詢按鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSearch_Click(object sender, EventArgs e) { if (kdtpSTARTTIME.SelectedDate == null || kdtpENDTIME.SelectedDate == null || string.IsNullOrEmpty(lblAccount.Text)) { gvItems.DataSource = CreateGvitem(); gvItems.DataBind(); return; } string accounts = lblAccount.Text; Exception ex = null; // 初始化 DataTable dtResult = null; SCSHR.net.azurewebsites.scsservices_beta.Parameter[] parameters = service.BOExecFunc( "WATT0021502", "GetAttSwipeDataAmendQueryData", SCSHR.Types.SCSParameter.getPatameters(new { StartDate = ((DateTime)kdtpSTARTTIME.SelectedDate).ToString("yyyyMMdd"), EndDate = ((DateTime)kdtpENDTIME.SelectedDate).ToString("yyyyMMdd"), EmployeeID = accounts }), out ex); //JGlobalLibs.DebugLog.Log(string.Format(@"WB_KYTI_SCSHR_PUNCH_REPORT.btnSearch_Click.BOExecFunc::{0}::Send::{1}", "WATT0021502", ((DateTime)kdtpSTARTTIME.SelectedDate).ToString("yyyyMMdd") + " , " + ((DateTime)kdtpENDTIME.SelectedDate).ToString("yyyyMMdd") + " , " + accounts)); //JGlobalLibs.DebugLog.Log(string.Format(@"WB_KYTI_SCSHR_PUNCH_REPORT.btnSearch_Click.BOExecFunc::{0}::Result::{1}", "WATT0021502", Newtonsoft.Json.JsonConvert.SerializeObject(parameters))); if (ex != null) { JGlobalLibs.DebugLog.Log(string.Format(@"WB_KYTI_SCSHR_PUNCH_REPORT.btnSearch_Click.BOExecFunc.ERROR:{0}", ex.Message)); } if (parameters != null && parameters.Length > 0) { if (parameters[0].DataType.ToString() == "DataTable") { //DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"UC_KYTI_SCSHR_LEAVE.btnCal_Click.BOExecFunc.Result.XML:{0}", parameters[0].Xml)); dtResult = SCSHRUtils.XmlToDataTable(parameters[0].Xml); } } DataTable dt = new DataTable(); foreach (DataColumn dc in dtResult.Columns) { dt.Columns.Add(new DataColumn(dc.ColumnName, typeof(String))); } for (int i = 0; i < dtResult.Rows.Count; i++) { DataRow dr = dtResult.Rows[i]; DataRow row = dt.NewRow(); foreach (DataColumn dc in dtResult.Columns) { row[dc.ColumnName] = dr[dc.ColumnName]; if (dc.DataType == typeof(DateTime) && dc.ColumnName.Length >= 4) { string title = string.Format("{0}TIME", dc.ColumnName.Substring(0, dc.ColumnName.Length - 4)); string date = row[dc.ColumnName].ToString(); if (dtResult.Columns.Contains(title)) { string time = dr[title].ToString(); row[dc.ColumnName] = string.Format("{0} {1}", date.Length > 10 ? date.Substring(0, 10) : date, time.Length >= 3 ? time.Insert(2, "") : time); } else { row[dc.ColumnName] = date.Length > 10 ? date.Substring(0, 10) : date; } } } dt.Rows.Add(row); } if (dtResult != null) { DataView dv = new DataView(dt); dv.Sort = "TMP_EMPLOYEEID, SWIPEDATE"; ViewState["gvitems"] = dv.ToTable(); gvItems.DataSource = dv; gvItems.DataBind(); ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), "LimitHeight()", true); return; } ViewState["gvitems"] = dtResult; gvItems.DataSource = dtResult; gvItems.DataBind(); }
/// <summary> /// 按下查詢按鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSearch_Click(object sender, EventArgs e) { //if (kdtpSTARTTIME.SelectedDate == null || kdtpENDTIME.SelectedDate == null || string.IsNullOrEmpty(lblAccount.Text)) //{ // gvItems.DataSource = CreateGvitem(); // gvItems.DataBind(); // return; //} //string accounts = lblAccount.Text; //UserSet US = UC_ChoiceListMobile.UserSet; //if (US.GetAllUsers().Rows.Count > 0) //{ // accounts = ""; // foreach (DataRow dr in US.GetAllUsers().Rows) // { // EBUser user = new UserUCO().GetEBUser(dr["USER_GUID"].ToString()); // if (!string.IsNullOrEmpty(accounts)) accounts += ";"; // accounts += user.Account; // } //} Exception ex = null; // 初始化 DataTable dtResult = null; SCSHR.net.azurewebsites.scsservices_beta.Parameter[] parameters = service.BOExecFunc( "ATT0021700", "GetAttendData_Web", SCSHR.Types.SCSParameter.getPatameters(new { StartDate = "20211201", EndDate = "20211231", CalcCHours = "0", ShowAbnormal = "0", EmployeeID = "160115" }), out ex); //正確查詢 //SCSHR.net.azurewebsites.scsservices_beta.Parameter[] parameters = service.BOExecFunc( //"ATT0021700", //"GetAttendData_Web", //SCSHR.Types.SCSParameter.getPatameters(new //{ // StartDate = ((DateTime)kdtpSTARTTIME.SelectedDate).ToString("yyyyMMdd"), // EndDate = ((DateTime)kdtpENDTIME.SelectedDate).ToString("yyyyMMdd"), // CalcCHours = ddlHours.SelectedValue, // ShowAbnormal = ddlAbnorma.SelectedValue, // EmployeeID = accounts //}), //out ex); //JGlobalLibs.DebugLog.Log(string.Format(@"WB_KYTI_SCSHR_DUTY_REPORT.btnSearch_Click.BOExecFunc::{0}::Send::{1}", "ATT0021700", ((DateTime)kdtpSTARTTIME.SelectedDate).ToString("yyyyMMdd") + " , " + ((DateTime)kdtpENDTIME.SelectedDate).ToString("yyyyMMdd") + " , " + ddlHours.SelectedValue + " , " + ddlAbnorma.SelectedValue + " , " + accounts)); //JGlobalLibs.DebugLog.Log(string.Format(@"WB_KYTI_SCSHR_DUTY_REPORT.btnSearch_Click.BOExecFunc::{0}::Result::{1}", "ATT0021700", Newtonsoft.Json.JsonConvert.SerializeObject(parameters))); if (ex != null) { JGlobalLibs.DebugLog.Log(string.Format(@"WB_KYTI_SCSHR_DUTY_REPORT.btnSearch_Click.BOExecFunc.ERROR:{0}", ex.Message)); } if (parameters != null && parameters.Length > 0) { if (parameters[0].DataType.ToString() == "DataTable") { //DebugLog.Log(DebugLog.LogLevel.Error, string.Format(@"UC_KYTI_SCSHR_LEAVE.btnCal_Click.BOExecFunc.Result.XML:{0}", parameters[0].Xml)); dtResult = SCSHRUtils.XmlToDataTable(parameters[0].Xml); } } DataTable dt = new DataTable(); foreach (DataColumn dc in dtResult.Columns) { dt.Columns.Add(new DataColumn(dc.ColumnName, typeof(String))); } for (int i = 0; i < dtResult.Rows.Count; i++) { DataRow dr = dtResult.Rows[i]; DataRow row = dt.NewRow(); foreach (DataColumn dc in dtResult.Columns) { row[dc.ColumnName] = dr[dc.ColumnName]; if (dc.DataType == typeof(DateTime) && dc.ColumnName.Length >= 4) { string title = string.Format("{0}TIME", dc.ColumnName.Substring(0, dc.ColumnName.Length - 4)); string date = row[dc.ColumnName].ToString(); if (dtResult.Columns.Contains(title)) { string time = dr[title].ToString(); row[dc.ColumnName] = string.Format("{0} {1}", date.Length > 10 ? date.Substring(0, 10) : date, time.Length >= 3 ? time.Insert(2, ":") : time); } else { row[dc.ColumnName] = date.Length > 10 ? date.Substring(0, 10) : date; } } } dt.Rows.Add(row); } if (dtResult != null) { DataView dv = new DataView(dt); dv.Sort = "EMPLOYEEVIEWID"; ViewState["gvitems"] = dv.ToTable(); gvItems.DataSource = dv; gvItems.DataBind(); ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), "SetGvItems()", true); return; } ViewState["gvitems"] = dtResult; gvItems.DataSource = dtResult; gvItems.DataBind(); }