📄 form5.cs
字号:
this.备注.Name = "备注";
this.备注.Size = new System.Drawing.Size(64, 16);
this.备注.TabIndex = 24;
this.备注.Text = "备注";
this.备注.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 专业名
//
this.专业名.Location = new System.Drawing.Point(32, 136);
this.专业名.Name = "专业名";
this.专业名.Size = new System.Drawing.Size(64, 16);
this.专业名.TabIndex = 23;
this.专业名.Text = "专业名";
this.专业名.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 姓名
//
this.姓名.Location = new System.Drawing.Point(32, 104);
this.姓名.Name = "姓名";
this.姓名.Size = new System.Drawing.Size(64, 16);
this.姓名.TabIndex = 22;
this.姓名.Text = "姓名";
this.姓名.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 学号
//
this.学号.Location = new System.Drawing.Point(32, 64);
this.学号.Name = "学号";
this.学号.Size = new System.Drawing.Size(64, 16);
this.学号.TabIndex = 21;
this.学号.Text = "学号";
this.学号.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "student", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("学号", "学号"),
new System.Data.Common.DataColumnMapping("姓名", "姓名"),
new System.Data.Common.DataColumnMapping("专业名", "专业名"),
new System.Data.Common.DataColumnMapping("性别", "性别"),
new System.Data.Common.DataColumnMapping("出生时间", "出生时间"),
new System.Data.Common.DataColumnMapping("总学分", "总学分"),
new System.Data.Common.DataColumnMapping("备注", "备注")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE FROM student WHERE (学号 = @Original_学号) AND (专业名 = @Original_专业名) AND (出生时间" +
" = @Original_出生时间) AND (姓名 = @Original_姓名) AND (性别 = @Original_性别) AND (总学分 = @O" +
"riginal_总学分 OR @Original_总学分 IS NULL AND 总学分 IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学号", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "学号", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_专业名", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "专业名", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_出生时间", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "出生时间", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.VarChar, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_性别", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_总学分", System.Data.SqlDbType.TinyInt, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "总学分", System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=8FB25E96FF90450;packet size=4096;integrated security=SSPI;data sou" +
"rce=8FB25E96FF90450;persist security info=False;initial catalog=celery";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO student(学号, 姓名, 专业名, 性别, 出生时间, 总学分, 备注) VALUES (@学号, @姓名, @专业名, @性别, " +
"@出生时间, @总学分, @备注); SELECT 学号, 姓名, 专业名, 性别, 出生时间, 总学分, 备注 FROM student WHERE (学号 " +
"= @学号)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学号", System.Data.SqlDbType.VarChar, 6, "学号"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.VarChar, 8, "姓名"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@专业名", System.Data.SqlDbType.VarChar, 10, "专业名"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@性别", System.Data.SqlDbType.VarChar, 2, "性别"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出生时间", System.Data.SqlDbType.DateTime, 8, "出生时间"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@总学分", System.Data.SqlDbType.TinyInt, 1, "总学分"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 2147483647, "备注"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 学号, 姓名, 专业名, 性别, 出生时间, 总学分, 备注 FROM student";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE student SET 学号 = @学号, 姓名 = @姓名, 专业名 = @专业名, 性别 = @性别, 出生时间 = @出生时间, 总学分 = @总学分, 备注 = @备注 WHERE (学号 = @Original_学号) AND (专业名 = @Original_专业名) AND (出生时间 = @Original_出生时间) AND (姓名 = @Original_姓名) AND (性别 = @Original_性别) AND (总学分 = @Original_总学分 OR @Original_总学分 IS NULL AND 总学分 IS NULL); SELECT 学号, 姓名, 专业名, 性别, 出生时间, 总学分, 备注 FROM student WHERE (学号 = @学号)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学号", System.Data.SqlDbType.VarChar, 6, "学号"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.VarChar, 8, "姓名"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@专业名", System.Data.SqlDbType.VarChar, 10, "专业名"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@性别", System.Data.SqlDbType.VarChar, 2, "性别"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出生时间", System.Data.SqlDbType.DateTime, 8, "出生时间"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@总学分", System.Data.SqlDbType.TinyInt, 1, "总学分"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 2147483647, "备注"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学号", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "学号", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_专业名", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "专业名", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_出生时间", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "出生时间", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.VarChar, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_性别", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_总学分", System.Data.SqlDbType.TinyInt, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "总学分", System.Data.DataRowVersion.Original, null));
//
// label3
//
this.label3.Location = new System.Drawing.Point(0, 288);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(496, 72);
this.label3.TabIndex = 38;
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataSet31.student;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 256);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(496, 96);
this.dataGrid1.TabIndex = 39;
//
// radioButton3
//
this.radioButton3.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet31, "student.性别"));
this.radioButton3.Location = new System.Drawing.Point(328, 64);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(32, 24);
this.radioButton3.TabIndex = 42;
this.radioButton3.Text = "男";
//
// radioButton1
//
this.radioButton1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet31, "student.性别"));
this.radioButton1.Location = new System.Drawing.Point(384, 64);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(32, 24);
this.radioButton1.TabIndex = 43;
this.radioButton1.Text = "女";
//
// Form5
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(504, 349);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.radioButton3);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.label3);
this.Controls.Add(this.返回);
this.Controls.Add(this.insert);
this.Controls.Add(this.all);
this.Controls.Add(this.birthday);
this.Controls.Add(this.memory);
this.Controls.Add(this.department);
this.Controls.Add(this.sname);
this.Controls.Add(this.sno);
this.Controls.Add(this.总学分);
this.Controls.Add(this.出生日期);
this.Controls.Add(this.性别);
this.Controls.Add(this.备注);
this.Controls.Add(this.专业名);
this.Controls.Add(this.姓名);
this.Controls.Add(this.学号);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form5";
this.Text = "修改记录";
this.Load += new System.EventHandler(this.Form5_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet31)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void insert_Click(object sender, System.EventArgs e)
{
DataRow drupdate;
string SNO=sno.Text;
bool sex;
drupdate=dataSet31.Tables["student"].Rows.Find(SNO);
try
{
drupdate.BeginEdit();
drupdate[0]=sno.Text;
drupdate[1]=sname.Text;
drupdate[2]=department.Text;
if(radioButton1.Checked==true)
{
sex=true;
drupdate[3]=sex;
}
else
{
sex=false;
drupdate[3]=sex;
}
drupdate[4]=Convert.ToDateTime(birthday.Text);
drupdate[5]=all.Text;
drupdate[6]=memory.Text;
drupdate.EndEdit();
sqlDataAdapter1.Update(dataSet31,"student");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void label3_Click(object sender, System.EventArgs e)
{
}
private void Form5_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet31);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -