Пример #1
0
        private DataTable FindPttBInPis(string PTTB_str)
        {
            OracleQuery2   cc2    = new OracleQuery2();
            DataTable      dt     = cc2.LoadMobileInPTTB(PTTB_str);
            SQLServerQuery ss     = new SQLServerQuery();
            string         result = "";

            foreach (DataRow r in dt.Rows)
            {
                result = result + r["CODE"].ToString() + ",";
            }
            result = result.TrimEnd(',');
            result = result.TrimStart(',');

            DataTable dt_pis = ss.LoadPosecodeINPIS(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["CODE"].ToString() equals table2["P_ID"].ToString()
                              select new
                {
                    code   = table1["CODE"].ToString(),
                    DEPART = table1["DEPARTMENT_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.code, item.name, item.unit, item.GROUP_ID);
                }
            }
            return(dtppl);
        }