protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string strContent = Request.Form["t_contents"].ToString();

        if (strContent == "")
        {
            CommonFunction.Alert(Literal1, "文章内容不能为空");
            return;
        }
        ServiceNews news = new ServiceNews();

        news.N_Title    = txtTitle.Text;
        news.N_Content  = strContent;
        news.N_SID      = ((UserInfo)Session["ServiceUser"]).U_SID;
        news.N_NewsType = ViewState["tid"].ToString();
        news.N_From     = txtForm.Text;
        news.N_Time     = DateTime.Parse(txtdate.Text);
        if (ViewState["strAction"].ToString() == "add")
        {
            ServiceNewService.Insert_News(news);
        }
        else if (ViewState["strAction"].ToString() == "update")
        {
            news.N_ID = Convert.ToInt32(ViewState["nid"]);
            ServiceNewService.Update_News(news);
        }
        CommonFunction.AlertAndRedirect(Literal1, "操作成功", "blank.aspx");
    }
    protected void btnSaveImage_Click(object sender, ImageClickEventArgs e)
    {
        if (ViewState["strAction"].ToString() == "add" || FileUploadImg.HasFile)
        {
            string fileName   = CommonFunction.Get_DynamicString() + FileUploadImg.FileName;
            string vfileName  = "v_" + fileName;
            string vvfileName = "vv_" + fileName;
            string filePath   = Server.MapPath("~/newsImages/" + fileName);
            string vfilePath  = Server.MapPath("~/newsImages/" + vfileName);
            string vvfilePath = Server.MapPath("~/newsImages/" + vvfileName);
            if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadImg, Literal1, filePath, new string[] { ".gif", ".jpg", ".jpeg" }))
            {
                return;
            }
            ImgUploadFunction.MakeThumbnail(filePath, vfilePath, 150, 112, "W");
            ImgUploadFunction.MakeThumbnail(filePath, vvfilePath, 600, 480, "W");
            System.IO.File.Delete(filePath);
            ViewState["VImgURL"]  = vfileName;
            ViewState["VVImgURL"] = vvfileName;
        }
        string      strContent = Request.Form["t_contents"].ToString();
        string      strTitle   = "(" + txtTitle.Text + ")[" + ViewState["VImgURL"].ToString() + "]{" + ViewState["VVImgURL"].ToString() + "}";
        ServiceNews news       = new ServiceNews();

        news.N_Title    = strTitle;
        news.N_Content  = strContent;
        news.N_From     = "本站原创";
        news.N_SID      = ((UserInfo)Session["ServiceUser"]).U_SID;
        news.N_NewsType = "6";
        news.N_Time     = DateTime.Parse(txtdate.Text.Trim());
        if (ViewState["strAction"].ToString() == "update")
        {
            news.N_ID = Convert.ToInt32(ViewState["nid"]);
            ServiceNewService.Update_News(news);
        }
        else if (ViewState["strAction"].ToString() == "add")
        {
            ServiceNewService.Insert_News(news);
        }
        CommonFunction.AlertAndRedirect(Literal1, "操作成功", "blank.aspx");
    }
Exemple #3
0
    protected void btnAdd_Click(object sender, ImageClickEventArgs e)
    {
        ServiceNews news = new ServiceNews();

        news.N_Title    = "";
        news.N_Content  = txtNotice.Text;
        news.N_SID      = ((UserInfo)Session["ServiceUser"]).U_SID;
        news.N_NewsType = "2";
        news.N_From     = "本站原创";
        news.N_Time     = DateTime.Parse(txtdate.Text);
        if (ViewState["strAction"].ToString() == "add")
        {
            ServiceNewService.Insert_News(news);
        }
        else if (ViewState["strAction"].ToString() == "update")
        {
            news.N_ID = Convert.ToInt32(ViewState["nid"]);
            ServiceNewService.Update_News(news);
        }
        CommonFunction.AlertAndRedirect(Literal1, "操作成功", "blank.aspx");
    }