12.20

来源:互联网 发布:双端面磨床 知乎 编辑:程序博客网 时间:2024/06/05 10:13
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Net.Mail;
using System.Net;
using System.Configuration;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = ConfigurationManager.ConnectionStrings["treecnn"].ConnectionString;
        using (SqlConnection cnn = new SqlConnection(str))
        {
            SqlCommand cmm = cnn.CreateCommand();
            cmm.CommandText = "insert into z1 (zh,mm,jh) values('" + this.TextBox1.Text + "','" + this.TextBox2.Text + "','" + Session["yanzheng"].ToString() + "')";
            cnn.Open();
            cmm.ExecuteNonQuery();
            cnn.Close();
        }
        Sendmail();
    }
    private void Sendmail()
    {
        MailMessage msg = new MailMessage();
        msg.Body = Session["yanzheng"].ToString();
        msg.From = new MailAddress("1241437018@qq.com");
        msg.Subject = "激活号";
        msg.To.Add(this.TextBox4.Text);
        msg.IsBodyHtml = true;
        SmtpClient sc = new SmtpClient();
        sc.Host = "smtp.qq.com";
        sc.Port = 25;
        NetworkCredential nc = new NetworkCredential();
        nc.UserName = "1241437018";
        nc.Password = "qaz753";
        sc.Credentials = nc;
        sc.Send(msg);
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string str = ConfigurationManager.ConnectionStrings["treecnn"].ConnectionString;
        using (SqlConnection sqlcnn = new SqlConnection(str))
        {
            using (SqlCommand sqlcmm = sqlcnn.CreateCommand())
            {
                sqlcmm.CommandText = "select * from z1 where zh='" + this.TextBox1.Text + "' and mm='"+this.TextBox2.Text+"'";
                sqlcnn.Open();
                SqlDataReader reader = sqlcmm.ExecuteReader();
                while (reader.Read())
                {
                    reader["jh"].ToString();
                    if (reader["jh"].ToString() == this.TextBox5.Text)
                    {
                        using (SqlConnection sql = new SqlConnection(str))
                        {
                            using (SqlCommand sqm = sql.CreateCommand())
                            {
                                sql.Open();
                                sqm.CommandText = "update z1 set jh=@jh where zh='" + this.TextBox1.Text + " and mm=" + this.TextBox2.Text + "'";
                                sqm.Parameters.AddWithValue("@jh","1");
                                sqm.ExecuteNonQuery();
                            }
                        }
                        this.Label1.Text = "激活成功";
                    }
                    else
                    {
                        this.Label1.Text = "激活码错误";
                    }
                }
            }
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        string str = ConfigurationManager.ConnectionStrings["treecnn"].ConnectionString;
        using (SqlConnection sqlcnn = new SqlConnection(str))
        {
            using (SqlCommand sqlcmm = sqlcnn.CreateCommand())
            {
                sqlcmm.CommandText = "select * from z1 where zh='" + this.TextBox6.Text + "' and mm='" + this.TextBox7.Text + "'";
                sqlcnn.Open();
                SqlDataReader reader = sqlcmm.ExecuteReader();
                while (reader.Read())
                {
                    reader["jh"].ToString();
                    if (reader["jh"].ToString() == "1")
                    {
                        this.Label2.Text = "登入成功";
                    }
                    else
                    {
                        this.Label2.Text = "账号未激活";
                    }
                }
            }
        }
    }
}

原创粉丝点击