?? classinfo.cs
字號:
this.sqlDeleteCommand1.CommandText = @"DELETE FROM 班級信息 WHERE (班級編號 = @Original_班級編號) AND (人數 = @Original_人數 OR @Original_人數 IS NULL AND 人數 IS NULL) AND (年級 = @Original_年級 OR @Original_年級 IS NULL AND 年級 IS NULL) AND (班主任 = @Original_班主任 OR @Original_班主任 IS NULL AND 班主任 IS NULL) AND (班級名稱 = @Original_班級名稱 OR @Original_班級名稱 IS NULL AND 班級名稱 IS NULL) AND (班級簡稱 = @Original_班級簡稱 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, 14, 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.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(3)), ((System.Byte)(0)), "人數", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_年級", System.Data.SqlDbType.VarChar, 4, 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, 30, 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, 16, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "班級簡稱", System.Data.DataRowVersion.Original, null));
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// label4
//
this.label4.Location = new System.Drawing.Point(64, 32);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(100, 16);
this.label4.TabIndex = 0;
this.label4.Text = "班級編號";
//
// txt4
//
this.txt4.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班級信息.班級編號"));
this.txt4.Location = new System.Drawing.Point(64, 48);
this.txt4.Name = "txt4";
this.txt4.ReadOnly = true;
this.txt4.Size = new System.Drawing.Size(136, 21);
this.txt4.TabIndex = 1;
this.txt4.Text = "";
//
// txt5
//
this.txt5.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班級信息.年級"));
this.txt5.Location = new System.Drawing.Point(232, 48);
this.txt5.Name = "txt5";
this.txt5.ReadOnly = true;
this.txt5.Size = new System.Drawing.Size(136, 21);
this.txt5.TabIndex = 1;
this.txt5.Text = "";
//
// label5
//
this.label5.Location = new System.Drawing.Point(232, 32);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(100, 16);
this.label5.TabIndex = 0;
this.label5.Text = "年級";
//
// label6
//
this.label6.Location = new System.Drawing.Point(408, 32);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(100, 16);
this.label6.TabIndex = 0;
this.label6.Text = "班級名稱";
//
// txt6
//
this.txt6.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班級信息.班級名稱"));
this.txt6.Location = new System.Drawing.Point(408, 48);
this.txt6.Name = "txt6";
this.txt6.ReadOnly = true;
this.txt6.Size = new System.Drawing.Size(136, 21);
this.txt6.TabIndex = 1;
this.txt6.Text = "";
//
// txt9
//
this.txt9.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班級信息.班主任"));
this.txt9.Location = new System.Drawing.Point(408, 96);
this.txt9.Name = "txt9";
this.txt9.ReadOnly = true;
this.txt9.Size = new System.Drawing.Size(136, 21);
this.txt9.TabIndex = 1;
this.txt9.Text = "";
//
// label7
//
this.label7.Location = new System.Drawing.Point(408, 80);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(100, 16);
this.label7.TabIndex = 0;
this.label7.Text = "班主任";
//
// label8
//
this.label8.Location = new System.Drawing.Point(232, 80);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(100, 16);
this.label8.TabIndex = 0;
this.label8.Text = "人數";
//
// txt8
//
this.txt8.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班級信息.班級簡稱"));
this.txt8.Location = new System.Drawing.Point(232, 96);
this.txt8.Name = "txt8";
this.txt8.ReadOnly = true;
this.txt8.Size = new System.Drawing.Size(136, 21);
this.txt8.TabIndex = 1;
this.txt8.Text = "";
//
// txt7
//
this.txt7.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班級信息.班級簡稱"));
this.txt7.Location = new System.Drawing.Point(64, 96);
this.txt7.Name = "txt7";
this.txt7.ReadOnly = true;
this.txt7.Size = new System.Drawing.Size(136, 21);
this.txt7.TabIndex = 1;
this.txt7.Text = "";
//
// label9
//
this.label9.Location = new System.Drawing.Point(64, 80);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(100, 16);
this.label9.TabIndex = 0;
this.label9.Text = "班級簡稱";
//
// ClassInfo
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(728, 502);
this.Name = "ClassInfo";
this.Text = "【班級信息維護】";
this.Load += new System.EventHandler(this.ClassInfo_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
} #endregion
//--------創建窗體時,讀入數據-------
private void ClassInfo_Load(object sender, System.EventArgs e)
{
da1.SelectCommand.Parameters[0].Value="%";
da1.SelectCommand.Parameters[1].Size=8;//4位年份輸入
da1.SelectCommand.Parameters[1].Value="%";
da1.SelectCommand.Parameters[2].Value="%";
da1.Fill(dataSet11);
//設置數據導航控件
this.cmOrders=(CurrencyManager) BindingContext[dataSet11,"班級信息"];
//將基類中的數據集與派生類中的數據集連接
base.dataSet11=this.dataSet11;
}
//-----------根據輸入,檢索信息----------
private void btnSearch_Click(object sender, System.EventArgs e)
{
da1.SelectCommand.Parameters[0].Value="%";
da1.SelectCommand.Parameters[1].Value="%";
da1.SelectCommand.Parameters[2].Value="%";
if(txt1.Text.Trim()!="")
{
da1.SelectCommand.Parameters[0].Value="%"+txt1.Text.Trim()+"%";
}
if(txt2.Text.Trim()!="")
{
da1.SelectCommand.Parameters[1].Value="%"+txt2.Text.Trim()+"%";
}
if(txt3.Text.Trim()!="")
{
da1.SelectCommand.Parameters[2].Value="%"+txt3.Text.Trim()+"%";
}
dataSet11.Clear();//刷新數據集
da1.Fill(dataSet11);
}
//----------重寫設置控件只讀屬性函數----------
protected override void SetModifyMode(bool blnEdit)
{
base.SetModifyMode (blnEdit);
txt4.ReadOnly=!blnEdit;
txt5.ReadOnly=!blnEdit;
txt6.ReadOnly=!blnEdit;
txt7.ReadOnly=!blnEdit;
txt8.ReadOnly=!blnEdit;
txt9.ReadOnly=!blnEdit;
}
//-------重寫新增記錄時設置默認值函數--------
protected override void SetDefaultValue()
{
base.SetDefaultValue ();
}
//-------重寫檢查非空字段函數--------
protected override bool CheckNotNull()
{
if(txt4.Text.Trim()=="")// 班級編號不能為空
{
MessageBox.Show("班級編號不能為空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
return(false);
}
return base.CheckNotNull ();
} }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -