Exemplo n.º 1
0
    /// <summary>
    /// 确定提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strError = Validates();

        if (strError != "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + strError + "');</script>");
            return;
        }
        model.CategoryId  = Convert.ToInt32(this.ddlType.SelectedValue);
        model.MarketId    = Convert.ToInt32(this.ddlMarket.SelectedValue);
        model.Titie       = SafeRequest.GetFormString("txtTitle");
        model.ReleaseDate = System.DateTime.Now;
        model.AddedDate   = System.DateTime.Now;
        model.ExpireDate  = System.DateTime.Now;
        model.Body        = SafeRequest.GetFormString("fckBody");
        model.Approved    = 1;
        model.AddedUserId = Convert.ToInt32(this.UserId);//默认登录进来人的编号
        if (_Pid != "")
        {
            model.ArticleId = Convert.ToInt32(_Pid);
            if (bll.Update(model))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            if (bll.Add(model) > 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('添加成功');layer_close_refresh();</script>");
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 确定提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strError = Validates();

        if (strError != "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + strError + "');</script>");
            return;
        }
        model.CategoryId  = Convert.ToInt32(this.ddlType.SelectedValue);
        model.Titie       = SafeRequest.GetFormString("txtTitle");
        model.ReleaseDate = Convert.ToDateTime(this.txtReleaseDate.Text.Trim());
        model.AddedDate   = System.DateTime.Now;
        model.ExpireDate  = System.DateTime.Now;
        model.Body        = SafeRequest.GetFormString("fckBody");
        model.Approved    = SafeRequest.GetFormInt("radioApproved", 0);
        model.AddedUserId = Convert.ToInt32(this.UserId);//默认登录进来人的编号
        if (_Pid != "")
        {
            model.ArticleId = Convert.ToInt32(_Pid);
            if (bll.Update(model))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            int ret = bll.Add(model);
            if (ret == -2)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<Script>alert('该类别只允许添加1篇文章,请到列表中查找然后修改!');</Script>");
            }
            else
            {
                if (ret > 0)
                {
                    JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString());
                }
            }
        }
    }