Пример #1
0
    //保存
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (this.Session["uid"] == null || this.Session["uid"].ToString() == "")
        {
            this.Response.Redirect("../login.aspx");
        }

        string ls_tip = "保存成功!";

        TPortalClass.HyContent HyContent = new TPortalClass.HyContent();
        TPortalClass.HyCommon HyCommon = new TPortalClass.HyCommon();

        HyContent.hy_typeid = this.txtcid.Value;
        HyContent.hy_addTime = this.txtpubtime.Text;
        HyContent.hy_title = this.txttitle.Text;
        HyContent.hy_contentcol = this.content1.Value;

        if (this.txtop.Value == "modify")
        {
            HyContent.ID = System.Int32.Parse(this.txtid.Value);
            //写系统日志
            HyCommon.WriteLog("修改", "修改文章记录[id:" + this.txtid.Value + "]", Session["uid"].ToString(), Session["uname"].ToString());

            HyContent.Update();
        }
        else
        {
            //for (int i = 0; i < 1000; i++)
            //{
            //    HyContent.hy_title = this.txttitle.Text + i;
            //    HyContent.Insert();
            //}

            //检查文章是否重复
            if (!HyContent.IsExist())
            {
                //写系统日志
                HyCommon.WriteLog("新增", "新增文章记录[id:" + this.txtid.Value + "]", Session["uid"].ToString(), Session["uname"].ToString());

                HyContent.Insert();
            }
            else
            {
                this.Response.Write("<script>alert('您添加的标题重复了,请重试!');window.location.href = window.location.href;</script>");
                return;
            }
        }
        Response.Write("<script>alert('" + ls_tip + "');window.location='" + this.txturl.Value + "'</script>");
        return;
    }
Пример #2
0
    private void DataPlay()
    {
        if (this.Request.QueryString["op"] != null)
        {
            this.txtop.Value = this.Request.QueryString["op"].ToString();           //新增还是修改
        }
        if (this.Request.QueryString["cid"] != null)
        {
            this.txtcid.Value = this.Request.QueryString["cid"].ToString();     //类别ID
            TPortalClass.HyCategory HyCategory = new TPortalClass.HyCategory();
            DataTable cdt = HyCategory.Getdocbyid(this.txtcid.Value);
            if (cdt.Rows.Count > 0)
            {
                this.lbltype.Text = cdt.Rows[0]["hy_cname"].ToString();

            }
        }
        if (this.Request.QueryString["id"] != null)
        {
            this.txtid.Value = this.Request.QueryString["id"].ToString();     //文档ID
        }
        TPortalClass.HyContent HyContent = new TPortalClass.HyContent();
        //新文档
        if (this.txtop.Value == "add")
        {
            this.txtpubtime.Text = System.DateTime.Now.ToString("yyyy-MM-dd");
        }
        //旧文档
        if (this.txtop.Value == "modify")
        {
            DataTable dt = HyContent.Getdocbyid(int.Parse(this.txtid.Value));
            if (dt.Rows.Count > 0)
            {
                this.txttitle.Text = dt.Rows[0]["hy_title"].ToString();
                this.content1.Value = dt.Rows[0]["hy_contentcol"].ToString();
                this.txtpubtime.Text = DateTime.Parse(dt.Rows[0]["hy_addTime"].ToString()).ToString("yyyy-MM-dd");
            }
        }
    }