Example #1
0
        protected void btnSendSMS_Click(object sender, EventArgs e)
        {
            List <string> selectedMobieNosList = GetArr90(40);
            //string msg = "Dear Parents, " + txtMessage.Text + ".";
            // string msg = ddlTemplate.SelectedValue.ToString()  + txtMessage.Text + ".";



            // string msg = ddlTemplate.SelectedValue.ToString() + TextBox2.Text + ".";

            string msg = ddlTemplate.SelectedValue.ToString() + TranslateSan() + ".";


            string result = "";
            //string selectedMobieNos = GetSelectedIds(gridView1, 5);
            string selectedMobieNos = GetSelectedIds(gridView1, 6);

            string[] arr        = selectedMobieNos.Split();
            int      mobileCoun = arr.Length;

            string mobs     = "";
            string mobsTest = "";

            DBSite site = new DBSite();

            string sms_result = "";

            int sms_count = 0;

            // if check box is selected
            bool isUnicode = ckbUnicode.Checked;


            //try
            {
                foreach (string str in selectedMobieNosList)
                {
                    mobs = str.Replace("&nbsp;,", "");

                    msg = msg.Replace("'", "");

                    try
                    {
                        site.BeginTrans();
                        sms_count += util.SaveSentSMSToDB(site, mobs, msg, isUnicode, Util_BLL.User);
                        site.Commit();
                    }
                    catch (Exception ex)
                    {
                        site.RollBack();
                        throw ex;
                    }


                    result += util.SendSms(site, mobs, msg, Util_BLL.User, Response, isUnicode);
                    //sms_result = util.SMSResult(result);



                    mobsTest += "\n" + mobs;
                }

                // txtMessage.Text = result;

                lblMessage.Text    = sms_count + " SMS Sent";
                lblMessage.Visible = true;
            }
            //catch (Exception ex)
            //{
            //    lblError.Text = "Ooops ...Some Error ! " + ex.Message;
            //    lblError.Visible = true;
            //}

            int sms_bal = util.GetSMSBalance(site, Util_BLL.User.UserId);



            if (sms_bal == -99)
            {
                lblBalance.Text = "Remaining SMS : ";
            }
            else
            {
                lblBalance.Text = "Remaining SMS : " + sms_bal.ToString();
            }
            //
        }
Example #2
0
        protected void btnSendSMSToAbsentees_Click(object sender, EventArgs e)
        {
            Util_BLL      util = new Util_BLL();
            AttendanceBll abll = new AttendanceBll();

            site = new DBSite();
            List <AttendanceBll.AttendanceEntity> attdList = new List <AttendanceBll.AttendanceEntity>();

            AttendanceBll.AttendanceEntity atd;

            foreach (GridViewRow gr in gridView1.Rows)
            {
                atd = new AttendanceBll.AttendanceEntity();



                CheckBox cb = (CheckBox)gr.Cells[0].FindControl("ckbPresent");
                if (!cb.Checked)
                {
                    atd.AttendanceId = util.CheckNullInt(gr.Cells[2].Text);

                    string msg = "Dear Parent, Your Child Name <40> is absent today.";
                    msg = msg.Replace("<40>", util.CheckNull(gr.Cells[3].Text));

                    // 5cs School, Lalpur
                    if (Util_BLL.User.SenderId == "FifthC")
                    {
                        msg = "Dear Parents, Your ward '<40>' is absent today from School.";
                        msg = msg.Replace("<40>", util.CheckNull(gr.Cells[3].Text));
                    }


                    // if not class is Staff then do not send sms
                    // and not sms has been sent already

                    string mobileNo = abll.GetMobileNo(site, atd.AttendanceId);

                    string ss = util.SendSms(site, mobileNo, msg, Util_BLL.User, this.Response, false);

                    int sms_count = 0;

                    try
                    {
                        site.BeginTrans();

                        sms_count = util.SaveSentSMSToDB(site, mobileNo, msg, false, Util_BLL.User);
                        site.Commit();
                    }
                    catch (Exception ex)
                    {
                        site.RollBack();
                    }



                    if (abll.GetClassName(site, atd.AttendanceId).ToUpper() != "STAFF" && !abll.IsSMSSent(site, atd.AttendanceId))
                    {
                        //string ss = util.SendSms(abll.GetMobileNo(site, atd.AttendanceId), msg, Util_BLL.User, this.Response);
                    }


                    attdList.Add(atd);
                }
            }

            abll.PostSMS(site, attdList);
        }