public void ChangeSim4G_1(SerialPort sp, int i, DataGridView DTGV_Thongtin, string Seri, Dictionary recport, DataGridView DTGV_4G, int j) { try { Regex r = new Regex("\\d{9,11}"); Regex r1 = new Regex(",\"([\\s\\S]*?)\","); new Thread(delegate { try { bool flag = !sp.IsOpen; if (flag) { sp.Open(); } DTGV_Thongtin.Rows[i].Cells[3].Value = "Đang thực hiện"; recport[sp.PortName] = ""; sp.Write("AT+CUSD=1,*098*4# \r"); Thread.Sleep(5000); sp.Write("AT+CUSD=1,2 \r"); Thread.Sleep(5000); sp.Write("AT+CUSD=1," + Seri + "\r"); Thread.Sleep(5000); sp.Write("AT+CUSD=1," + Seri + "\r"); Thread.Sleep(5000); sp.Write("AT+CUSD=1,1 \r"); Thread.Sleep(5000); bool flag2 = recport[sp.PortName].Contains("Quy khach dang su dung sim 4G cua Viettel"); if (flag2) { this.Dtgv_Change4G.Rows[i].Cells[2].Value = "Thành công"; DTGV_Thongtin.Rows[i].Cells[4].Value = r1.Match(recport[sp.PortName]).Groups[1].Value; } else { this.Dtgv_Change4G.Rows[i].Cells[2].Value = "Thất bại"; DTGV_Thongtin.Rows[i].Cells[4].Value = " Vui lòng thử lại"; } } catch { } }) { IsBackground = true }.Start(); } catch { } }