private void btnOk_Click(object sender, EventArgs e) { if (IsEmpty()) { return; } CategoryInfo newCategory = new CategoryInfo(); newCategory.CName = txtCName.Text; newCategory.CNum = txtCNum.Text; newCategory.CRemark = txtCRemark.Text; CategoryInfoBLL categorybll = new CategoryInfoBLL(); int i = 0; //插入时,给未在窗体显示的值添加默认值 if (status == HandleStatus.Insert) { newCategory.DelFlag = 0; newCategory.SubBy = 1; newCategory.SubTime = DateTime.Now; i = categorybll.add(newCategory); } //更新时,将未在窗体显示的值赋予原来的值 if (status == HandleStatus.Update) { newCategory.CId = oldCategory.CId; newCategory.DelFlag = oldCategory.DelFlag; newCategory.SubBy = oldCategory.SubBy; newCategory.SubTime = oldCategory.SubTime; i = categorybll.update(newCategory); } string msg = i > 0 ? "操作成功" : "操作失败"; md.MsgDivShow(msg, 1, Bind); }