public static bool insertHopThuDi(HopThuDiMODEL hopThuDiModel) { try { SqlParameter[] parameter = new SqlParameter[9]; int i = 0; parameter[i] = new SqlParameter("So_dien_thoai", SqlDbType.VarChar); parameter[i++].Value = hopThuDiModel.So_Dien_Thoai; parameter[i] = new SqlParameter("Noi_dung_tin_nhan", SqlDbType.NVarChar); parameter[i++].Value = hopThuDiModel.Noi_Dung_Tin_Nhan; parameter[i] = new SqlParameter("Tinh_trang", SqlDbType.Int); parameter[i++].Value = hopThuDiModel.Tinh_Trang; parameter[i] = new SqlParameter("Loai_hop_thu", SqlDbType.Int); parameter[i++].Value = hopThuDiModel.Loai_Hop_Thu; parameter[i] = new SqlParameter("User1", SqlDbType.VarChar); parameter[i++].Value = hopThuDiModel.User11; parameter[i] = new SqlParameter("User2", SqlDbType.VarChar); parameter[i++].Value = hopThuDiModel.User21; parameter[i] = new SqlParameter("User3", SqlDbType.VarChar); parameter[i++].Value = hopThuDiModel.User31; parameter[i] = new SqlParameter("User4", SqlDbType.VarChar); parameter[i++].Value = hopThuDiModel.User41; parameter[i] = new SqlParameter("User5", SqlDbType.VarChar); parameter[i++].Value = hopThuDiModel.User51; Boolean kq = DataUtil.executeNonStore("sp_ISO_SMS_insertMessSent", parameter); return(kq); } catch (Exception) { throw; } }
//private delegate void SetTextCallback(string text); private void but_Send_Click(object sender, EventArgs e) { SmsSubmitPdu[] desPhones; ArrayList listPdu = new ArrayList(); SmsSubmitPdu pdu; string[] phones = (txtPhoneNumber.Text).Split(';'); string mess = txtMessage.Text; bool unicode = chkUnicode.Checked; if (!txtPhoneNumber.Text.Equals("") && !mess.Equals("")) { Cursor.Current = Cursors.WaitCursor; if (phones.Length == 1) { model = new HopThuDiMODEL(); int testTV = 0; if (!unicode) { pdu = new SmsSubmitPdu(); try { pdu.UserDataText = mess; pdu.DestinationAddress = phones[0]; pdu.SmscAddress = ""; testTV = 1; } catch (Exception) { txtLog.AppendText("Ban phai check vao Tieng Viet de gui tin nhan co dau .\n"); testTV = 0; } } else { byte dcs = DataCodingScheme.NoClass_16Bit; pdu = new SmsSubmitPdu(txtMessage.Text, phones[0], "", dcs); testTV = 1; } model.So_Dien_Thoai = phones[0]; model.Noi_Dung_Tin_Nhan = mess; model.Loai_Hop_Thu = "6"; model.User11 = ""; model.User21 = ""; model.User31 = ""; model.User41 = ""; model.User51 = ""; if (testTV == 1) { try { common.Constants.comm.SendMessage(pdu); model.Tinh_Trang = "1"; txtLog.AppendText("Gui 1 tin nhan thanh cong .\n"); } catch (Exception k) { model.Tinh_Trang = "0"; MessageBox.Show("Gui tin nhan that bai . " + k.Message + "\n"); } } bool result = HopThuDiDAO.insertHopThuDi(model); } else if (phones.Length > 1) { int testTV = 0; if (!unicode) { foreach (string phone in phones) { try { pdu = new SmsSubmitPdu(mess, phone, ""); testTV = 1; } catch (Exception) { txtLog.AppendText("Ban phai check vao Tieng Viet de gui tin nhan co dau .\n"); testTV = 0; break; } listPdu.Add(pdu); model = new HopThuDiMODEL(); model.So_Dien_Thoai = phone; model.Noi_Dung_Tin_Nhan = mess; model.Tinh_Trang = "1"; model.Loai_Hop_Thu = "6"; model.User11 = ""; model.User21 = ""; model.User31 = ""; model.User41 = ""; model.User51 = ""; bool result = HopThuDiDAO.insertHopThuDi(model); } desPhones = (SmsSubmitPdu[])listPdu.ToArray(typeof(SmsSubmitPdu)); if (testTV == 1) { try { common.Constants.comm.SendMessages(desPhones); txtLog.AppendText("Gui " + desPhones.Length.ToString() + " tin nhan thanh cong .\n"); } catch (Exception i) { txtLog.AppendText(i.Message + "\n"); } } } else { byte dcs = DataCodingScheme.NoClass_16Bit; foreach (string phone in phones) { pdu = new SmsSubmitPdu(mess, phone, "", dcs); listPdu.Add(pdu); model = new HopThuDiMODEL(); model.So_Dien_Thoai = phone; model.Noi_Dung_Tin_Nhan = mess; model.Tinh_Trang = "1"; model.Loai_Hop_Thu = "6"; model.User11 = ""; model.User21 = ""; model.User31 = ""; model.User41 = ""; model.User51 = ""; bool result = HopThuDiDAO.insertHopThuDi(model); } desPhones = (SmsSubmitPdu[])listPdu.ToArray(typeof(SmsSubmitPdu)); try { common.Constants.comm.SendMessages(desPhones); txtLog.AppendText("Gui " + desPhones.Length.ToString() + " tin nhan thanh cong .\n"); } catch (Exception j) { txtLog.AppendText(j.Message + "\n"); } } Cursor.Current = Cursors.Default; } } else { MessageBox.Show("Số Điện Thoại hoặc Nội Dung Tin Nhắn trống ."); } }