public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtzixunTitle.Text.Trim().Length == 0) { strErr += "zixunTitle不能为空!\\n"; } if (!PageValidate.IsDateTime(txtzixuntime.Text)) { strErr += "zixuntime格式错误!\\n"; } if (this.txtzixuncontent.Text.Trim().Length == 0) { strErr += "zixuncontent不能为空!\\n"; } if (this.txtzixunUserName.Text.Trim().Length == 0) { strErr += "zixunUserName不能为空!\\n"; } if (this.txtzixunuserPhoto.Text.Trim().Length == 0) { strErr += "zixunuserPhoto不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int zixunID = int.Parse(this.lblzixunID.Text); string zixunTitle = this.txtzixunTitle.Text; DateTime zixuntime = DateTime.Parse(this.txtzixuntime.Text); string zixuncontent = this.txtzixuncontent.Text; string zixunUserName = this.txtzixunUserName.Text; string zixunuserPhoto = this.txtzixunuserPhoto.Text; Maticsoft.Model.ZiXunInfo model = new Maticsoft.Model.ZiXunInfo(); model.zixunID = zixunID; model.zixunTitle = zixunTitle; model.zixuntime = zixuntime; model.zixuncontent = zixuncontent; model.zixunUserName = zixunUserName; model.zixunuserPhoto = zixunuserPhoto; Maticsoft.BLL.ZiXunInfo bll = new Maticsoft.BLL.ZiXunInfo(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
protected void btnok_Click(object sender, EventArgs e) { Maticsoft.BLL.ZiXunInfo zixunbll = new Maticsoft.BLL.ZiXunInfo(); Maticsoft.Model.ZiXunInfo zixunmodel = zixunbll.GetModel(1); if (txtusename.Text.Trim() == "") { lblusername.Text = "请填写提问人姓名"; return; } zixunmodel.zixunUserName = txtusename.Text.Trim(); lblusername.Text = ""; if (txtlinkphoto.Text.Trim() == "") { lbllinkphoto.Text = "请填写您的联系方式"; return; } zixunmodel.zixunuserPhoto = txtlinkphoto.Text.Trim(); lbllinkphoto.Text = ""; if (txtzixuntitle.Text.Trim() == "") { lbltitile.Text = "请填写提问标题"; return; } zixunmodel.zixunTitle = txtzixuntitle.Text.Trim(); lbltitile.Text = ""; if (txtzixuncontent.Text.Trim() == "") { lblcontent.Text = "请填写提问内容"; return; } zixunmodel.zixuncontent = txtzixuncontent.Text.Trim(); lblcontent.Text = ""; if (txtzixundaan.Text.Trim() == "") { lbldaan.Text = "请填写您的答案"; return; } zixunmodel.ZiXundaan = txtzixundaan.Text.Trim(); lbldaan.Text = ""; zixunbll.Update(zixunmodel); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>"); bind(); }