Exemple #1
0
    private void BindData()
    {
        DataTable dt = new DAL.Tables.T_FocusEvent().Open("", "", "");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_FocusNews");

            return;
        }

        PF.DataGridBindData(g, dt, gPager);
    }
    private void BindData()
    {
        hID.Value = Shove._Web.Utility.GetRequest("ID");

        if (hID.Value != "")
        {
            DataTable dt = new DAL.Tables.T_FocusEvent().Open("", "ID=" + hID.Value, "");

            if (dt == null || dt.Rows.Count == 0)
            {
                PF.GoError(ErrorNumber.NoData, "数据不存在或已被删除!", this.GetType().BaseType.FullName);

                return;
            }

            tbTitle.Text           = dt.Rows[0]["Title"].ToString();
            tbContent.Value        = dt.Rows[0]["Content"].ToString();
            cbIsMaster.Checked     = Shove._Convert.StrToBool(dt.Rows[0]["IsShow"].ToString(), false);
            ddlYear.SelectedIndex  = ddlYear.Items.Count - 1 - (DateTime.Now.Year - Shove._Convert.StrToInt(dt.Rows[0]["Year"].ToString(), 0));
            ddlMonth.SelectedIndex = Shove._Convert.StrToInt(dt.Rows[0]["Month"].ToString(), 0) - 1;

            isLoadTemplate = false;
        }

        ddlImage.Items.Clear();
        ddlImage.Items.Add("--选择图片--");

        string UploadPath = this.Server.MapPath("../Private/" + _Site.ID.ToString() + "/NewsImages");

        if (!System.IO.Directory.Exists(UploadPath))
        {
            System.IO.Directory.CreateDirectory(UploadPath);
        }
        else
        {
            string[] FileList = Shove._IO.File.GetFileList(UploadPath);

            if (FileList != null)
            {
                for (int i = 0; i < FileList.Length; i++)
                {
                    ddlImage.Items.Add(FileList[i]);
                }
            }
        }
    }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            ID = Shove._Convert.StrToLong(Shove._Web.Utility.GetRequest("ID"), 1);

            DataTable dt = new DAL.Tables.T_FocusEvent().Open("[Content]", "ID=" + ID.ToString(), "");

            if (dt == null)
            {
                PF.GoError(ErrorNumber.NoData, "数据库繁忙,请重试", this.GetType().FullName);

                return;
            }

            if (dt.Rows.Count < 1)
            {
                return;
            }

            lbContent.Text = dt.Rows[0]["Content"].ToString();
        }
    }
    protected void btnAdd_Click(object sender, System.EventArgs e)
    {
        string Title = tbTitle.Text.Trim();

        if (string.IsNullOrEmpty(Title))
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入标题。");

            return;
        }

        string Content = tbContent.Value.Trim();

        if (string.IsNullOrEmpty(Content))
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入内容。");

            return;
        }

        string Image = "";

        if (tbImage.Value.Trim() != "")
        {
            string UploadPath = this.Server.MapPath("../Private/" + _Site.ID.ToString() + "/NewsImages");

            if (!System.IO.Directory.Exists(UploadPath))
            {
                System.IO.Directory.CreateDirectory(UploadPath);
            }

            if (Shove._IO.File.UploadFile(this.Page, tbImage, "../Private/" + _Site.ID.ToString() + "/NewsImages/", ref Image, true, "image") != 0)
            {
                Shove._Web.JavaScript.Alert(this.Page, "图片文件上传错误!");

                return;
            }
        }
        else
        {
            if (ddlImage.SelectedIndex > 0)
            {
                Image = ddlImage.SelectedItem.Text;
            }
        }

        DAL.Tables.T_FocusEvent f = new DAL.Tables.T_FocusEvent();

        f.Title.Value    = Title;
        f.Content.Value  = Content;
        f.IsShow.Value   = cbIsMaster.Checked;
        f.ImageUrl.Value = Image;
        f.Year.Value     = ddlYear.SelectedValue;
        f.Month.Value    = ddlMonth.SelectedValue;

        if (hID.Value == "")
        {
            if (string.IsNullOrEmpty(Image))
            {
                Shove._Web.JavaScript.Alert(this.Page, "请选择图片!");

                return;
            }

            f.Insert();
        }
        else
        {
            f.Update("ID=" + hID.Value);
        }

        Shove._Web.Cache.ClearCache("Admin_FocusEventAdd");
        // 清除前台缓存
        Shove._Web.Cache.ClearCache("Focus_Default_Year_" + ddlYear.SelectedValue.Trim() + "_Month_" + ddlMonth.SelectedValue.Trim());
        this.Response.Redirect("FocusEvent.aspx", true);
    }
Exemple #5
0
    private void DataBind()
    {
        string    CacheKey = "Focus_Default" + "_Year_" + ddlYear.SelectedValue + "_Month_" + Month.ToString();
        DataTable dt       = Shove._Web.Cache.GetCacheAsDataTable(CacheKey);

        if (dt == null)
        {
            dt = new DAL.Tables.T_FocusEvent().Open("ID, Title, [Content], ImageUrl", "Year=" + ddlYear.SelectedValue + " and Month = " + Month.ToString() + " and IsShow=1", "ID");

            if (dt == null)
            {
                PF.GoError(ErrorNumber.NoData, "数据库繁忙,请重试", this.GetType().FullName);

                return;
            }

            Shove._Web.Cache.SetCache(CacheKey, dt, 1200);
        }

        StringBuilder sb = new StringBuilder();

        if (dt.Rows.Count > 1)
        {
            sb.Append("<div class=\"BigImgBox\">");
            sb.Append("<div class=\"BigImg\">");
            sb.Append("<a href=\"Detailed.aspx?ID=" + dt.Rows[0]["ID"].ToString() + "\" target=\"_blank\">");
            sb.Append("<img src=\"/Private/1/NewsImages/" + dt.Rows[0]["ImageUrl"].ToString() + "\" width=\"300px\" height=\"218\"></a></div>");
            sb.Append("<a href=\"Detailed.aspx?ID=" + dt.Rows[0]["ID"].ToString() + "\" target=\"_blank\">" + Shove._String.Cut(dt.Rows[0]["Title"].ToString(), 22) + "</a>");
            sb.Append("</div>");

            for (int i = 1; i < dt.Rows.Count; i++)
            {
                sb.Append("<div class=\"SmallImgBox\">");
                sb.Append("<div class=\"SmallImg\">");
                sb.Append("<a href=\"Detailed.aspx?ID=" + dt.Rows[i]["ID"].ToString() + "\" target=\"_blank\">");
                sb.Append("<img src=\"/Private/1/NewsImages/" + dt.Rows[i]["ImageUrl"].ToString() + "\" width=\"135\" height=\"90\"></a></div>");
                sb.Append("<a href=\"Detailed.aspx?ID=" + dt.Rows[i]["ID"].ToString() + "\" target=\"_blank\">" + Shove._String.Cut(dt.Rows[i]["Title"].ToString(), 11) + "</a>");
                sb.Append("</div>");
            }

            lbContent.Text = sb.ToString();

            sb.Remove(0, sb.Length);

            sb.Append("&nbsp;");
        }
        else
        {
            lbContent.Text = "";
        }
        for (int i = 1; i < 13; i++)
        {
            sb.Append("&nbsp;<span ");

            if (i == Month)
            {
                sb.Append("class=\"month2\"");
            }

            sb.Append(">");

            if ((ddlYear.SelectedValue.Equals(DateTime.Now.Year.ToString()) && i <= Month) || !ddlYear.SelectedValue.Equals(DateTime.Now.Year.ToString()))
            {
                sb.Append("<a href=\"?Month=" + i.ToString() + "\">");
            }
            else
            {
                sb.Append("<a href=\"?Month=" + i.ToString() + "\">");
            }

            sb.Append(i.ToString() + "月</a></span>&nbsp;");

            if (i != 12)
            {
                sb.Append("|");
            }
        }
        innerHtml = sb.ToString();
    }