protected void btnSearch_Click(object sender, EventArgs e)
        {
            int GroupId = Convert.ToInt32(ddlGroup.SelectedValue);
            int Month   = Convert.ToInt32(ddlMonth.SelectedValue);
            int Year    = Convert.ToInt32(ddlYear.SelectedValue);

            BusinessLayer.SMS.DoctorsSMSTrigger objDoc = new BusinessLayer.SMS.DoctorsSMSTrigger();
            DataTable dtdoc = new DataTable();

            dtdoc = objDoc.GetAll(GroupId, Month, Year);
            if (dtdoc != null)
            {
                dlReport.DataSource = dtdoc;
                dlReport.DataBind();
            }
        }
        private void SendSMS()
        {
            BusinessLayer.SMS.ApiConfiguration ObjApi = new BusinessLayer.SMS.ApiConfiguration();
            DataTable dt = ObjApi.GetAll();
            DataView  DV = new DataView(dt);

            DV.RowFilter = "IsActive = 1";
            string API = string.Empty;

            API_INDEX = Convert.ToString(DV[0]["SMSAPIId"]);

            try
            {
                string mobiles = "";
                string message = "";
                string strUrl;
                string dataString;

                message = txtMsg.Text.Trim();
                mobiles = txtMobNo.Text.Trim();

                int MobNoCount = 0;
                if (mobiles.Length > 0)
                {
                    string[] Arrmob = mobiles.Trim().Split(',');
                    MobNoCount = Arrmob.Length;//How many nos are sending for SMS
                    mobiles    = "";
                    for (int index = 0; index < Arrmob.Length; index++)
                    {
                        if (Arrmob[index].Length == 10)
                        {
                            mobiles += "91" + Arrmob[index].Trim() + ";";
                        }
                        else if (Arrmob[index].Length == 12)
                        {
                            mobiles += Arrmob[index].Trim() + ";";
                        }
                    }
                    mobiles = mobiles.Trim().Substring(0, mobiles.Length - 1).Trim();
                }
                //------------------------------------

                if (message.Length > 0)
                {
                    if (mobiles.Length == 0)//Then fetch mobile numbers from Database
                    {
                        DataTable dtDB = getMobileNumbers(Convert.ToInt32(ddlGroup.SelectedValue));
                        MobNoCount = dtDB.Rows.Count;//How many nos are sending for SMS
                        int counter = 0;
                        foreach (DataRow dr in dtDB.Rows)
                        {
                            mobiles += "91" + dr["MobileNo"].ToString() + ";";
                            counter++;
                            if (counter == MobNoCount)
                            {
                                mobiles = mobiles.Trim().Substring(0, mobiles.Length - 1);
                                counter = 0;
                            }
                        }
                    }
                    int Credit      = Convert.ToInt32(txtCredit.Text);
                    int TotalCredit = Credit * MobNoCount;
                    strUrl = GetHTTPAPI(mobiles, message);

                    WebRequest      request1    = HttpWebRequest.Create(strUrl);
                    HttpWebResponse response1   = (HttpWebResponse)request1.GetResponse();
                    Stream          s1          = (Stream)response1.GetResponseStream();
                    StreamReader    readStream1 = new StreamReader(s1);
                    dataString = readStream1.ReadToEnd();
                    response1.Close();
                    s1.Close();
                    readStream1.Close();

                    BusinessLayer.SMS.DoctorsSMSTrigger ObjDocSMSTrigger = new BusinessLayer.SMS.DoctorsSMSTrigger();
                    Entity.SMS.DoctorsSMSTrigger        docEntity        = new Entity.SMS.DoctorsSMSTrigger();
                    if (MobNoCount > 0)
                    {
                        docEntity.DoctorsSMSTriggerId = 0;
                        docEntity.Username            = Session["UserId"].ToString();
                        docEntity.GroupId             = Convert.ToInt32(ddlGroup.SelectedValue);
                        docEntity.NoofTrigger         = TotalCredit;
                        docEntity.MessageBody         = txtMsg.Text.ToString();
                        ObjDocSMSTrigger.Save(docEntity);
                        lblMsg.Text   = "<h2>Message send successfully</h2>";
                        Hidden1.Value = "1";
                        btnSendSMS.Style.Add("display", "none");
                    }
                }
            }

            catch (Exception ex)
            {
                lblMsg.Text = "<h2>Error: " + ex.Message + "</h2>";
            }
        }