📄 courseinfo.cs
字号:
//
// txt5
//
this.txt5.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.课程名称"));
this.txt5.Location = new System.Drawing.Point(256, 38);
this.txt5.Name = "txt5";
this.txt5.ReadOnly = true;
this.txt5.Size = new System.Drawing.Size(216, 21);
this.txt5.TabIndex = 9;
this.txt5.Text = "";
//
// txt6
//
this.txt6.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.课程简称"));
this.txt6.Location = new System.Drawing.Point(496, 38);
this.txt6.Name = "txt6";
this.txt6.ReadOnly = true;
this.txt6.Size = new System.Drawing.Size(168, 21);
this.txt6.TabIndex = 8;
this.txt6.Text = "";
//
// txt9
//
this.txt9.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.开课系别"));
this.txt9.Location = new System.Drawing.Point(304, 86);
this.txt9.Name = "txt9";
this.txt9.ReadOnly = true;
this.txt9.Size = new System.Drawing.Size(136, 21);
this.txt9.TabIndex = 13;
this.txt9.Text = "";
//
// txt8
//
this.txt8.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.教师"));
this.txt8.Location = new System.Drawing.Point(176, 86);
this.txt8.Name = "txt8";
this.txt8.ReadOnly = true;
this.txt8.Size = new System.Drawing.Size(104, 21);
this.txt8.TabIndex = 12;
this.txt8.Text = "";
//
// txt7
//
this.txt7.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.拼音码"));
this.txt7.Location = new System.Drawing.Point(88, 86);
this.txt7.Name = "txt7";
this.txt7.ReadOnly = true;
this.txt7.Size = new System.Drawing.Size(64, 21);
this.txt7.TabIndex = 11;
this.txt7.Text = "";
//
// label4
//
this.label4.Location = new System.Drawing.Point(88, 22);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(100, 16);
this.label4.TabIndex = 4;
this.label4.Text = "课程编号";
//
// label5
//
this.label5.Location = new System.Drawing.Point(256, 22);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(100, 16);
this.label5.TabIndex = 3;
this.label5.Text = "课程名称";
//
// label6
//
this.label6.Location = new System.Drawing.Point(496, 22);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(100, 16);
this.label6.TabIndex = 2;
this.label6.Text = "课程简称";
//
// label7
//
this.label7.Location = new System.Drawing.Point(304, 72);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(100, 16);
this.label7.TabIndex = 7;
this.label7.Text = "开课系别";
//
// label8
//
this.label8.Location = new System.Drawing.Point(176, 72);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(100, 16);
this.label8.TabIndex = 6;
this.label8.Text = "教师";
//
// label9
//
this.label9.Location = new System.Drawing.Point(88, 70);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(100, 16);
this.label9.TabIndex = 5;
this.label9.Text = "拼音码";
//
// txt10
//
this.txt10.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.学分"));
this.txt10.Location = new System.Drawing.Point(464, 88);
this.txt10.Name = "txt10";
this.txt10.ReadOnly = true;
this.txt10.Size = new System.Drawing.Size(56, 21);
this.txt10.TabIndex = 13;
this.txt10.Text = "";
//
// label10
//
this.label10.Location = new System.Drawing.Point(464, 72);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(32, 16);
this.label10.TabIndex = 7;
this.label10.Text = "学分";
//
// label11
//
this.label11.Location = new System.Drawing.Point(544, 72);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(96, 16);
this.label11.TabIndex = 7;
this.label11.Text = "是否本学期课程";
//
// cmb1
//
this.cmb1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.本学期课程"));
this.cmb1.Enabled = false;
this.cmb1.Items.AddRange(new object[] {
"Y",
"N"});
this.cmb1.Location = new System.Drawing.Point(544, 88);
this.cmb1.Name = "cmb1";
this.cmb1.Size = new System.Drawing.Size(121, 20);
this.cmb1.TabIndex = 14;
//
// CourseInfo
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(728, 502);
this.Name = "CourseInfo";
this.Text = "【课程信息维护】";
this.Load += new System.EventHandler(this.CourseInfo_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
} #endregion
//-----------根据输入,检索信息----------
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);
}
//-----------新建窗体,读入数据----------
private void CourseInfo_Load(object sender, System.EventArgs e)
{
da1.SelectCommand.Parameters[0].SqlDbType=System.Data.SqlDbType.VarChar;//更改类型
da1.SelectCommand.Parameters[0].Value="%";
da1.SelectCommand.Parameters[1].Value="%";
da1.SelectCommand.Parameters[2].Value="%";
da1.Fill(dataSet11);
//设置数据导航控件
this.cmOrders=(CurrencyManager) BindingContext[dataSet11,"课程信息"];
//将基类中的数据集与派生类中的数据集连接
base.dataSet111=this.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;
txt10.ReadOnly=!blnEdit;
cmb1.Enabled=blnEdit;
}
//-------重写新增记录时设置默认值函数--------
protected override void SetDefaultValue()
{
base.SetDefaultValue ();
txt4.Text=this.NewCouseID();//生成新编号
}
//-------重写检查非空字段函数--------
protected override bool CheckNotNull()
{
if(txt4.Text.Trim()=="")// 课程编号不能为空
{
MessageBox.Show("课程编号不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
return(false);
}
if(txt5.Text.Trim()==""||txt6.Text.Trim()=="")// 课程名称不能为空
{
MessageBox.Show("课程名称和简称不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
return(false);
}
if(txt7.Text.Trim()=="")
{
MessageBox.Show("请输入拼音码","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
return(false);
}
if(cmb1.Text.Trim()=="")
{
MessageBox.Show("请先确定该课程是否是本学期课程","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
return(false);
}
return base.CheckNotNull ();
} //--------计算新的课程编号-------- private string NewCouseID() { string strConn="workstation id=localhost;Integrated Security=SSPI;database=eisbook;"; SqlConnection cn=new SqlConnection(strConn); cn.Open(); SqlCommand cmd=cn.CreateCommand(); cmd.CommandText="select max(课程编号) 最大编号 from 课程信息"; int newID=Convert.ToInt32(cmd.ExecuteScalar()); newID++; return(newID.ToString()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -