コード例 #1
0
ファイル: Edit.aspx.cs プロジェクト: crestviewshanghai/Tony
 protected void lnbRemoveImage_Click(object sender, EventArgs e)
 {
     MojoCube.Web.Product.List list = new MojoCube.Web.Product.List();
     list.GetData(int.Parse(ViewState["pk_Product"].ToString()));
     list.ImagePath = string.Empty;
     list.UpdateData(list.pk_Product);
     imgMain.Attributes.Add("style", "display:none");
     lnbRemoveImage.Visible = false;
 }
コード例 #2
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        MojoCube.Web.Product.List list = new MojoCube.Web.Product.List();
        int index = 0;

        //删除
        if (e.CommandName == "_delete")
        {
            index = Convert.ToInt32(e.CommandArgument);
            list.DeleteData(int.Parse(((Label)GridView1.Rows[index].FindControl("lblID")).Text));
        }
        GridBind();
    }
コード例 #3
0
ファイル: Edit.aspx.cs プロジェクト: crestviewshanghai/Tony
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtProductName.Text.Trim() == "" || txtNumber.Text.Trim() == "")
        {
            AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请填写产品名称和产品编号");
            return;
        }

        MojoCube.Api.File.Upload upload = new MojoCube.Api.File.Upload();
        upload.FilePath = "Product/" + txtNumber.Text.Trim();
        upload.FileName = MojoCube.Api.Text.Function.DateTimeString(true);
        upload.DoFileUpload(fuImage);

        MojoCube.Web.Product.List list = new MojoCube.Web.Product.List();

        //修改
        if (ViewState["pk_Product"] != null)
        {
            list.GetData(int.Parse(ViewState["pk_Product"].ToString()));

            MojoCube.Web.Product.Category category = new MojoCube.Web.Product.Category();
            category.GetData(int.Parse(ddlCategory.SelectedValue));

            if (category.ParentID == 0)
            {
                list.CategoryID1 = category.pk_Category;
                list.CategoryID2 = 0;
            }
            else
            {
                list.CategoryID1 = category.ParentID;
                list.CategoryID2 = category.pk_Category;
            }

            list.Number          = txtNumber.Text.Trim();
            list.PageName        = txtPageName.Text.Trim();
            list.ProductName     = txtProductName.Text.Trim();
            list.Price           = MojoCube.Web.String.ToDecimal(txtPrice.Text.Trim());
            list.Subtitle        = txtSubtitle.Text.Trim();
            list.Description     = txtDescription.Text.Trim();
            list.Attribute       = txtAttribute.Text.Trim();
            list.Issue           = cbIssue.Checked;
            list.IsComment       = cbComment.Checked;
            list.SEO_Title       = txtSEO_Title.Text.Trim();
            list.SEO_Keyword     = txtSEO_Keyword.Text.Trim();
            list.SEO_Description = txtSEO_Description.Text.Trim();
            if (upload.IsUpload)
            {
                list.ImagePath = upload.OldFilePath;
                SetImage(list.ImagePath);
            }
            list.ModifyDate   = DateTime.Now.ToString();
            list.ModifyUserID = int.Parse(Session["UserID"].ToString());
            list.UpdateData(list.pk_Product);
        }
        //新增
        else
        {
            MojoCube.Web.Product.Category category = new MojoCube.Web.Product.Category();
            category.GetData(int.Parse(ddlCategory.SelectedValue));

            if (category.ParentID == 0)
            {
                list.CategoryID1 = category.pk_Category;
                list.CategoryID2 = 0;
            }
            else
            {
                list.CategoryID1 = category.ParentID;
                list.CategoryID2 = category.pk_Category;
            }

            list.Number      = txtNumber.Text.Trim();
            list.PageName    = txtPageName.Text.Trim();
            list.ProductName = txtProductName.Text.Trim();
            list.Subtitle    = txtSubtitle.Text.Trim();
            list.Description = txtDescription.Text.Trim();
            list.Attribute   = txtAttribute.Text.Trim();
            if (txtSEO_Title.Text.Trim() != "")
            {
                list.SEO_Title = txtSEO_Title.Text.Trim();
            }
            else
            {
                list.SEO_Title = txtProductName.Text.Trim();
            }
            list.SEO_Keyword     = txtSEO_Keyword.Text.Trim();
            list.SEO_Description = txtSEO_Description.Text.Trim();
            list.Tags            = string.Empty;
            list.Visual          = string.Empty;
            list.Price           = MojoCube.Web.String.ToDecimal(txtPrice.Text.Trim());
            list.Qty             = 0;
            list.Location        = string.Empty;
            list.CountryID       = 0;
            list.ProvinceID      = 0;
            list.CityID          = 0;
            if (upload.IsUpload)
            {
                list.ImagePath = upload.OldFilePath;
                SetImage(list.ImagePath);
            }
            else
            {
                list.ImagePath = string.Empty;
            }
            list.Issue              = cbIssue.Checked;
            list.IsComment          = cbComment.Checked;
            list.IsRecommend        = false;
            list.Clicks             = 0;
            list.SortID             = 0;
            list.TypeID             = 0;
            list.StatusID           = 0;
            list.Score              = 0;
            list.ScoreIn            = 0;
            list.Sales              = 0;
            list.SpecialPrice       = 0;
            list.Freight            = 0;
            list.StartDate          = DateTime.Now.ToString();
            list.EndDate            = DateTime.Now.ToString();
            list.CreateDate         = DateTime.Now.ToString();
            list.CreateUserID       = int.Parse(Session["UserID"].ToString());
            list.ModifyDate         = DateTime.Now.ToString();
            list.ModifyUserID       = 0;
            list.Language           = MojoCube.Api.UI.Language.GetLanguage();
            ViewState["pk_Product"] = list.InsertData();
        }

        ImageBind();

        AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("success", "数据保存成功");
    }
コード例 #4
0
ファイル: Edit.aspx.cs プロジェクト: crestviewshanghai/Tony
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            MojoCube.Web.Sql.BindClass(ddlCategory, "Product_Category");

            if (Request.QueryString["id"] != null)
            {
                ViewState["pk_Product"] = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["id"]);

                MojoCube.Web.Product.List list = new MojoCube.Web.Product.List();
                list.GetData(int.Parse(ViewState["pk_Product"].ToString()));

                txtProductName.Text     = list.ProductName;
                txtDescription.Text     = list.Description;
                txtPageName.Text        = list.PageName;
                txtNumber.Text          = list.Number;
                txtPrice.Text           = list.Price.ToString();
                txtAttribute.Text       = list.Attribute;
                txtSubtitle.Text        = list.Subtitle;
                cbIssue.Checked         = list.Issue;
                cbComment.Checked       = list.IsComment;
                txtSEO_Title.Text       = list.SEO_Title;
                txtSEO_Keyword.Text     = list.SEO_Keyword;
                txtSEO_Description.Text = list.SEO_Description;

                if (list.CategoryID2 > 0)
                {
                    MojoCube.Web.Sql.ddlFindByValue(ddlCategory, list.CategoryID2.ToString());
                }
                else
                {
                    MojoCube.Web.Sql.ddlFindByValue(ddlCategory, list.CategoryID1.ToString());
                }

                if (list.ImagePath != "")
                {
                    SetImage(list.ImagePath);
                }

                ImageBind();

                this.Title = "产品编辑:" + txtProductName.Text.Trim();
            }
            else
            {
                string parentId = "0";

                if (Request.QueryString["parentId"] != null)
                {
                    parentId = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["parentId"]);
                }

                MojoCube.Web.Sql.ddlFindByValue(ddlCategory, parentId);

                txtPageName.Text  = MojoCube.Web.String.GetPageName();
                txtNumber.Text    = txtPageName.Text.Trim();
                cbIssue.Checked   = true;
                cbComment.Checked = true;

                this.Title = "产品编辑";
            }

            if (ddlCategory.SelectedValue != "0")
            {
                hlBack.NavigateUrl = "List.aspx?parentId=" + MojoCube.Api.Text.Security.EncryptString(ddlCategory.SelectedValue) + "&active=" + Request.QueryString["active"];
            }
            else
            {
                hlBack.NavigateUrl = "List.aspx?active=" + Request.QueryString["active"];
            }
        }
    }