Example #1
0
 protected void lnbRemoveImage_Click(object sender, EventArgs e)
 {
     MojoCube.Web.Album.List list = new MojoCube.Web.Album.List();
     list.GetData(int.Parse(ViewState["pk_Album"].ToString()));
     list.ImagePath = string.Empty;
     list.UpdateData(list.pk_Album);
     imgMain.Attributes.Add("style", "display:none");
     lnbRemoveImage.Visible = false;
 }
Example #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtTitle.Text.Trim() == "")
        {
            AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请填写标题");
            return;
        }

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

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

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

            MojoCube.Web.Album.Category category = new MojoCube.Web.Album.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.Title           = txtTitle.Text.Trim();
            list.PageName        = txtPageName.Text.Trim();
            list.Subtitle        = txtSubtitle.Text.Trim();
            list.Description     = txtDescription.Text.Trim();
            list.Issue           = cbIssue.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_Album);
        }
        //新增
        else
        {
            MojoCube.Web.Album.Category category = new MojoCube.Web.Album.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.PageName    = txtPageName.Text.Trim();
            list.Title       = txtTitle.Text.Trim();
            list.Subtitle    = txtSubtitle.Text.Trim();
            list.Description = txtDescription.Text.Trim();
            if (txtSEO_Title.Text.Trim() != "")
            {
                list.SEO_Title = txtSEO_Title.Text.Trim();
            }
            else
            {
                list.SEO_Title = txtTitle.Text.Trim();
            }
            list.SEO_Keyword     = txtSEO_Keyword.Text.Trim();
            list.SEO_Description = txtSEO_Description.Text.Trim();
            list.Tags            = string.Empty;
            list.Visual          = string.Empty;
            if (upload.IsUpload)
            {
                list.ImagePath = upload.OldFilePath;
                SetImage(list.ImagePath);
            }
            else
            {
                list.ImagePath = string.Empty;
            }
            list.Issue            = cbIssue.Checked;
            list.IsComment        = false;
            list.IsRecommend      = false;
            list.Clicks           = 0;
            list.SortID           = 0;
            list.TypeID           = 0;
            list.Score            = 0;
            list.ScoreIn          = 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_Album"] = list.InsertData();
        }

        ImageBind();

        AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("success", "数据保存成功");
    }