Пример #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtWeiTitle.Text.Trim().Length == 0)
            {
                strErr += "WeiTitle不能为空!\\n";
            }
            if (this.txtWeiKey.Text.Trim().Length == 0)
            {
                strErr += "WeiKey不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtFatime.Text))
            {
                strErr += "Fatime格式错误!\\n";
            }
            if (this.txtWrite.Text.Trim().Length == 0)
            {
                strErr += "Write不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtHitNum.Text))
            {
                strErr += "HitNum格式错误!\\n";
            }
            if (this.txtWeicontent.Text.Trim().Length == 0)
            {
                strErr += "Weicontent不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   WeiTitle   = this.txtWeiTitle.Text;
            string   WeiKey     = this.txtWeiKey.Text;
            DateTime Fatime     = DateTime.Parse(this.txtFatime.Text);
            string   Write      = this.txtWrite.Text;
            int      HitNum     = int.Parse(this.txtHitNum.Text);
            string   Weicontent = this.txtWeicontent.Text;

            Maticsoft.Model.WeiLanInfo model = new Maticsoft.Model.WeiLanInfo();
            model.WeiTitle   = WeiTitle;
            model.WeiKey     = WeiKey;
            model.Fatime     = Fatime;
            model.Write      = Write;
            model.HitNum     = HitNum;
            model.Weicontent = Weicontent;

            Maticsoft.BLL.WeiLanInfo bll = new Maticsoft.BLL.WeiLanInfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Пример #2
0
 protected void btnok_Click(object sender, EventArgs e)
 {
     Maticsoft.BLL.WeiLanInfo   weilanbll   = new Maticsoft.BLL.WeiLanInfo();
     Maticsoft.Model.WeiLanInfo weilanmodel = new Maticsoft.Model.WeiLanInfo();
     if (txtzhishititle.Text.Trim() == "")
     {
         lbltitle.Text = "请填写围栏标题";
         return;
     }
     weilanmodel.WeiTitle = txtzhishititle.Text.Trim();
     lbltitle.Text        = "";
     if (txtkeyword.Text.Trim() == "")
     {
         lblkeyword.Text = "请填写关键字";
         return;
     }
     weilanmodel.WeiKey = txtkeyword.Text.Trim();
     lblkeyword.Text    = "";
     if (txtFatime.Text.Trim() == "")
     {
         lblfatime.Text = "请填写发布时间";
         return;
     }
     weilanmodel.Fatime = Convert.ToDateTime(txtFatime.Text.Trim());
     lblfatime.Text     = "";
     if (txtwrite.Text.Trim() == "")
     {
         lblwrite.Text = "请填写发布人";
         return;
     }
     weilanmodel.Write      = txtwrite.Text.Trim();
     lblwrite.Text          = "";
     weilanmodel.Weicontent = txtcontent.Text.Trim();
     weilanbll.Add(weilanmodel);
     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>");
     txtcontent.Text     = string.Empty;
     txtFatime.Text      = string.Empty;
     txtkeyword.Text     = string.Empty;
     txtwrite.Text       = string.Empty;
     txtzhishititle.Text = string.Empty;
 }