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

📄 studentsearch.aspx.cs

📁 学生公寓管理系统使用说明: 1.服务器运行环境 SQL 2000 .NET FRAMEWORK 1.1 .NET FRAMEWORK 1.1 CHINESE (SIMPL
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			this.sqlInsertCommand1.CommandText = @"INSERT INTO Student(Student_ID, Student_Name, Student_Password, Student_Birth, Student_Sex, Student_Photo, Student_Depart, Student_Course, Student_Postion, Room_ID, Student_Email, Student_LiveCost, Student_StudyCost, Student_Address, Student_Phone) VALUES (@Student_ID, @Student_Name, @Student_Password, @Student_Birth, @Student_Sex, @Student_Photo, @Student_Depart, @Student_Course, @Student_Postion, @Room_ID, @Student_Email, @Student_LiveCost, @Student_StudyCost, @Student_Address, @Student_Phone); SELECT Student_ID, Student_Name, Student_Password, Student_Birth, Student_Sex, Student_Photo, Student_Depart, Student_Course, Student_Postion, Room_ID, Student_Email, Student_LiveCost, Student_StudyCost, Student_Address, Student_Phone FROM Student WHERE (Student_ID = @Student_ID)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_ID", System.Data.SqlDbType.BigInt, 8, "Student_ID"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Name", System.Data.SqlDbType.VarChar, 8, "Student_Name"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Password", System.Data.SqlDbType.VarChar, 16, "Student_Password"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Birth", System.Data.SqlDbType.NVarChar, 10, "Student_Birth"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Sex", System.Data.SqlDbType.VarChar, 2, "Student_Sex"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Photo", System.Data.SqlDbType.VarChar, 30, "Student_Photo"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Depart", System.Data.SqlDbType.VarChar, 20, "Student_Depart"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Course", System.Data.SqlDbType.VarChar, 20, "Student_Course"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Postion", System.Data.SqlDbType.VarChar, 20, "Student_Postion"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Room_ID", System.Data.SqlDbType.BigInt, 8, "Room_ID"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Email", System.Data.SqlDbType.VarChar, 30, "Student_Email"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_LiveCost", System.Data.SqlDbType.Money, 8, "Student_LiveCost"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_StudyCost", System.Data.SqlDbType.Money, 8, "Student_StudyCost"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Address", System.Data.SqlDbType.VarChar, 50, "Student_Address"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Phone", System.Data.SqlDbType.VarChar, 12, "Student_Phone"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT Student_ID, Student_Name, Student_Password, Student_Birth, Student_Sex, St" +
				"udent_Photo, Student_Depart, Student_Course, Student_Postion, Room_ID, Student_E" +
				"mail, Student_LiveCost, Student_StudyCost, Student_Address, Student_Phone FROM S" +
				"tudent";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = "UPDATE Student SET Student_ID = @Student_ID, Student_Name = @Student_Name, Studen" +
				"t_Password = @Student_Password, Student_Birth = @Student_Birth, Student_Sex = @S" +
				"tudent_Sex, Student_Photo = @Student_Photo, Student_Depart = @Student_Depart, St" +
				"udent_Course = @Student_Course, Student_Postion = @Student_Postion, Room_ID = @R" +
				"oom_ID, Student_Email = @Student_Email, Student_LiveCost = @Student_LiveCost, St" +
				"udent_StudyCost = @Student_StudyCost, Student_Address = @Student_Address, Studen" +
				"t_Phone = @Student_Phone WHERE (Student_ID = @Original_Student_ID) AND (Room_ID " +
				"= @Original_Room_ID OR @Original_Room_ID IS NULL AND Room_ID IS NULL) AND (Stude" +
				"nt_Address = @Original_Student_Address OR @Original_Student_Address IS NULL AND " +
				"Student_Address IS NULL) AND (Student_Birth = @Original_Student_Birth OR @Origin" +
				"al_Student_Birth IS NULL AND Student_Birth IS NULL) AND (Student_Course = @Origi" +
				"nal_Student_Course) AND (Student_Depart = @Original_Student_Depart) AND (Student" +
				"_Email = @Original_Student_Email OR @Original_Student_Email IS NULL AND Student_" +
				"Email IS NULL) AND (Student_LiveCost = @Original_Student_LiveCost OR @Original_S" +
				"tudent_LiveCost IS NULL AND Student_LiveCost IS NULL) AND (Student_Name = @Origi" +
				"nal_Student_Name) AND (Student_Password = @Original_Student_Password OR @Origina" +
				"l_Student_Password IS NULL AND Student_Password IS NULL) AND (Student_Phone = @O" +
				"riginal_Student_Phone OR @Original_Student_Phone IS NULL AND Student_Phone IS NU" +
				"LL) AND (Student_Photo = @Original_Student_Photo OR @Original_Student_Photo IS N" +
				"ULL AND Student_Photo IS NULL) AND (Student_Postion = @Original_Student_Postion " +
				"OR @Original_Student_Postion IS NULL AND Student_Postion IS NULL) AND (Student_S" +
				"ex = @Original_Student_Sex) AND (Student_StudyCost = @Original_Student_StudyCost" +
				" OR @Original_Student_StudyCost IS NULL AND Student_StudyCost IS NULL); SELECT S" +
				"tudent_ID, Student_Name, Student_Password, Student_Birth, Student_Sex, Student_P" +
				"hoto, Student_Depart, Student_Course, Student_Postion, Room_ID, Student_Email, S" +
				"tudent_LiveCost, Student_StudyCost, Student_Address, Student_Phone FROM Student " +
				"WHERE (Student_ID = @Student_ID)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_ID", System.Data.SqlDbType.BigInt, 8, "Student_ID"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Name", System.Data.SqlDbType.VarChar, 8, "Student_Name"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Password", System.Data.SqlDbType.VarChar, 16, "Student_Password"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Birth", System.Data.SqlDbType.NVarChar, 10, "Student_Birth"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Sex", System.Data.SqlDbType.VarChar, 2, "Student_Sex"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Photo", System.Data.SqlDbType.VarChar, 30, "Student_Photo"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Depart", System.Data.SqlDbType.VarChar, 20, "Student_Depart"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Course", System.Data.SqlDbType.VarChar, 20, "Student_Course"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Postion", System.Data.SqlDbType.VarChar, 20, "Student_Postion"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Room_ID", System.Data.SqlDbType.BigInt, 8, "Room_ID"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Email", System.Data.SqlDbType.VarChar, 30, "Student_Email"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_LiveCost", System.Data.SqlDbType.Money, 8, "Student_LiveCost"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_StudyCost", System.Data.SqlDbType.Money, 8, "Student_StudyCost"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Address", System.Data.SqlDbType.VarChar, 50, "Student_Address"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Phone", System.Data.SqlDbType.VarChar, 12, "Student_Phone"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_ID", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Room_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Room_ID", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Address", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Address", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Birth", System.Data.SqlDbType.NVarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Birth", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Course", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Course", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Depart", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Depart", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Email", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Email", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_LiveCost", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_LiveCost", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Name", System.Data.SqlDbType.VarChar, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Name", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Password", System.Data.SqlDbType.VarChar, 16, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Password", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Phone", System.Data.SqlDbType.VarChar, 12, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Phone", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Photo", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Photo", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Postion", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Postion", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Sex", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Sex", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_StudyCost", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_StudyCost", System.Data.DataRowVersion.Original, null));
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion


		private void Search_Click(object sender, System.EventArgs e)
		{
			
			this.DataGrid1.CurrentPageIndex=0;
			myConn=ConfigurationSettings.AppSettings["mySql"];
			string s;
			s=this.DropDownList1.SelectedValue.ToString()+"="+"'"+this.TextBox1.Text+"'";
			conn=new System.Data.SqlClient.SqlConnection(myConn);
			try
			{
				if(this.TextBox1.Text!="")
				{
					int i=0;
					cmdText="select * from Student where ";
					cmdText=cmdText+s;
					conn.Open();
					cmd=new System.Data.SqlClient.SqlCommand(cmdText,conn);
					reader=cmd.ExecuteReader();
					while(reader.Read())
						i++;
					reader.Close();
					conn.Close();
					this.sqlConnection1=new System.Data.SqlClient.SqlConnection(myConn);
					this.sqlConnection1.Open();
					this.sqlDataAdapter1=new System.Data.SqlClient.SqlDataAdapter(cmdText,this.sqlConnection1);
			
					this.dataSet11=new DataSet1();
					this.sqlDataAdapter1.Fill(this.dataSet11,"Student");
					this.DataGrid1.DataSource=this.dataSet11;
					this.DataGrid1.DataBind();
					this.sqlConnection1.Close();
					this.Label2.Text=this.DropDownList1.SelectedItem.Text+"为"+this.TextBox1.Text+"的学生共有"+Convert.ToString(i)+"人";
				}
				else 
				{
						Response.Write("<script>alert('请输入查询条件!')</script>");
						Data_Bind();
						this.Label2.Text="";
				}
			}
			catch(Exception ex)
			{	
				
				Response.Write("<script>alert('"+ex.Message+"查询条件格式错误!')</script>");
				Data_Bind();
			}
		}


		private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
		{
			DataGrid1.CurrentPageIndex = e.NewPageIndex;
			if(this.TextBox1.Text!="")
				Grid_Bind();
			else if(this.TextBox1.Text=="")
				Data_Bind();
		}
	}
}

⌨️ 快捷键说明

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