📄 student.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace Students
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Student : System.Windows.Forms.Form
{
private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button DepInfo;
private System.Windows.Forms.Button StuInfo;
private System.Windows.Forms.ComboBox comboBox1;
private string select;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.TextBox textBox8;
private System.Windows.Forms.TextBox textBox9;
private string connectstr = "data source=localhost;Initial Catalog=students;User ID=student;Password=student;";
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Student()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
//定义Dataset1类的对象实例myset
Dataset1 myset = new Dataset1();
SqlConnection sqlcnn = new SqlConnection( connectstr );
string sqlstr = "select * from students";
SqlDataAdapter myadapter = new SqlDataAdapter(sqlstr,sqlcnn);
//将从数据库的students表中选出的所有数据放置在myset的名为students表中
myadapter.Fill(myset,"students");
sqlstr = "select * from Department";
SqlDataAdapter myadapter1 = new SqlDataAdapter(sqlstr,sqlcnn);
//将从数据库的Department表中选出的所有数据放置在myset的名为Department表中
myadapter1.Fill(myset,"Department");
//设置程序运行时默认显示的报表
MyRprt1 myrpt = new MyRprt1();
//设置将水晶报表的数据源
myrpt.SetDataSource(myset);
//设置报表查看器中显示的报表
crystalReportViewer1.ReportSource = myrpt;
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Student));
this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.DepInfo = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.textBox9 = new System.Windows.Forms.TextBox();
this.textBox8 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.StuInfo = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// crystalReportViewer1
//
this.crystalReportViewer1.ActiveViewIndex = -1;
this.crystalReportViewer1.BackColor = System.Drawing.Color.White;
this.crystalReportViewer1.Name = "crystalReportViewer1";
this.crystalReportViewer1.ReportSource = null;
this.crystalReportViewer1.Size = new System.Drawing.Size(816, 712);
this.crystalReportViewer1.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.BackColor = System.Drawing.Color.Transparent;
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBox4,
this.textBox3,
this.textBox2,
this.textBox1,
this.label5,
this.label4,
this.label3,
this.DepInfo,
this.label2});
this.groupBox1.ForeColor = System.Drawing.Color.White;
this.groupBox1.Location = new System.Drawing.Point(824, 72);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 240);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "学院信息";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(72, 160);
this.textBox4.Name = "textBox4";
this.textBox4.TabIndex = 12;
this.textBox4.Text = "";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(72, 120);
this.textBox3.Name = "textBox3";
this.textBox3.TabIndex = 11;
this.textBox3.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(72, 80);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 10;
this.textBox2.Text = "";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(72, 40);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 9;
this.textBox1.Text = "";
//
// label5
//
this.label5.Location = new System.Drawing.Point(32, 160);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(32, 23);
this.label5.TabIndex = 8;
this.label5.Text = "备注";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label4
//
this.label4.Location = new System.Drawing.Point(32, 120);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 23);
this.label4.TabIndex = 7;
this.label4.Text = "院长";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 23);
this.label3.TabIndex = 6;
this.label3.Text = "学院名称";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// DepInfo
//
this.DepInfo.Location = new System.Drawing.Point(72, 200);
this.DepInfo.Name = "DepInfo";
this.DepInfo.Size = new System.Drawing.Size(88, 23);
this.DepInfo.TabIndex = 4;
this.DepInfo.Text = "录入信息";
this.DepInfo.Click += new System.EventHandler(this.DepInfo_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 23);
this.label2.TabIndex = 5;
this.label2.Text = "学院编号";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// groupBox2
//
this.groupBox2.BackColor = System.Drawing.Color.Transparent;
this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBox9,
this.textBox8,
this.textBox6,
this.textBox5,
this.label10,
this.label9,
this.label7,
this.label6,
this.StuInfo});
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(824, 328);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(200, 248);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "学生信息";
//
// textBox9
//
this.textBox9.Location = new System.Drawing.Point(72, 160);
this.textBox9.Name = "textBox9";
this.textBox9.TabIndex = 15;
this.textBox9.Text = "";
//
// textBox8
//
this.textBox8.Location = new System.Drawing.Point(72, 120);
this.textBox8.Name = "textBox8";
this.textBox8.TabIndex = 14;
this.textBox8.Text = "";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(72, 80);
this.textBox6.Name = "textBox6";
this.textBox6.TabIndex = 12;
this.textBox6.Text = "";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(72, 40);
this.textBox5.Name = "textBox5";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -