コード例 #1
0
    /// <summary>
    /// 绑定内容
    /// </summary>
    /// <param name="_id"></param>
    public void bind_date(int _id)
    {
        Cms.BLL.sc_Product bll = new Cms.BLL.sc_Product();
        DataTable          dt  = bll.GetList("id=" + _id).Tables[0];

        if (dt.Rows.Count > 0)
        {
            ddpid.SelectedValue = dt.Rows[0]["pid"].ToString();
            ddcz.SelectedValue  = dt.Rows[0]["Material"].ToString();
            tbtilte.Text        = dt.Rows[0]["pname"].ToString();
            tbPrice.Text        = Convert.ToDecimal(dt.Rows[0]["Price"]).ToString("0.00");
            tbmarketpice.Text   = Convert.ToDecimal(dt.Rows[0]["marketpice"]).ToString("0.00");
            photoUrl.Text       = dt.Rows[0]["picurl"].ToString();
            tbstock.Text        = dt.Rows[0]["stock"].ToString();
            tbintegral.Text     = dt.Rows[0]["integral"].ToString();
            tbinfo.Value        = dt.Rows[0]["content"].ToString();
            tbProperty.Text     = dt.Rows[0]["Property"].ToString();
            isjf.SelectedValue  = dt.Rows[0]["isjf"].ToString();
        }
    }
コード例 #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Cms.BLL.sc_Product   bll = new Cms.BLL.sc_Product();
        Cms.Model.sc_Product bml = new Cms.Model.sc_Product();
        string action            = this.Request.QueryString["action"] ?? "";//编辑:edit 添加:add
        int    id  = Convert.ToInt32(this.Request.QueryString["id"] ?? "0");
        bool   bl  = false;
        bool   bls = true;

        string urlhot = Request.Url.Host.ToString();

        if (action == "add")
        {
            bml.pid        = int.Parse(ddpid.SelectedValue.ToString());
            bml.Material   = ddcz.SelectedValue.ToString();
            bml.pname      = tbtilte.Text.Trim();
            bml.Price      = Convert.ToDecimal(tbPrice.Text.Trim());
            bml.marketpice = Convert.ToDecimal(tbmarketpice.Text.Trim());
            bml.Property   = tbProperty.Text;
            bml.isjf       = int.Parse(isjf.SelectedValue.ToString());
            bml.picurl     = photoUrl.Text.Trim();
            bml.stock      = int.Parse(tbstock.Text.Trim());
            bml.integral   = int.Parse(tbintegral.Text.Trim());
            bml.content    = tbinfo.Value;
            bml.updatetime = DateTime.Now;

            bl = bll.Add(bml) > 0 ? true : false;
        }
        else
        {
            bml            = bll.GetModel(id);
            bml.pid        = int.Parse(ddpid.SelectedValue.ToString());
            bml.Material   = ddcz.SelectedValue.ToString();
            bml.pname      = tbtilte.Text.Trim();
            bml.Price      = Convert.ToDecimal(tbPrice.Text.Trim());
            bml.marketpice = Convert.ToDecimal(tbmarketpice.Text.Trim());
            bml.Property   = tbProperty.Text;
            bml.isjf       = int.Parse(isjf.SelectedValue.ToString());
            bml.picurl     = photoUrl.Text.Trim();
            bml.stock      = int.Parse(tbstock.Text.Trim());
            bml.integral   = int.Parse(tbintegral.Text.Trim());
            bml.content    = tbinfo.Value;
            bml.updatetime = DateTime.Now;
            bl             = bll.Update(bml);
        }
        if (bl && bls)
        {
            if (action == "add")
            {
                adminUser.AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加产品" + tbtilte.Text); //记录日志
                ShowConfirm("是否继续添加?", "productedit.aspx?action=add", "productlist.aspx");
            }
            else
            {
                adminUser.AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "修改产品" + tbtilte.Text); //记录日志
                JscriptMsg("提交成功!", "productlist.aspx", "Success");
            }
        }
        else
        {
            JscriptMsg("提交失败!", "productedit.aspx?action=edit?id=" + id, "Error");
        }
    }