form1.cs
来自「C#经典范例50讲」· CS 代码 · 共 294 行 · 第 1/2 页
CS
294 行
//
// oleDbDataAdapter2
//
this.oleDbDataAdapter2.InsertCommand = this.oleDbInsertCommand2;
this.oleDbDataAdapter2.SelectCommand = this.oleDbSelectCommand2;
this.oleDbDataAdapter2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "book", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("username", "username"),
new System.Data.Common.DataColumnMapping("bookname", "bookname"),
new System.Data.Common.DataColumnMapping("description", "description")})});
//
// oleDbInsertCommand2
//
this.oleDbInsertCommand2.CommandText = "INSERT INTO book(username, bookname, description) VALUES (?, ?, ?)";
this.oleDbInsertCommand2.Connection = this.oleDbConnection1;
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("username", System.Data.OleDb.OleDbType.VarWChar, 20, "username"));
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("bookname", System.Data.OleDb.OleDbType.VarWChar, 50, "bookname"));
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("description", System.Data.OleDb.OleDbType.VarWChar, 50, "description"));
//
// oleDbSelectCommand2
//
this.oleDbSelectCommand2.CommandText = "SELECT username, bookname, description FROM book";
this.oleDbSelectCommand2.Connection = this.oleDbConnection1;
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
this.dataSet11.Namespace = "http://www.tempuri.org/DataSet1.xsd";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(67, 18);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(144, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 18);
this.label2.TabIndex = 2;
this.label2.Text = "地址:";
//
// textBox1
//
this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "user.address"));
this.textBox1.Location = new System.Drawing.Point(192, 40);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(200, 25);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(144, 104);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(60, 18);
this.label3.TabIndex = 4;
this.label3.Text = "Email:";
//
// textBox2
//
this.textBox2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "user.Email"));
this.textBox2.Location = new System.Drawing.Point(192, 96);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(200, 25);
this.textBox2.TabIndex = 5;
this.textBox2.Text = "";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(16, 128);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(52, 18);
this.label4.TabIndex = 6;
this.label4.Text = "书籍:";
//
// dataGrid1
//
this.dataGrid1.DataMember = "user.userbook";
this.dataGrid1.DataSource = this.dataSet11;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16, 152);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(376, 152);
this.dataGrid1.TabIndex = 7;
//
// listBox1
//
this.listBox1.DataSource = this.dataSet11;
this.listBox1.DisplayMember = "user.username";
this.listBox1.ItemHeight = 15;
this.listBox1.Location = new System.Drawing.Point(16, 32);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 94);
this.listBox1.TabIndex = 8;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
this.ClientSize = new System.Drawing.Size(402, 312);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.listBox1,
this.dataGrid1,
this.label4,
this.textBox2,
this.label3,
this.textBox1,
this.label2,
this.label1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "主控明细数据库显示";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
dataSet11.Clear();
oleDbDataAdapter1.Fill(dataSet11);
oleDbDataAdapter2.Fill(dataSet11);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?