Exemplo n.º 1
0
        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("ارسال با خطا مواجه شد");
            }
        }
Exemplo n.º 2
0
        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();
        }