protected void SndFinal_Click(object sender, EventArgs e) { updateProgress.Visible = true; grpPanel.Visible = false; DetailPanel.Visible = false; PreviewPanel.Visible = false; PreviewSendPanel.Visible = false; DataTable dataTable = ViewState["GroupList"] as DataTable; if (dataTable != null && dataTable.Rows.Count > 0) { DataTable PTTB = dataTable.Select("Department_ID =100").Count() > 0 ? dataTable.Select("Department_ID =100").CopyToDataTable() : null; DataTable PTT = dataTable.Select("Department_ID =200").Count() > 0 ? dataTable.Select("Department_ID =200").CopyToDataTable() : null; DataTable GC = dataTable.Select("Department_ID =300").Count() > 0 ? dataTable.Select("Department_ID =300").CopyToDataTable() : null; DataTable CS = dataTable.Select("Department_ID =400").Count() > 0 ? dataTable.Select("Department_ID =400").CopyToDataTable() : null; DataTable TCS = dataTable.Select("Department_ID =500").Count() > 0 ? dataTable.Select("Department_ID =500").CopyToDataTable() : null; DataTable TEST = dataTable.Select("Department_ID =600").Count() > 0 ? dataTable.Select("Department_ID =600").CopyToDataTable() : null; string PTTB_str, PTT_str, GC_str, CS_str, TCS_str, TEST_str = ""; PTTB_str = PTTB == null ? "" : getListStringGroup(PTTB); PTT_str = PTT == null ? "" : getListStringGroup(PTT); GC_str = GC == null ? "" : getListStringGroup(GC); CS_str = CS == null ? "" : getListStringGroup(CS); TCS_str = TCS == null ? "" : getListStringGroup(TCS); TEST_str = TEST == null ? "" : getListStringGroup(TEST); DataTable Result_Dt = new DataTable(); OracleQuery cc = new OracleQuery(); OracleQuery2 cc2 = new OracleQuery2(); Result_Dt.Columns.Add("MOBILE", typeof(string)); Result_Dt.Columns.Add("DEPARTMENT_ID", typeof(string)); Result_Dt.Columns.Add("EMPLOYEE_ID", typeof(string)); Result_Dt.Columns.Add("NAME", typeof(string)); Result_Dt.Columns.Add("COMPANY", typeof(string)); Result_Dt.Columns.Add("GROUP_ID", typeof(string)); //Result_Dt.Rows.Add(); if (PTTB_str != "") { Result_Dt.Merge(FindPttBInPis(PTTB_str)); } if (PTT_str != "") { Result_Dt.Merge(FindPttInPis(PTT_str)); } if (GC_str != "") { Result_Dt.Merge(cc2.LoadMobileInGC(GC_str)); } if (CS_str != "") { Result_Dt.Merge(cc2.LoadMobileInCS(CS_str)); } if (TCS_str != "") { Result_Dt.Merge(cc2.LoadMobileInTCS(TCS_str)); } if (TEST_str != "") { Result_Dt.Merge(cc2.LoadMobileInTest(TEST_str)); } DataTable output = Result_Dt.Rows.Count > 0 ? Result_Dt.Copy() : null; DataView dv = new DataView(output); dv.Sort = "MOBILE"; DataTable output2 = dv.ToTable(); DataTable newDataTable = new DataTable(); newDataTable.Columns.Add("MOBILE", typeof(string)); newDataTable.Columns.Add("DEPARTMENT_ID", typeof(string)); newDataTable.Columns.Add("EMPLOYEE_ID", typeof(string)); newDataTable.Columns.Add("NAME", typeof(string)); newDataTable.Columns.Add("COMPANY", typeof(string)); newDataTable.Columns.Add("GROUP_ID", typeof(string)); var dis = output.AsEnumerable().Select(row => new { MOBILE = row.Field <string>("MOBILE"), DEPARTMENT_ID = row.Field <string>("DEPARTMENT_ID"), EMPLOYEE_ID = row.Field <string>("EMPLOYEE_ID"), NAME = row.Field <string>("NAME"), COMPANY = row.Field <string>("COMPANY"), GROUP_ID = row.Field <string>("GROUP_ID") }).GroupBy(x => x.MOBILE).Select(x => x.FirstOrDefault()); foreach (var array in dis) { newDataTable.Rows.Add(array.MOBILE, array.DEPARTMENT_ID, array.EMPLOYEE_ID, array.NAME, array.COMPANY, array.GROUP_ID); } //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "notext", "alert('"+ output.Rows.Count +","+ dis.Count() + "')", true); SendSMS ss = new SendSMS(); string resultsent = ""; string smsText = MSGTEXT.Text;//SetSMSText(); if (smsText == null) { ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "notext", "alert('No Text Message')", true); } else if (dis == null) { ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "notext", "alert('No Recipient')", true); } else { //DataView view = new DataView(dis); //dis = dis.ToTable(true); string loginName = Session["ID"].ToString(); string sendername = ""; if (SenderCheck.Checked) { sendername = "From GasControl"; } else { sendername = ""; } resultsent = ss.sendSMS_webPost(newDataTable, smsText, sendername, loginName); if (resultsent == "1") { ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "notext", "alert('Success')", true); } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "notext", "alert('" + resultsent + "')", true); } } return; } ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "notext", "alert('No Recipient')", true); }