Ejemplo n.º 1
0
        private void btnGenerateNumber_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(txt_message_text.Text))
            {
                Message_PopUp.Show_Error_Message("Please Enter Message Text");
            }
            else
            {
                string result = sms_repository.Construct_SMS_All_Class(txt_message_text.Text);

                if (result == "ARGEN001")
                {
                    Message_PopUp.Show_Error_Message("Already Constructed.");
                }
                if (result == "S")
                {
                    Message_PopUp.Show_Success_Message("Message Constructed.");
                }
            }
            bind_Grid();
        }
        private void btnSentMessage_Click(object sender, System.EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringBuilder sb_invalid_mobile_number = new StringBuilder();

            string[] arr_mobile_number = txtNumbers.Text.Split(',');

            #region Validation
            if (string.IsNullOrEmpty(txt_message_text.Text))
            {
                sb.Append("\u2022 Please enter message text.\n");
            }

            if (string.IsNullOrEmpty(txtNumbers.Text))
            {
                sb.Append("\u2022 Please enter mobile number.\n");
            }


            int invalidNumberCount = 0;
            foreach (string numbers in arr_mobile_number)
            {
                if (numbers.Length != 10)
                {
                    sb_invalid_mobile_number.Append(numbers).Append("\n");
                    invalidNumberCount++;
                }
            }

            if (invalidNumberCount > 0)
            {
                sb.Append("\u2022 Invalid mobile number & wrong format, Please Check.\n");
                sb.Append(sb_invalid_mobile_number.ToString()).Append("\n");
            }

            if (sb.ToString().Length > 0)
            {
                Message_PopUp.Show_Error_Message(sb.ToString());
                return;
            }


            #endregion Validation

            if (invalidNumberCount == 0)
            {
                List <SMS_Model> sms_model_list = new List <SMS_Model>();
                string           sms_response   = string.Empty;
                foreach (string numbers in arr_mobile_number.Distinct())
                {
                    sms_response = SMS_Service_API.Send_SMS_Service(numbers, txt_message_text.Text);
                    if (sms_response == "S")
                    {
                        sms_repository.Log_SMS_Individual(numbers, txt_message_text.Text);
                    }

                    sms_model_list.Add(new SMS_Model {
                        Mobile_Number = numbers, Send_Status = sms_response == "S" ? "Send" : "Not Send"
                    });
                }
                gridSMS.Refresh();
                gridSMS.DataSource = sms_model_list;

                lblBalancedSMSValue.Text = SMS_Service_API.SMS_Balance_Service();
            }
        }