private void btnAddyuan_Click(object sender, EventArgs e) { CollegesBLL college = new CollegesBLL(); CollegesModel model = new CollegesModel(); if (this.txtyuanbian.TextLength != 2) { MessageBox.Show("学院编号只能为两位"); this.txtyuanbian.Text = ""; return; } model.College_ID = this.txtyuanbian.Text; bool b = college.SeleColleges(model); if (b == true) { MessageBox.Show("编号已存在,请重新输入"); this.txtyuanbian.Text = ""; return; } if (string.IsNullOrEmpty(this.txtyuanbian.Text)) { MessageBox.Show("学院编号不能为空"); return; } if (string.IsNullOrEmpty(this.txtyuanName.Text)) { MessageBox.Show("学院名称不能为空"); return; } try { model.College_ID = this.txtyuanbian.Text; } catch { MessageBox.Show("学院编号重复"); this.txtyuanbian.Text = ""; } model.College_Name = this.txtyuanName.Text; college.AddColleges(model); GetAllColleges(); }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { CollegesBLL college = new CollegesBLL(); CollegesModel model = new CollegesModel(); if (this.txtyuanbian.TextLength != 2) { MessageBox.Show("学院编号只能为两位"); this.txtyuanbian.Text = ""; return; } model.College_ID = this.txtyuanbian.Text; bool b = college.SeleColleges(model); if (b == true) { MessageBox.Show("编号已存在,请重新输入"); this.txtyuanbian.Text = ""; return; } }