protected void Button1_Click(object sender, EventArgs e) { //1.把界面修改过的内容放置到实体对象 mdlnews.newsId = int.Parse(UserId.Value); mdlnews.typeId = int.Parse(TBnewType.Text); mdlnews.newsTitle = TBnewsTitle.Text; mdlnews.newsContent = TBnewsContent.Text; mdlnews.typeId = int.Parse(TBnewsUser.Text); mdlnews.newsReleaseTime = DateTime.Parse(TBnewsReleaseTime.Text); //2.把新的信息,传给业务逻辑更新到数据库 bllnews.Update(mdlnews); Response.Redirect("newsQuery.aspx"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtuserId.Text)) { strErr += "userId格式错误!\\n"; } if (!PageValidate.IsNumber(txtTypeId.Text)) { strErr += "typeId格式错误!\\n"; } if (this.txtnewsTitle.Text.Trim().Length == 0) { strErr += "newsTitle不能为空!\\n"; } if (this.txtnewsContent.Text.Trim().Length == 0) { strErr += "newsContent不能为空!\\n"; } if (!PageValidate.IsNumber(txtnewsCount.Text)) { strErr += "newsCount格式错误!\\n"; } if (!PageValidate.IsDateTime(txtnewsReleaseTime.Text)) { strErr += "newsReleaseTime格式错误!\\n"; } if (this.txtext1.Text.Trim().Length == 0) { strErr += "ext1不能为空!\\n"; } if (this.txtext2.Text.Trim().Length == 0) { strErr += "ext2不能为空!\\n"; } if (this.txtext3.Text.Trim().Length == 0) { strErr += "ext3不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int newsId = int.Parse(this.lblnewsId.Text); int userId = int.Parse(this.txtuserId.Text); int typeId = int.Parse(this.txtTypeId.Text); string newsTitle = this.txtnewsTitle.Text; string newsContent = this.txtnewsContent.Text; int newsCount = int.Parse(this.txtnewsCount.Text); DateTime newsReleaseTime = DateTime.Parse(this.txtnewsReleaseTime.Text); string ext1 = this.txtext1.Text; string ext2 = this.txtext2.Text; string ext3 = this.txtext3.Text; rr2.Model.newsInfo model = new rr2.Model.newsInfo(); model.newsId = newsId; model.userId = userId; model.typeId = typeId; model.newsTitle = newsTitle; model.newsContent = newsContent; model.newsCount = newsCount; model.newsReleaseTime = newsReleaseTime; model.ext1 = ext1; model.ext2 = ext2; model.ext3 = ext3; rr2.BLL.newsInfo bll = new rr2.BLL.newsInfo(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }