예제 #1
0
        private DataTable FindPttInPis(string PTT_str)
        {
            OracleQuery2   cc2    = new OracleQuery2();
            DataTable      dt     = cc2.LoadMobileInPTT(PTT_str);
            SQLServerQuery ss     = new SQLServerQuery();
            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("MOBILE");
            dtppl.Columns.Add("DEPARTMENT_ID");
            dtppl.Columns.Add("EMPLOYEE_ID");
            dtppl.Columns.Add("NAME");
            dtppl.Columns.Add("COMPANY");
            dtppl.Columns.Add("GROUP_ID");
            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
                {
                    DEPART = table1["DEPARTMENT_ID"].ToString(),

                    EMPLOYEE_ID = table1["EMPLOYEE_ID"].ToString(),
                    mobile      = !string.IsNullOrEmpty(table1["mobile"].ToString()) ? table1["mobile"].ToString() : table2["mobile"].ToString(),
                    name        = table2["FULLNAMETH"].ToString(),
                    unit        = table2["unitname"].ToString(),
                    GROUP_ID    = table1["GROUP_ID"].ToString(),
                };

                foreach (var item in results)
                {
                    dtppl.Rows.Add(item.mobile, item.DEPART, item.EMPLOYEE_ID, item.name, item.unit, item.GROUP_ID);
                }
            }
            return(dtppl);
        }