⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 注册.aspx.cs

📁 本系统时物资管理系统
💻 CS
字号:
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 登录 : System.Web.UI.Page
{
    static int a = 0,c= 0,d=0;
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        int b = 0;
        string myConnStr = "data source=.;database=物资管理系统;trusted_connection=SSPI";
        SqlConnection Conn1 = new SqlConnection(myConnStr);
        Conn1.Open();

        string mysql1 = "select ID from 用户表 ";
        SqlCommand cm1 = new SqlCommand(mysql1, Conn1);
        SqlDataReader dr1 = cm1.ExecuteReader();
        while (dr1.Read())
        {
            b = (int)dr1[0] + 1;
        }
        if (a == 1 && TextBox5.Text!=""&&TextBox6.Text!=""&&b!=0&&c==1&&d==1)
        {
            string myConn = "data source=.;database=物资管理系统;trusted_connection=SSPI";
            SqlConnection Conn = new SqlConnection(myConn);
            Conn.Open();

            string mysql = "insert into 用户表(用户编号,用户名,密码,部门名称) values('" + Convert.ToString(TextBox4.Text) + "','" + Convert.ToString(TextBox5.Text) + "','" + Convert.ToString(TextBox6.Text) + "','" + Convert.ToString(TextBox7.Text) + "') ";
            SqlCommand cm = new SqlCommand(mysql, Conn);
            cm.ExecuteNonQuery();
            Conn.Close();
            a = 0;
            c = 0;
            d = 0;
            Response.Write("<script>alert(' 注册成功!');</script>"); 
        }
        else { Response.Write("<script>alert(' 请完善信息!');</script>"); }
    }


    protected void Button3_Click(object sender, EventArgs e)
    {
        string myConnStr = "data source=.;database=物资管理系统;trusted_connection=SSPI";
        SqlConnection Conn = new SqlConnection(myConnStr);
        Conn.Open();

        string mysql = "select 用户编号 from 用户表 where 用户编号='" + TextBox4.Text + "'";
        SqlCommand cm = new SqlCommand(mysql, Conn);
        SqlDataReader dr1 = cm.ExecuteReader();
        if (dr1.Read())
        {
            Response.Write("<script>alert(' 该用户编号已存在!');</script>");
        }
        else
        {
            a = 1;
            Response.Write("<script>alert(' 请继续填写其它信息!');</script>");
        }
        Conn.Close();
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        string myConnStr = "data source=.;database=物资管理系统;trusted_connection=SSPI";
        SqlConnection Conn = new SqlConnection(myConnStr);
        Conn.Open();

        string mysql = "select 部门名称 from 用户表 where 部门名称='" + TextBox7.Text + "'";
        SqlCommand cm = new SqlCommand(mysql, Conn);
        SqlDataReader dr1 = cm.ExecuteReader();
        if (!dr1.Read())
        {
            Response.Write("<script>alert(' 不存在此部门!');</script>");
        }
        else
            c = 1;
        Conn.Close();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string myConnStr = "data source=.;database=物资管理系统;trusted_connection=SSPI";
        SqlConnection Conn = new SqlConnection(myConnStr);
        Conn.Open();

        string mysql = "select 姓名 from 职工信息表 where 姓名='" + TextBox5.Text + "'";
        SqlCommand cm = new SqlCommand(mysql, Conn);
        SqlDataReader dr1 = cm.ExecuteReader();
        if (!dr1.Read())
        {
            Response.Write("<script>alert(' 对不起,您非该公司员工,不能注册!');</script>");
        }
        else
            d = 1;
        Conn.Close();
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        this.Response.Redirect("登录.aspx");
    }
}

⌨️ 快捷键说明

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