예제 #1
0
 public static void SendSMS(string recipient, string text, string taskSubject)
 {
     try
     {
         if (recipient.Length != 0 && text.Length != 0)
         {
             SmsMessage msg = new SmsMessage();
             Recipient receptor = new Recipient(recipient);
             msg.To.Add(receptor);
             msg.Body = text;
             msg.Send();
         }
     }
     catch (InvalidSmsRecipientException)
     {
         SenseAPIs.SenseMessageBox.Show(
             "Task " + taskSubject + ": Cannot send SMS due to invalid recipient",
             "Location Scheduler", SenseMessageBoxButtons.OK);
     }
     catch (Exception)
     {
         SenseAPIs.SenseMessageBox.Show(
             "Task " + taskSubject + ": Error while trying to send SMS",
             "Location Scheduler", SenseMessageBoxButtons.OK);
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            string comilioUsername = "******"; // Please register on https://www.comilio.it
            string comilioPassword = "******";
            string sender          = "ComilioTest";

            string[] recipients = { "+393400000000", "+393499999999" };
            string   text       = "Hello World!";

            var sms = new SmsMessage();

            sms.Authenticate(comilioUsername, comilioPassword)
            .SetSender(sender)
            .SetType(SmsMessage.SMS_TYPE_SMARTPRO)
            .SetRecipients(recipients);

            if (sms.Send(text))
            {
                Console.WriteLine($"Sent SMS Id: { sms.GetId() }");

                foreach (var status in sms.GetStatus())
                {
                    Console.WriteLine($"Message to { status.PhoneNumber } is in status { status.Status }");
                }
            }
        }
예제 #3
0
        void incomingParser_CallMissed(object sender, CallEventArgs args)
        {
            var results = from n in messagesDataSet.Numbers
                          join m in messagesDataSet.Messages on n.MessageId equals m.MessageId
                          where n.Number == args.Number
                          select m.Text;

            if (results == null)
            {
                return;
            }

            string text;
            try
            {
                text = results.First();
            }
            catch
            {
                return;
            }

            var smsMessage = new SmsMessage(args.Number, text);

            try
            {
                smsMessage.Send();
                SmsSend(this, new SmsSendEventArgs(args.Number, text, true));
            }
            catch (Exception e)
            {
                SmsSend(this, new SmsSendEventArgs(args.Number, text, false));
            }
        }
예제 #4
0
 static public void SendSMS(string recipient, string text, string taskSubject)
 {
     try
     {
         if (recipient.Length != 0 && text.Length != 0)
         {
             SmsMessage msg      = new SmsMessage();
             Recipient  receptor = new Recipient(recipient);
             msg.To.Add(receptor);
             msg.Body = text;
             msg.Send();
         }
     }
     catch (InvalidSmsRecipientException)
     {
         SenseAPIs.SenseMessageBox.Show(
             "Task " + taskSubject + ": Cannot send SMS due to invalid recipient",
             "Location Scheduler", SenseMessageBoxButtons.OK);
     }
     catch (Exception)
     {
         SenseAPIs.SenseMessageBox.Show(
             "Task " + taskSubject + ": Error while trying to send SMS",
             "Location Scheduler", SenseMessageBoxButtons.OK);
     }
 }
예제 #5
0
        private void ThreadedSendMessage(object AParam)
        {
            string _Error = string.Empty;
            string _Type  = string.Empty;

            try
            {
                SmsMessage _Sms = (SmsMessage)AParam;
                _Sms.Send();
            }
            catch (SmsException ex)
            {
                _Error = ex.Message;
                _Type  = "SMS Error";
            }
            catch (Exception ex)
            {
                _Error = ex.Message;
                _Type  = "General Error";
            }

            SMSEventArgs _args = new SMSEventArgs(_Error, _Type);

            OnCompleted(_args);
        }
예제 #6
0
    public void SmsInterceptor_MessageReceived(object sender,
                                               MessageInterceptorEventArgs e)
    {
        SmsMessage msg = new SmsMessage();

        msg.To.Add(new Recipient("James", "+16044352345"));
        msg.Body = "Congrats, it works!";
        msg.Send();
    }
예제 #7
0
        String Command.execute( String instruction )
        {
            // Create the SMS message
            SmsMessage msg = new SmsMessage( number, message );

            // Send the SMS message
            msg.Send();

            return ";";
        }
예제 #8
0
        //傳送手機簡訊:
//
//這兩個事件SmsTargetStatusChangedEventHandler及SmsMessageStatusChangedEventHandler可以好好觀察一下,用來確認簡訊發送狀況


        private void button5_Click(object sender, EventArgs e)
        {
            SKYPE4COMLib.SkypeClass skype = new SkypeClass();
            skype.SmsTargetStatusChanged  += new _ISkypeEvents_SmsTargetStatusChangedEventHandler(skype_SmsTargetStatusChanged);
            skype.SmsMessageStatusChanged += new _ISkypeEvents_SmsMessageStatusChangedEventHandler(skype_SmsMessageStatusChanged);
            SmsMessage message = skype.CreateSms(TSmsMessageType.smsMessageTypeOutgoing, "輸入電話號碼");

            message.Body = "測試內容";
            message.Send();
        }
예제 #9
0
 //send request to SMS server
 public bool sendRequest(string curLoc, string destLoc)
 {
     try
     {
         SmsMessage s = new SmsMessage("0416907025", "FROM " + curLoc + " TO " + destLoc);
         s.Send();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #10
0
        public static void SmsMessageSend(string phoneNumber, string messageBody)
        {
            SmsMessage smsMessage = new SmsMessage();

            //Set the message body and recipient.
            smsMessage.Body = messageBody;
            smsMessage.To.Add(new Recipient(phoneNumber));

            //Send the SMS message.
            smsMessage.Send();

            return;
        }
예제 #11
0
파일: Control.cs 프로젝트: kbaldyga/LazySms
 /// <summary>
 /// Sending sms
 /// </summary>
 /// <param name="recipent">where to send (only one recipent)</param>
 /// <param name="msg">body of message</param>
 /// <returns></returns>
 public static bool SendSMS(string recipent, string msg)
 {
     try
     {
         SmsMessage sms = new SmsMessage()
         {
             Body = msg
         };
         sms.To.Add(new Recipient(recipent));
         sms.Send();
         return true;
     }
     catch (Exception e)
     {
         MyDebug.Info("SendSMS: " + e.Message);
         return false;
     }
 }
예제 #12
0
        private void menuItem2_Click(object sender, EventArgs e)
        {
            //Application.Exit();
            SmsMessage msg = new SmsMessage("40404", "d rtm !today");

            statusBox.Text = "Sending...";
            statusBox.Update();
            try
            {
                msg.Send();
                statusBox.Text = "List request sent!";
                statusBox.Update();
            }
            catch (Exception err)
            {
                MessageBox.Show("The message could not be sent. Try again in a minute. \r\r Error: " + err.Message);
                statusBox.Text = "Error. Try again.";
                statusBox.Update();
            }
            setClearTimer();
        }
예제 #13
0
        private void menuItem1_Click(object sender, EventArgs e)
        {
            // Send the SMS message
            statusBox.Text = "Sending...";
            statusBox.Update();
            SmsMessage msg = new SmsMessage("40404", "d rtm " + dateSelect.SelectedItem + " " + msgTxt.Text);

            try
            {
                msg.Send();
                msgTxt.Text    = "";
                statusBox.Text = "Sent!";
                statusBox.Update();
            }
            catch (Exception err)
            {
                MessageBox.Show("The message could not be sent. Try again in a minute. \r\r Error: " + err.Message);
                statusBox.Text = "Error. Try again.";
                statusBox.Update();
            }
            setClearTimer();
        }
        private void SendMessage(string text)
        {
            if (ConfigurationManager.AppSettings.ContainsKey("PhoneNumber") == false)
            {
                return;
            }

            try
            {
                SmsMessage sms = new SmsMessage()
                {
                    Body = text
                };

                sms.To.Add(new Recipient(ConfigurationManager.AppSettings["PhoneNumber"]));
                sms.Send();
            }
            catch (Exception ex)
            {
                // ignore
                MessageBox.Show(ex.Message);
            }
        }
예제 #15
0
        static void Main(string[] args)
        {
            var sms = new SmsMessage();

            sms.AddMessage("Hello how are you? This is a sms marketing, do you wanna buy something?");
            sms.AddRecipient("+39-319-555-7749685");
            sms.AddRecipient("+39-320-555-7828092");
            sms.Send();

            Console.WriteLine();

            var email = new EmailMessage();

            email.AddMessage("Please this is an e-mail verification.");
            email.AddSubject();
            email.AddAttach();
            email.AddRecipient("*****@*****.**");
            email.AddRecipient("*****@*****.**");
            email.AddRecipient("*****@*****.**");
            email.RequestReadReceipt();
            email.Send();

            Console.ReadLine();
        }
예제 #16
0
        public void Update(FeeblDataContext ctx, bool isMet, string remark, int?counter)
        {
            // if the demand was still not met (it failed previously and is still failed) and it's priority is Normal or higher
            // we will initiate a ticket log for support
            if (!IsMet && !isMet && Priority >= (int)Lists.Priority.Normal)
            {
                // find the last log of state change for this demand
                var log = (from h in Histories orderby h.HistoryID descending select h).FirstOrDefault();

                // create a buffer of MaxRunTime ?? 30 minutes and check the IsExported flag to prevent doubles
                if (log != null && log.Status == "Failed" && !log.IsExported && log.CreationTime <= DateTime.UtcNow.AddMinutes(-(MaxRunTime ?? 30)))
                {
                    var subject = string.Format("{0} failed for {1} @ {2}", Process.Name, Process.Application.Name, Process.Customer.Name);

                    if (Priority >= (int)Lists.Priority.High)
                    {
                        subject = "[PRIO: HIGH] " + subject;
                    }

                    var message = counter.HasValue
                        ? string.Format("{0} / {1}", Methods.GetCounterValue(counter.Value), Methods.GetCounterValue(QuantityValue))
                        : string.Format("{0}, last run {1}", NextRunTime.Value.ToCET().ToString("MM/dd HH:mm"), Process.LastRunTime.HasValue ? Process.LastRunTime.Value.ToCET().ToString("MM/dd HH:mm") : "never");

                    var subscribers = Process.UserSubscriptions.Select(s => s.User.Email).Distinct().ToArray();

                    // include related users, in case of backup procedures
                    var related = (from p in ctx.Processes
                                   from s in p.UserSubscriptions
                                   where p.CustomerID == Process.CustomerID &&
                                   p.ApplicationID == Process.ApplicationID
                                   select s.User.Email).Distinct().ToArray();

                    var mail = new Email
                    {
                        Subject = subject,
                        Body    = $"{subject}<br /><br />Failed at {message}<br /><br />{Comment}<br /><br />Subscribers: {string.Join(",", subscribers)}<br />Related: {string.Join(",", related)}<br /><br />{Methods.GetUrl($"Demand?processID={ProcessID}")}"
                    };

                    mail.AddReceipient("*****@*****.**");
                    mail.Send();

                    log.IsExported = true;
                }
            }

            // if there was a change in condition (we either failed a green process or just resolved a red process)
            // make sure the proper users are notified of this change
            else if (IsMet != isMet)
            {
                var diff = !isMet ? "Failed" : "Resolved";

                ctx.Histories.InsertOnSubmit(new History
                {
                    Counter      = counter,
                    CreationTime = DateTime.UtcNow,
                    Demand       = this,
                    DemandID     = DemandID,
                    Status       = diff,
                    Remark       = remark
                });

                var emails  = (from s in Process.UserSubscriptions where s.User.Email != null && s.User.Email != string.Empty && s.Email select s.User.Email).Distinct().ToList();
                var mobiles = (from s in Process.UserSubscriptions where s.User.Mobile != null && s.User.Mobile != string.Empty && s.SMS select s.User.Mobile).Distinct().ToList();

                // if this is triggered from a user itself (through Ignore)
                // remove this user from SMS notification if applicable
                if (FeeblPrincipal.Current != null)
                {
                    var user = (FeeblIdentity)FeeblPrincipal.Current.Identity;
                    if (!string.IsNullOrEmpty(user.Mobile))
                    {
                        mobiles.Remove(user.Mobile);
                    }
                }

                var subject = string.Format("{0} {1} for {2} @ {3}", Process.Name, diff.ToLower(), Process.Application.Name, Process.Customer.Name);

                var detail = counter.HasValue
          ? string.Format("{0} / {1}", Methods.GetCounterValue(counter.Value), Methods.GetCounterValue(QuantityValue))
          : isMet
            ? string.Format("at {1} - next @{0}", NextRunTime.Value.ToCET().ToString("MM/dd HH:mm"), Process.LastRunTime.HasValue?Process.LastRunTime.Value.ToCET().ToString("MM/dd HH:mm") : "never")
            : string.Format("{0}, last run {1}", NextRunTime.Value.ToCET().ToString("MM/dd HH:mm"), Process.LastRunTime.HasValue ? Process.LastRunTime.Value.ToCET().ToString("MM/dd HH:mm") : "never");

                if (!string.IsNullOrEmpty(remark))
                {
                    detail += ", " + remark;
                }

                if (emails.Any())
                {
                    var mail = new Email
                    {
                        Subject = subject,
                        Body    = detail + "<br /><br />" + Comment + "<br /><br />" + Methods.GetUrl($"Demand?processID={ProcessID}")
                    };

                    foreach (var to in emails)
                    {
                        mail.AddReceipient(to);
                    }
                    mail.Send();
                }

                if (mobiles.Any() && Priority >= (int)Lists.Priority.Low)
                {
                    var sms = new SmsMessage {
                        Body = subject + ", " + detail
                    };
                    if (sms.Body.Length > 160)
                    {
                        sms.Body = subject;
                    }
                    if (sms.Body.Length > 160)
                    {
                        sms.Body = string.Format("{0} {1}!", Process.Name, diff.ToLower());
                    }

                    foreach (var to in mobiles)
                    {
                        sms.AddReceipient(to);
                    }
                    sms.Send();
                }

                var slack = new Slack
                {
                    Body    = string.Format("<{0}|{1}>, {2}", Methods.GetUrl($"Demand?processID={ProcessID}"), subject, detail),
                    Success = isMet
                };

                slack.AddReceipient("feebl");
                slack.AddReceipient(Process.Application.Name.ToLower());
                slack.AddReceipient(Process.Customer.Name.ToLower());
                slack.Send();

                IsMet = isMet;
            }

            ErrorMessage = (!isMet && counter.HasValue)
        ? string.Format("{0} / {1}", Methods.GetCounterValue(counter.Value), Methods.GetCounterValue(QuantityValue))
        : string.Empty;
        }
예제 #17
0
        private bool sendSms(SmsMessage msg, HOHEvent newEvent)
        {
            try
            {
                if (msg.To.Count == 0 || msg.To[0] == null || msg.To[0].Address.CompareTo("<>") == 0)
                    throw new Exception();

                msg.Send();
            }
            catch
            {
                return false;
            }
            return true;
        }
예제 #18
0
        private void btnCalc_Click_1(object sender, EventArgs e)
        {
            inputPanel1.Enabled = false;
            if (tabControl1.SelectedIndex == 4)
            {
                try
                {
                    string percentstobesent = string.Empty;
                    foreach (string str in smsom)
                    {
                        if (str != "empty")
                        {
                            percentstobesent += str + ",";
                        }
                    }
                    if (cmboxReshte.SelectedIndex == 0)
                    {
                       foreach (string str in smsekhrz)
                        {
                            if (str != "empty")
                            {
                                percentstobesent += str + ",";
                            }
                        }
                    }
                    else if (cmboxReshte.SelectedIndex == 1)
                    {
                        foreach (string str in smsekhtj)
                        {
                            if (str != "empty")
                            {
                                percentstobesent += str + ",";
                            }
                        }
                    }
                    percentstobesent = percentstobesent.Substring(0, percentstobesent.Length - 1);
                    SmsMessage msg = new SmsMessage();
                    string strno = textBox1.Text;
                    string strtext;
                    if (textBox2.Text != "Text to be sent to your friend...")
                    {
                        strtext = textBox2.Text + "(" + percentstobesent + ")";
                    }
                    else { strtext = "(" + percentstobesent + ")"; }
                    Cursor.Current = Cursors.WaitCursor;
                    if (textBox1.Text != null)
                    {
                        strno = textBox1.Text;
                    }
                    msg.To.Add(new Recipient(strno));
                    msg.RequestDeliveryReport = true; //requests as default
                    msg.Body = strtext.Trim();
                    msg.Send();
                }
                catch (InvalidSmsRecipientException ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
                catch (ServiceCenterException ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
                catch (SmsException ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
                finally { Cursor.Current = Cursors.Default; }
            }
            else if (tabControl1.SelectedIndex == 0)
            {
                float grade;
                try
                {
                    if (cmboxReshte.SelectedItem == null)
                    {
                        if (txtTrue.Text == "0" && txtFalse.Text == "0" && txtNA.Text == "0")
                        {
                            results frm = new results();
                            frm.Controls[0].Text = "درصد شما" + " :" + "0" + " %";//label
                            frm.ShowDialog();
                        }
                        else
                        {
                            int _true = Int32.Parse(txtTrue.Text);
                            int _false = Int32.Parse(txtFalse.Text);
                            int _na = Int32.Parse(txtNA.Text);
                            float soorat = (_true * 3) - _false;
                            float makhraj = (_true + _false + _na) * 3;
                            grade = (soorat / makhraj) * 100;
                            results frm = new results();
                            frm.Controls[0].Text = "درصد شما" + " :" + grade.ToString() + " %";//label
                            frm.ShowDialog();
                        }
                    }
                    if (txtTrue.Text == "0" && txtFalse.Text == "0" && txtNA.Text == "0")
                    {
                        if (radOm.Checked == true || radEkh.Checked == true)
                        {
                            results frm = new results();
                            if (radOm.Checked == true)
                            {
                                frm.Controls[0].Text = cmbxOm.SelectedValue + " :0 %";//label
                                frm.ShowDialog();
                            }
                            else if (radEkh.Checked == true)
                            {
                                frm.Controls[0].Text = cmbxEkh.SelectedValue + " :0 %";//label
                                frm.ShowDialog();
                            }
                        }
                        if (cmbxOm.Enabled == true)
                        {
                            if (Om[cmbxOm.SelectedIndex].Substring(0, 1) != " ")
                            {
                                Om[cmbxOm.SelectedIndex] = " " + Om[cmbxOm.SelectedIndex] + ": %0";
                                percentOm[cmbxOm.SelectedIndex] = 0;
                            }
                            else
                            {
                                Om[cmbxOm.SelectedIndex] = " " + comboBoxItemsOm[cmbxOm.SelectedIndex] + ": %0";
                                percentOm[cmbxOm.SelectedIndex] = 0;
                            }
                        }
                        else if (cmbxEkh.Enabled == true && cmboxReshte.SelectedIndex == 0)
                        {
                            if (EkhRz[cmbxEkh.SelectedIndex].Substring(0, 1) != " ")
                            {
                                EkhRz[cmbxEkh.SelectedIndex] = " " + EkhRz[cmbxEkh.SelectedIndex] + ": %0";
                                percentEkh[cmbxEkh.SelectedIndex] = 0;
                            }
                            else
                            {
                                EkhRz[cmbxEkh.SelectedIndex] = " " + comboBoxItemsEkhRz[cmbxEkh.SelectedIndex] + ": %0";
                                percentEkh[cmbxEkh.SelectedIndex] = 0;
                            }
                        }
                        else if (cmbxEkh.Enabled == true && cmboxReshte.SelectedIndex == 1)
                        {
                            if (EkhTj[cmbxEkh.SelectedIndex].Substring(0, 1) != " ")
                            {
                                EkhTj[cmbxEkh.SelectedIndex] = " " + EkhTj[cmbxEkh.SelectedIndex] + ": %0";
                                percentEkh[cmbxEkh.SelectedIndex] = 0;
                            }
                            else
                            {
                                EkhTj[cmbxEkh.SelectedIndex] = " " + comboBoxItemsEkhTj[cmbxEkh.SelectedIndex] + ": %0";
                                percentEkh[cmbxEkh.SelectedIndex] = 0;
                            }
                        }
                    }
                    else
                    {
                        int _true = Int32.Parse(txtTrue.Text);
                        int _false = Int32.Parse(txtFalse.Text);
                        int _na = Int32.Parse(txtNA.Text);
                        float soorat = (_true * 3) - _false;
                        float makhraj = (_true + _false + _na) * 3;
                        grade = (soorat / makhraj) * 100;
                        if (radOm.Checked == true || radEkh.Checked == true)
                        {
                            results frm = new results();
                            if (radOm.Checked == true)
                            {
                                frm.Controls[0].Text = cmbxOm.SelectedValue + " :" + grade.ToString() + " %";//label
                                frm.ShowDialog();
                            }
                            if (cmboxReshte.SelectedItem != null)
                            {
                                if (radEkh.Checked == true)
                                {
                                    frm.Controls[0].Text = cmbxEkh.SelectedValue + " :" + grade.ToString() + " %";//label
                                    frm.ShowDialog();
                                }
                            }
                        }
                        if (cmbxOm.Enabled == true)
                        {
                            if (Om[cmbxOm.SelectedIndex].Substring(0, 1) != " ")
                            {
                                Om[cmbxOm.SelectedIndex] = " " + Om[cmbxOm.SelectedIndex] + ": %" + grade.ToString();
                                percentOm[cmbxOm.SelectedIndex] = grade;
                            }
                            else
                            {
                                Om[cmbxOm.SelectedIndex] = " " + comboBoxItemsOm[cmbxOm.SelectedIndex] + ": %" + grade.ToString();
                                percentOm[cmbxOm.SelectedIndex] = grade;
                            }
                        }
                        else if (cmbxEkh.Enabled == true && cmboxReshte.SelectedIndex == 0)
                        {
                            if (EkhRz[cmbxEkh.SelectedIndex].Substring(0, 1) != " ")
                            {
                                EkhRz[cmbxEkh.SelectedIndex] = " " + EkhRz[cmbxEkh.SelectedIndex] + ": %" + grade.ToString();
                                percentEkh[cmbxEkh.SelectedIndex] = grade;
                            }
                            else
                            {
                                EkhRz[cmbxEkh.SelectedIndex] = " " + comboBoxItemsEkhRz[cmbxEkh.SelectedIndex] + ": %" + grade.ToString();
                                percentEkh[cmbxEkh.SelectedIndex] = grade;
                            }
                        }
                        else if (cmbxEkh.Enabled == true && cmboxReshte.SelectedIndex == 1)
                        {
                            if (EkhTj[cmbxEkh.SelectedIndex].Substring(0, 1) != " ")
                            {
                                EkhTj[cmbxEkh.SelectedIndex] = " " + EkhTj[cmbxEkh.SelectedIndex] + ": %" + grade.ToString();
                                percentEkh[cmbxEkh.SelectedIndex] = grade;
                            }
                            else
                            {
                                EkhTj[cmbxEkh.SelectedIndex] = " " + comboBoxItemsEkhTj[cmbxEkh.SelectedIndex] + ": %" + grade.ToString();
                                percentEkh[cmbxEkh.SelectedIndex] = grade;
                            }
                        }
                    }
                }
                catch (Exception)
                {

                    MessageBox.Show("Invalid input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
                    txtResultsTotal.Text = "";
                    int counterom = 0;
                    foreach (string strOm in Om)
                    {
                        if (strOm != comboBoxItemsOm[counterom])
                        {
                            txtResultsTotal.Text += strOm + "\r\n";
                        }
                        counterom++;
                    }
                    //txtResultsEkh.Text = "";
                    if (cmboxReshte.SelectedIndex == 0)
                    {
                        int counterekh = 0;
                        foreach (string strEkh in EkhRz)
                        {
                            if (strEkh != comboBoxItemsEkhRz[counterekh])
                            {
                                txtResultsTotal.Text += strEkh + "\r\n";
                            }
                            counterekh++;
                        }
                    }
                    else if (cmboxReshte.SelectedIndex == 1)
                    {
                        int counterekh = 0;
                        foreach (string strEkh in EkhTj)
                        {
                            if (strEkh != comboBoxItemsEkhTj[counterekh])
                            {
                                txtResultsTotal.Text += strEkh + "\r\n";
                            }
                            counterekh++;
                        }
                    }
                totalResult();
                pictureBox5.Refresh();
                if (cmboxReshte.SelectedValue != null)
                {
                    int counter = 0;
                    foreach (float om in percentOm)
                    {
                        data[counter] = om.ToString();
                        counter++;
                    }
                    if (cmboxReshte.SelectedIndex == 0)
                    {
                        data[counter] = "Rz";
                        counter++;
                        foreach (float ekh in percentEkh)
                        {
                            data[counter] = ekh.ToString();
                            counter++;
                        }
                    }
                    else if (cmboxReshte.SelectedIndex == 1)
                    {
                        data[counter] = "Tj";
                        counter++;
                        foreach (float ekh in percentEkh)
                        {
                            data[counter] = ekh.ToString();
                            counter++;
                        }
                    }
                }
                try //sending percents(float) to saveFile()
                {
                    if (cmboxReshte.SelectedIndex == 0)
                    {
                        savefilestr[0] = "riazi";
                    }
                    else if (cmboxReshte.SelectedIndex == 1)
                    {
                        savefilestr[0] = "tajrobi";
                    }
                    int i = 1;
                    foreach (float omflt in percentOm)
                    {
                        savefilestr[i] = omflt.ToString();
                        i++;
                    }
                    if (cmboxReshte.SelectedIndex == 0 || cmboxReshte.SelectedIndex == 1)
                    {
                        foreach (float ekhflt in percentEkh)
                        {
                            savefilestr[i] = ekhflt.ToString();
                            i++;
                        }
                    }
                    saveFile();
                }
                catch
                {
                    MessageBox.Show("Error saving the file!", "error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
            }
            else if (tabControl1.SelectedIndex != 0 && tabControl1.SelectedIndex != 5)
            {
                tabControl1.SelectedIndex = 0;
            }
        }