private void btnSubmit_Click(object sender, EventArgs e) { //接收界面参数 dormType t = new dormType(); t.typeName = this.txtTypeName.Text; string reply1 = "亲,类型名不能为空哦!"; string reply2 = "亲,人数不能为空哦!"; string reply3 = "亲,价格不能为空哦!"; if (Validation.checktxt(t.typeName, ref reply1)) { return; } t.personCount = this.txtPersonCount.Text; if (Validation.checktxt(t.personCount, ref reply2)) { return; } t.price = this.txtPrice.Text; if (Validation.checktxt(t.price, ref reply3)) { return; } string sex = ""; if (rdoMan.Checked) { sex = "男"; } else if (rdoWoman.Checked) { sex = "女"; } t.sex = sex; t.memeo = this.txtMemo.Text; DataTable dt = wsm.findTypeName(this.txtTypeName.Text); if (dt.Rows.Count > 0) { MessageBox.Show("该类型已存在!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //添加进数据库 wsm.insert(t); //关闭当前窗体 this.Close(); MessageBox.Show("添加成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public void flush() { //创建实体类对象 dormType t = new dormType(); //处理界面参数 t.typeName = this.txtTeachTypeName.Text; //查询总条数 page.count = wsm.count(t); DataTable dt = wsm.findAll(t, page); //将数据库中的内容显示到界面上 this.dgvTeachType.DataSource = dt; //给页面上的控件赋值 this.lblPage.Text = "当前:" + page.nowPage + "页 共:" + page.getTotalPage() + "页 总计:" + page.count + "条"; }