public void BindPPLDetail(string group_id, int level) { groupLabel.Text = group_id; LevelLabel.Text = level.ToString(); OracleQuery2 cc2 = new OracleQuery2(); SQLServerQuery ss = new SQLServerQuery(); DataTable dt = cc2.LoadPTTPPL(group_id); string result = ""; foreach (DataRow r in dt.Rows) { result = result + r["EMPLOYEE_ID"].ToString() + ","; } result = result.TrimEnd(','); DataTable dt_pis = ss.LoadINPIS("", result); DataTable dtppl = new DataTable(); dtppl.Columns.Add("EMPLOYEE_ID"); dtppl.Columns.Add("NAME"); dtppl.Columns.Add("POSITION"); dtppl.Columns.Add("COMPANY"); dtppl.Columns.Add("MOBILE"); dtppl.Columns.Add("GROUP_KEY"); if (dt != null && dt_pis != null && dt.Rows.Count > 0 && dt_pis.Rows.Count > 0) { var results = from table1 in dt.AsEnumerable() join table2 in dt_pis.AsEnumerable() on table1["EMPLOYEE_ID"].ToString() equals table2["P_ID"].ToString() select new { EMPLOYEE_ID = table1["EMPLOYEE_ID"].ToString(), FULLNAMETH = table2["FULLNAMETH"].ToString(), POSNAME = table2["POSNAME"].ToString(), unitname = table2["unitname"].ToString(), mobile = !string.IsNullOrEmpty(table2["mobile"].ToString()) ? table2["mobile"].ToString() : table1["mobile"].ToString() }; foreach (var item in results) { dtppl.Rows.Add(item.EMPLOYEE_ID, item.FULLNAMETH, item.POSNAME, item.unitname, item.mobile, 200); } } ViewState["CurrentPTTPPL"] = dtppl; if (dtppl.Rows.Count > 0) { Grid_ppl.DataSource = dtppl; Grid_ppl.DataBind(); PPL_PANEL.Visible = true; } else { Grid_ppl.DataSource = null; Grid_ppl.DataBind(); PPL_PANEL.Visible = false; } }
public void BindPPLDetail() { SchPPL.Text = ""; OracleQuery2 cc2 = new OracleQuery2(); SQLServerQuery ss = new SQLServerQuery(); DataTable dt = cc2.LoadPTTPPL(); string result = ""; foreach (DataRow r in dt.Rows) { result = result + r["EMPLOYEE_ID"].ToString() + ","; } result = result.TrimEnd(','); DataTable dt_pis = ss.LoadINPIS("", result); DataTable dtppl = new DataTable(); dtppl.Columns.Add("EMPLOYEE_ID"); dtppl.Columns.Add("NAME"); dtppl.Columns.Add("POSITION"); dtppl.Columns.Add("COMPANY"); dtppl.Columns.Add("UNITCODE"); dtppl.Columns.Add("MOBILE"); dtppl.Columns.Add("LASTUPDATE", typeof(DateTime)); dtppl.Columns.Add("UPDATE_BY"); dtppl.Columns.Add("Keyword"); dtppl.Columns.Add("GROUP_KEY"); dtppl.Columns.Add("MOBILE_FM"); dtppl.Columns.Add("STATUS"); if (dt != null && dt_pis != null && dt.Rows.Count > 0 && dt_pis.Rows.Count > 0) { var results = from table1 in dt.AsEnumerable() join table2 in dt_pis.AsEnumerable() on table1["EMPLOYEE_ID"].ToString() equals table2["P_ID"].ToString() select new { EMPLOYEE_ID = table1["EMPLOYEE_ID"].ToString(), FULLNAMETH = table2["FULLNAMETH"].ToString(), POSNAME = table2["POSNAME"].ToString(), unitname = table2["unitname"].ToString(), unitcode = table2["UNITCODE"].ToString(), lastupdate = table1["LASTUPDATE"], updateby = table1["UPDATE_BY"].ToString(), keyword = table1["EMPLOYEE_ID"].ToString() + " " + table2["FULLNAMETH"].ToString() + " " + table2["POSNAME"].ToString() + " " + table2["unitname"].ToString(), mobile = !string.IsNullOrEmpty(table2["mobile"].ToString()) ? table2["mobile"].ToString() : table1["mobile"].ToString(), MOBILE_FM = string.IsNullOrEmpty(table2["mobile"].ToString()) ?1:0, STATUS = table1["STATUS"].ToString(), }; foreach (var item in results) { dtppl.Rows.Add(item.EMPLOYEE_ID, item.FULLNAMETH, item.POSNAME, item.unitname, item.unitcode, item.mobile, item.lastupdate, item.updateby, item.keyword, 200, item.MOBILE_FM, item.STATUS); } } // dtppl = findPTTPerson(dtppl, group_id); ViewState["CurrentPTTEditPPL"] = dtppl; ViewState["ALLPPL"] = dtppl; if (dtppl.Rows.Count > 0) { Grid_ppl.DataSource = dtppl; Grid_ppl.DataBind(); PPL_PANEL.Visible = true; } else { Grid_ppl.DataSource = null; Grid_ppl.DataBind(); PPL_PANEL.Visible = false; } }