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

📄 addcom.aspx.cs

📁 网络营销软件的源代码
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using WebApplication8.firstPage;
using System.Data.SqlClient;

namespace WebApplication8.admin
{
	/// <summary>
	/// addCom 的摘要说明。
	/// </summary>
	public class addCom : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox comName;
		protected System.Web.UI.WebControls.TextBox account;
		protected System.Web.UI.WebControls.TextBox realName;
		protected System.Web.UI.WebControls.TextBox userName;
		protected System.Web.UI.WebControls.TextBox password;
		protected System.Web.UI.WebControls.TextBox studentNO;
		protected System.Web.UI.WebControls.TextBox description;
		protected System.Web.UI.WebControls.TextBox password_;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Label hint ;
		protected System.Web.UI.WebControls.TextBox className;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
		protected System.Web.UI.WebControls.TextBox teacher;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(Session["type"] == null || !Session["type"].Equals("管理员"))
				Response.Redirect("../login.aspx");
			Connection connection = new Connection(Application["market"].ToString());
			SqlDataReader reader = connection.execute("select className from Class where classID="+Request["id"]);
			string class_="";
			if(reader.Read())
			{
				class_ = reader["className"].ToString();
			}
			className.Text = class_;// 在此处放置用户代码以初始化页面
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			if((userName.Text.Length == 0)||(comName.Text.Length == 0)||(password.Text != password_.Text)||(realName.Text.Length == 0)
				||(teacher.Text.Length == 0)||(password.Text.Length == 0))
			{
				hint.Text = "填写的信息不正确,请重新填写!";
			}
			
			else
			{
				Connection connection = new Connection(Application["market"].ToString());
				SqlDataReader reader = connection.execute("SELECT * from Single where studentNO='"+studentNO.Text+"'");
				if(reader.HasRows)
				{
					reader.Close();
					hint.Text = "对不起,学号为"+studentNO.Text+"的同学已经注册过了";
				}
				else
				{
					reader.Close();
					reader = connection.execute("select * from Single where userName='"+userName.Text+"'");
					if(reader.HasRows)
					{
						reader.Close();
						hint.Text = "对不起,用户名"+userName.Text+"已经被使用,请使用其它的用户名";
					}
					else
					{
						reader.Close();
						
						reader = connection.execute("insert into Single values ('"+userName.Text+"','"+password.Text+"','"+realName.Text+"','"+className.Text
							+"','"+teacher.Text+"','"+studentNO.Text+"','"+ account.Text +"','企业',0)");
						reader.Close();

						
						reader = connection.execute("insert into company values ('"+comName.Text+"','"+studentNO.Text+"','"+userName.Text+"','"+realName.Text
							+"','"+password.Text+"','" + account.Text + "',0,0," + account.Text + ",'"+className.Text+"','"+teacher.Text+"','"+description.Text+"','"+System.DateTime.Now.ToString()+"')");
						reader.Close();

						Response.Redirect("stuManage.aspx?id=" + Request["id"]);
					}
				}
			}
		}
	}
}

⌨️ 快捷键说明

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