private void btnsend_Click(object sender, EventArgs e) { string msgcontent = matn.Text; string phonenumber = RecieverNo.Text; ServiceReference1.SendSoapClient sms = new Rohab.ServiceReference1.SendSoapClient(); byte[] status = new byte[] { }; ServiceReference1.ArrayOfLong aroflo = new Rohab.ServiceReference1.ArrayOfLong(); //string[] returnValue try { msgcontent = msgcontent.Replace("*نام*", recieverName.Text); } catch (Exception) { } try { phonenumber = phonenumber.Substring(0, 11); } catch (Exception) { } Thread.Sleep(1000); if (this == null) { return; } if (this.IsDisposed || Disposing) { return; } try { Result = sms.SendSms("9369611913", "19130", new ServiceReference1.ArrayOfString { phonenumber }, "30004966300049", msgcontent, false, "", ref aroflo, ref status); } catch (Exception) { MessageBox.Show("سرویس در دسترس نیست"); } //label2.Text = i.ToString(); ///////////////////// if (Result == 1) { sms sm = new sms(); sm.matnsms = msgcontent; sm.shomaremaghsad = msgcontent; sm.tahvilgirande = phonenumber; sm.tahvilshod = true; sm.tarikh = Date.Shamsiwithtime(DateTime.Now); sm.type = "ارسال به سایر"; sm.Add(); } else { MessageBox.Show("ارسال با خطا مواجه شد"); } }
void updategridview() { Boolean check = false; string SQL = "select [smsid],[type],[tarikh],[tahvilgirande],[shomaremaghsad],[matnsms],[tahvilshod] from sms where "; check = false; SQL = SQL + "[type] like N'%" + txttype.Text.Trim() + "%'AND "; if (txttarikh.Text != "13 / /") { SQL = SQL + "[tarikh] like N'%" + txttarikh.Text.Trim() + "%'AND "; check = true; } SQL = SQL.Remove(SQL.Length - 4) + " order by tarikh DESC"; sms cl = new sms(); DataTable dt = new DataTable(); dt = cl.Search(SQL); dataGridView1.DataSource = dt; string[] col_headers = { "مشخصه", "ارسال به", "تاریخ", "نام گیرنده", "موبایل", "متن پیام", "تحویل شد" }; // int[] col_width = { 70, 80, 100, 70, 110, 80, 80, 80, 100, 80, 78 }; for (int i = 0; i < col_headers.Length; i++) { dataGridView1.Columns[i].HeaderText = col_headers[i].ToString(); // dataGridView1.Columns[i].Width = col_width[i]; } DataGridViewCellStyle objAlternatingCellStyle = new DataGridViewCellStyle(); objAlternatingCellStyle.BackColor = Color.Khaki; dataGridView1.AlternatingRowsDefaultCellStyle = objAlternatingCellStyle; }
private void Sendsms() { int count = 0; if (datarows != null) { foreach (DataGridViewRow dr in datarows.Rows) { try { if (!bool.Parse(dr.Cells[0].Value.ToString())) { continue; } } catch (Exception) { continue; } string msg = msgcontent; if (string.IsNullOrEmpty(dr.Cells[3].Value.ToString())) { continue; } ServiceReference1.SendSoapClient sms = new Rohab.ServiceReference1.SendSoapClient(); byte[] status = new byte[] { }; ServiceReference1.ArrayOfLong aroflo = new Rohab.ServiceReference1.ArrayOfLong(); //string[] returnValue try { msg = msg.Replace("*نام*", dr.Cells[2].Value.ToString()); } catch (Exception) { } string phonenumber = dr.Cells[3].Value.ToString().Trim(); try { phonenumber = phonenumber.Substring(0, 11); } catch (Exception) { } SetLabelfun(msg, phonenumber, dr.Cells[2].Value.ToString()); // Thread.Sleep(1000); if (this == null) { return; } if (this.IsDisposed || Disposing) { return; } int i = sms.SendSms("9369611913", "19130", new ServiceReference1.ArrayOfString { phonenumber }, "30004966300049", msg, false, "", ref aroflo, ref status); //label2.Text = i.ToString(); ///////////////////// count++; if (i == 1) { SetResultfun("پیامک برای " + dr.Cells[2].Value.ToString() + " به شماره " + phonenumber + " با موفقیت ارسال شد", count); } else { SetResultfun("ارسال به " + dr.Cells[2].Value.ToString() + " به شماره " + phonenumber + " نا موفق بوده است ", count); } sms sm = new sms(); sm.matnsms = msg; sm.shomaremaghsad = phonenumber; sm.tahvilgirande = dr.Cells[2].Value.ToString(); //sm.tahvilshod = i == 1 ? true : false; sm.tarikh = Date.Shamsiwithtime(DateTime.Now); try { if (((DataTable)dr.DataGridView.DataSource).Columns[3].Caption.Contains("birthdate")) { sm.type = "تبریک تولد"; } } catch (Exception) { if (!((DataTable)dr.DataGridView.DataSource).Columns[0].Caption.Contains("std")) { sm.type = "ارسال به استاد"; } else { sm.type = "ارسال به هنرجو"; } } sm.Add(); } } SetLabel1fun(); }