protected void Button1_Click(object sender, EventArgs e)
    {
        data_context dc      = new data_context();
        string       SMSText = ConfigurationManager.AppSettings["CDFAddManuallySmsTemplate"].ToString();

        //SMSText = SMSText.Replace("{userName}", "myclap");
        //SMSText = SMSText.Replace("{Password}", "Reminder");
        //dc.sendSms("9595396050", SMSText);


        //SMSText = ConfigurationManager.AppSettings["CDFAddManuallySmsTemplate"].ToString();
        //SMSText = SMSText.Replace("{CDF}", "Bahubali");
        //dc.sendSms("9595396050", SMSText);

        SMSText = ConfigurationManager.AppSettings["CDFRegistrationCompleteSmsTemplate"].ToString();
        dc.sendSms("9595396050", SMSText);



        SMSText = ConfigurationManager.AppSettings["CDFTestCompleteSmsTemplate"].ToString();
        SMSText = SMSText.Replace("{CDF}", "Bahubali");
        dc.sendSms("9595396050", SMSText);



        SMSText = ConfigurationManager.AppSettings["CDFApprovalSmsTemplate"].ToString();
        SMSText = SMSText.Replace("{CDF}", "Bahubali");
        dc.sendSms("9595396050", SMSText);



        SMSText = ConfigurationManager.AppSettings["NDASmsTemplate"].ToString();
        SMSText = SMSText.Replace("{CDF}", "Bahubali");
        dc.sendSms("9595396050", SMSText);



        SMSText = ConfigurationManager.AppSettings["ResetPasswordSmsTemplate"].ToString();
        SMSText = SMSText.Replace("{CDF}", "Bahubali");
        dc.sendSms("9595396050", SMSText);

        SMSText = ConfigurationManager.AppSettings["WelcomeEmailSmsTemplate"].ToString();
        SMSText = SMSText.Replace("{CDF}", "Bahubali");
        dc.sendSms("9595396050", SMSText);



        SMSText = ConfigurationManager.AppSettings["CDFPaymentSmsTemplate"].ToString();
        SMSText = SMSText.Replace("{CDF}", "Bahubali");
        SMSText = SMSText.Replace("{}", "1000");
        dc.sendSms("9595396050", SMSText);

        SMSText = ConfigurationManager.AppSettings["CustomPaymentSmsTemplate"].ToString();
        SMSText = SMSText.Replace("{CDF}", "Bahubali");
        dc.sendSms("9595396050", SMSText);
    }
Example #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //check is valid page property
        if (IsValid)
        {
            try
            {
                //add to emailid sting varible to user input email
                string emailid = txt_emailid.Text.Trim();
                if (emailid != "")
                {
                    //check email id is avaible to datebase and get uid
                    using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString.ToString()))
                    {
                        connection.Open();
                        string        Str  = "select uId,fname,contactNo from tblUserMaster where (email= '" + emailid + "' or dheyaEmail= '" + emailid + "') and userTypeId='" + ConfigurationManager.AppSettings["userTypeId"] + "'";
                        SqlCommand    cmd1 = new SqlCommand(Str, connection);
                        SqlDataReader dr   = cmd1.ExecuteReader();
                        if (dr.HasRows)
                        {
                            dr.Read();
                            int    token        = Convert.ToInt32(dataContext.GenerateRandomNo(1000, 9999) + "" + dr.GetValue(0));
                            string encrypttoken = dataContext.Dataencrypt(token.ToString());
                            if (!encrypttoken.Equals(null))
                            {
                                //create to reset link
                                string resetlink = ConfigurationManager.AppSettings["ResetPasswordURL"] + encrypttoken;

                                string body = this.PrepareBody(resetlink);
                                if (!body.Equals(null))
                                {
                                    //inset data in tblForgotPassword
                                    string     strcmd = "INSERT INTO tblForgotPassword(uId,token,status,date) VALUES (@c_id,@token,@status,@date)";
                                    SqlCommand cmd    = new SqlCommand(strcmd);
                                    cmd.Parameters.AddWithValue("@c_id", dr.GetValue(0));
                                    cmd.Parameters.AddWithValue("@token", token);
                                    cmd.Parameters.AddWithValue("@status", "ACTIVE");
                                    cmd.Parameters.AddWithValue("@date", DateTime.Now);
                                    int i = dbContext.ExecNonQuerypara(cmd);
                                    if (i > 0)
                                    {
                                        //if data save to database then sent email
                                        var task = new Thread(() => dataContext.sendemail(emailid, null, null, ConfigurationManager.AppSettings["ResetPasswordEmailSubject"], body));
                                        task.Start();

                                        if (dr["fname"].ToString() != "" && dr["contactNo"].ToString() != "")
                                        {
                                            string SMSText = ConfigurationManager.AppSettings["ResetPasswordSmsTemplate"].ToString();
                                            SMSText = SMSText.Replace("{CDF}", dr["fname"].ToString());
                                            dataContext.sendSms(dr["contactNo"].ToString(), SMSText);
                                        }
                                    }
                                    resetsuccess.Visible = true;
                                    resetbox.Visible     = false;
                                    HtmlMeta meta = new HtmlMeta();
                                    meta.HttpEquiv = "Refresh";
                                    meta.Content   = "5;url=login.aspx";
                                    this.Page.Controls.Add(meta);
                                }
                            }
                            else
                            {
                                //tokan is null then print error msg
                                div_msg.Visible             = true;
                                div_msg.Attributes["class"] = "alert alert-danger";
                                div_msg.InnerText           = "Something went worng. Please try again.";
                            }
                        }
                        else
                        {
                            div_msg.Visible             = true;
                            div_msg.Attributes["class"] = "alert alert-danger";
                            div_msg.InnerText           = "No account matches " + emailid;
                        }
                    }
                }
                else
                {
                    //user email id is invalid
                    div_msg.Visible             = true;
                    div_msg.Attributes["class"] = "alert alert-danger";
                    div_msg.InnerText           = "Please enter valid email address";
                }
            }
            catch (Exception ex)
            {
                Log.Error("" + ex);
                div_msg.Visible             = true;
                div_msg.Attributes["class"] = "alert alert-danger";
                div_msg.InnerText           = "Something went worng. Please try again.";
            }
        }
    }