protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsDateTime(txtAddTime.Text)) { strErr += "发布时间格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } String Name = this.txtName.Text; int Fk_NewsType_Id = int.Parse(this.ddlFk_NewsType_Id.SelectedValue); String Contents = this.txtContents.Text; int Fk_Users_Id = int.Parse(this.ddlFk_Users_Id.SelectedValue); DateTime AddTime = DateTime.Parse(this.txtAddTime.Text); Maticsoft.Model.News model = new Maticsoft.Model.News(); model.Name = Name; model.Fk_NewsType_Id = Fk_NewsType_Id; model.Contents = Contents; model.Fk_Users_Id = Fk_Users_Id; model.AddTime = AddTime; Maticsoft.BLL.News bll = new Maticsoft.BLL.News(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "Add.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtTitle.Text.Trim().Length == 0) { strErr += "标题不能为空!\\n"; } if (this.txtContent.Text.Trim().Length == 0) { strErr += "内容不能为空!\\n"; } if (!PageValidate.IsDateTime(txtTime.Text)) { strErr += "发布时间格式错误!\\n"; } if (this.txtAttachment.Text.Trim().Length == 0) { strErr += "附件不能为空!\\n"; } if (!PageValidate.IsNumber(txtGroupID.Text)) { strErr += "分组格式错误!\\n"; } if (!PageValidate.IsNumber(txtClick.Text)) { strErr += "点击数格式错误!\\n"; } if (!PageValidate.IsNumber(txtNo.Text)) { strErr += "No格式错误!\\n"; } if (!PageValidate.IsNumber(txtMark.Text)) { strErr += "Mark格式错误!\\n"; } if (this.txtS1.Text.Trim().Length == 0) { strErr += "S1不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string Title = this.txtTitle.Text; string Content = this.txtContent.Text; DateTime Time = DateTime.Parse(this.txtTime.Text); string Attachment = this.txtAttachment.Text; int GroupID = int.Parse(this.txtGroupID.Text); bool IsOpen = this.chkIsOpen.Checked; int Click = int.Parse(this.txtClick.Text); int No = int.Parse(this.txtNo.Text); int Mark = int.Parse(this.txtMark.Text); string S1 = this.txtS1.Text; Maticsoft.Model.News model = new Maticsoft.Model.News(); model.Title = Title; model.Content = Content; model.Time = Time; model.Attachment = Attachment; model.GroupID = GroupID; model.IsOpen = IsOpen; model.Click = Click; model.No = No; model.Mark = Mark; model.S1 = S1; Maticsoft.BLL.News bll = new Maticsoft.BLL.News(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }