kaihu.aspx.cs

来自「一种模拟的手机计费软件」· CS 代码 · 共 64 行

CS
64
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class kaihu : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

   


protected void  khquxiao_Click(object sender, EventArgs e)
{
    khkahao.Text = "";
    khmima.Text = "";
     yonghuhao.Text = "";
 
}

    
protected void  khqueding_Click(object sender, EventArgs e)
{
    string connString = @"Data Source=.;Initial Catalog=shoujijifei;Integrated Security=True";
        using (SqlConnection conn = new SqlConnection(connString))
        {
            if ((khkahao.Text.Trim() != "") && (khmima.Text.Trim() != ""))
            {
                conn.Open();
                string sql = "INSERT INTO Card(CardNo,UserPwd,CustomerName) VALUES('" +
                    khkahao.Text + "','" + khmima.Text + "','" + yonghuhao.Text + "')";
                SqlCommand cmd = new SqlCommand(sql, conn);
                int i = cmd.ExecuteNonQuery();
                if (i == 1)
                {
                    Response.Write("<script>alert('开户成功!')</script>");
                    khkahao.Text = "";
                    khmima.Text = "";
                 }
                   else
                {
                    Response.Write("<script>alert('开户失败!不能重复!')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('开户失败,卡号或密码不能为空!')</script>");

            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?