コード例 #1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                int vaziyzt = 1;
                using (var context = new kitchenEntities())
                {
                    try
                    {
                        var x = context.Setting.FirstOrDefault();
                        if (x.GroupSms == "true")
                        {
                            vaziyzt = 1;
                        }
                        else
                        {
                            vaziyzt = 0;
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("ابتدا باید مشخصات مدیر را در بخش تنظیمات ثبت کنید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        return;
                        //MessageBox.Show(ex.Message);
                    }

                    if (txtSignature.Text == "" || txtSMSnumber.Text == "")
                    {
                        MessageBox.Show("امضا دیجیتال یا شماره پیامک اشتباه است", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtSignature.Focus();
                        return;
                    }
                    if (vaziyzt == 1)
                    {
                        lblSendMessage.Text = "";
                        lblDelivery.Text    = "";
                        PARSGREEN.API.SMS.Send.SendSMS send = new PARSGREEN.API.SMS.Send.SendSMS();
                        int      successCount = 0;
                        int      restStatus;
                        string[] restr = null;
                        restStatus = send.SendGroupSMS(txtSignature.Text, txtSMSnumber.Text, new string[] { txtMobilesNumbers.Text }, txtMessageBody.Text, false, string.Empty, ref successCount, ref restr);
                        if (restStatus == 1)
                        {
                            MessageBox.Show("ارسال شد", "پیامک", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            lblSendMessage.Text = restStatus.ToString();
                            lblDelivery.Text    = successCount.ToString();
                            return;
                        }
                        if (restStatus == -1)
                        {
                            MessageBox.Show("امضا دیجیتال یا شماره پیامک اشتباه است", "پیامک", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("برای فعال سازی یه بخش تنظیمتات بروید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    //MessageBox.Show("تعداد پیام ها: " + restStatus.ToString() + "\r" + "تحویل داده شده اولیه: " + successCount);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("آقا /خانم " + txtName.Text + " به خشکشویی باران خوش آمدید\nکد اشتراک شما " + txtEshterak.Text, "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //MessageBox.Show("آقا /خانم " + txtName + " به خشکشویی باران خوش آمدید.کد اشتراک شما " + txtEshterak.Text);

            try
            {
                if (txtEshterak.Text == "")
                {
                    MessageBox.Show("شماره اشتراک خالی است", "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    using (var context = new StimulsoftEntities())
                    {
                        bool isContact = context.User.Where(check => check.Eshterak == txtEshterak.Text).Any();
                        if (isContact)
                        {
                            //MessageBox.Show("کاربری بااین شماره اشتراک وجود دارد", "اشتراک", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            lblError.ForeColor = Color.Red;
                            lblError.Text      = "کاربری بااین شماره اشتراک وجود دارد";
                            txtEshterak.Focus();
                        }
                        else
                        {
                            if (txtPhone.Text == "")
                            {
                                txtPhone.Text = "0";
                            }
                            User user = new User
                            {
                                Name     = txtName.Text,
                                Phone    = txtPhone.Text,
                                Eshterak = txtEshterak.Text,
                                //Date = int.Parse(DateEnter.Text.Replace("/", "")),
                                Email = txtEmail.Text,
                                //************
                            };
                            context.User.Add(user);
                            context.SaveChanges();
                            lblError.ForeColor = Color.Green;
                            lblError.Text      = "اطلاعات با موفقیت ثیت شد";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //-----ersal sms
            try
            {
                // PARSGREEN.API_SendSMS.SendSMS send = new PARSGREEN.API_SendSMS.SendSMS();
                PARSGREEN.API.SMS.Send.SendSMS send = new PARSGREEN.API.SMS.Send.SendSMS();
                int      successCount = 0;
                int      restStatus;
                string[] restr = null;
                restStatus = send.SendGroupSMS("8B0AA695-E750-4CB3-AF3E-98F9D03F06AC", "10001000300076", new string[] { txtPhone.Text }, "آقا /خانم " + txtName.Text + " به خشکشویی باران خوش آمدید\nکد اشتراک شما " + txtEshterak.Text, false, string.Empty, ref successCount, ref restr);
                //MessageBox.Show("تعداد پیام ها: " + restStatus.ToString() + "\r" + "تحویل داده شده: " + successCount);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }