예제 #1
0
        protected void GridViewCommand(object sender, GridViewCommandEventArgs e)
        {
            int    index      = Convert.ToInt16(e.CommandArgument);
            string Sourcepath = Server.MapPath("~/upload/Temp/");
            string Despath    = Server.MapPath("~/upload/img/");
            int    picid      = 0; //int.Parse(this.GridView1.Rows[index].Cells[0].Text.Trim());

            try
            {
                if (File.Exists(Sourcepath + this.GridView1.Rows[index].Cells[1].Text))
                {
                    File.Delete(Sourcepath + this.GridView1.Rows[index].Cells[1].Text);
                }
                if (File.Exists(Despath + this.GridView1.Rows[index].Cells[1].Text))
                {
                    File.Delete(Despath + this.GridView1.Rows[index].Cells[1].Text);
                }
                picid = int.Parse(this.GridView1.Rows[index].Cells[0].Text);
            }
            catch { }
            //    Dbs.DeleteData("document_info_pic", Conditioin);

            Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages();

            bll.Delete(picid);

            DataSet Ds = bll.GetNewsImagesList(-1, NewsId, false); //bll.GetTopScroll(4);//

            this.GridView1.DataSource = Ds;                        // Dbs.BindGrid("document_info_pic", "*", "where Articleid='" + this.Label_ArticleId.Text + "'", "");
            this.GridView1.DataBind();
            this.Label_Msg.Text = "已经上传了 " + this.GridView1.Rows.Count.ToString() + "  个图片,您可以删除已上传图片,如需修改图片,请先该上传图片,再重新上传!";

            this.Button1.Enabled = (this.GridView1.Rows.Count > 0);
        }
예제 #2
0
        protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int    NewsID         = (int)gridView.DataKeys[e.RowIndex].Value;
            string strpath        = Server.MapPath("~/upload/Temp/");
            string strCopypath    = Server.MapPath("~/upload/img/");
            string strCopypathaff = Server.MapPath("~/upload/affix/");

            //删除文章里面的图片
            Maticsoft.BLL.NewsManage.NewsImages bllimg = new Maticsoft.BLL.NewsManage.NewsImages();
            DataSet ds = bllimg.GetNewsImagesList(-1, NewsID, false);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                try
                {
                    if (File.Exists(strpath + ds.Tables[0].Rows[i]["LinkUrl"].ToString()))
                    {
                        File.Delete(strpath + ds.Tables[0].Rows[i]["LinkUrl"].ToString());
                    }
                    if (File.Exists(strCopypath + ds.Tables[0].Rows[i]["LinkUrl"].ToString()))
                    {
                        File.Delete(strCopypath + ds.Tables[0].Rows[i]["LinkUrl"].ToString());
                    }
                }
                catch { }
            }
            bllimg.DeletebyNewsId(NewsID);

            //删除文章里面的附件

            Maticsoft.BLL.NewsManage.NewsAffix bllaff = new Maticsoft.BLL.NewsManage.NewsAffix();
            DataSet ds1 = bllaff.GetNewsAffixList(-1, NewsID, false);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                try
                {
                    if (File.Exists(strpath + ds1.Tables[0].Rows[i]["LinkUrl"].ToString()))
                    {
                        File.Delete(strpath + ds1.Tables[0].Rows[i]["LinkUrl"].ToString());
                    }
                    if (File.Exists(strCopypathaff + ds1.Tables[0].Rows[i]["LinkUrl"].ToString()))
                    {
                        File.Delete(strCopypathaff + ds1.Tables[0].Rows[i]["LinkUrl"].ToString());
                    }
                }
                catch { }
            }
            bllaff.DeletebyNewsId(NewsID);

            bll.Delete(NewsID);
            BindData();
        }
예제 #3
0
        protected void Button_Upload_Click(object sender, EventArgs e)
        {
            if (!this.FileUpload1.HasFile)
            {
                this.Label_Msg.Text += "请先上传一个图片";
                return;
            }
            string Filename = DateTime.Now.Ticks.ToString() + Path.GetExtension(FileUpload1.FileName).ToLower();

            if (!IsPic(Path.GetExtension(FileUpload1.FileName).ToLower()))
            {
                this.Label_Msg.Text += "图片格式不对!";
                return;
            }

            string strpath = Server.MapPath("~/upload/Temp/");

            try
            {
                this.FileUpload1.PostedFile.SaveAs(strpath + Filename);


                //  id,newsid,descrip,linkurl,issuedate

                LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"];
                Maticsoft.Model.NewsManage.NewsImages newsimages = new Maticsoft.Model.NewsManage.NewsImages();

                newsimages.NewsId    = NewsId;
                newsimages.Descrip   = this.FreeTextBox1.Text;
                newsimages.IssueDate = DateTime.Now;
                newsimages.LinkUrl   = Filename;


                Maticsoft.BLL.NewsManage.NewsImages n = new Maticsoft.BLL.NewsManage.NewsImages();
                n.Add(newsimages);


                Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages();
                DataSet Ds = bll.GetNewsImagesList(-1, NewsId, false); //bll.GetTopScroll(4);//
                Session["FileList"]       = Ds;
                this.GridView1.DataSource = Ds;                        // Dbs.BindGrid("document_info_pic", "*", "where Articleid='" + this.Label_ArticleId.Text + "'", "");
                this.GridView1.DataBind();
                this.Label_Msg.Text = "已经上传了 " + this.GridView1.Rows.Count.ToString() + "  个图片,您可以删除已上传图片,如需修改图片,请先该上传图片,再重新上传!";
            }
            catch
            {
                this.Label_Msg.Text = "图片上传失败!";
            }
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ArticleId"] == null)
                {
                    NewsId = 999999;// Response.End();
                }
                else
                { 
                    NewsId = int.Parse(Request.QueryString["ArticleId"].ToString()); 
                }
                Session["NewsImages_tempId"] = NewsId;
                try
                {
                    StrWebUrl = ConfigurationSettings.AppSettings["WebURL"];
                    Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages();
                    DataSet Ds = bll.GetNewsImagesList(-1, NewsId, false); //bll.GetTopScroll(4);//
                    this.GridView1.DataSource = Ds;// Dbs.BindGrid("document_info_Pic", "*", "where Articleid='" + this.Label_ArticleId.Text + "'", "");
                    this.GridView1.DataBind();
                    Session["FileList"] = Ds;

                    if (NewsId < 999999)
                    {
                        string strDespath = Server.MapPath("~/upload/Temp/");
                        string strSourcepath = Server.MapPath("~/upload//img/");
                        for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                        {
                            string strFileName = Ds.Tables[0].Rows[i]["LinkUrl"].ToString();
                            CopyFile(strSourcepath + strFileName, strDespath + strFileName);
                        }
                    }
                    Ds = null;
                }
                catch { }
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ArticleId"] == null)
                {
                    NewsId = 999999;// Response.End();
                }
                else
                {
                    NewsId = int.Parse(Request.QueryString["ArticleId"].ToString());
                }
                Session["NewsImages_tempId"] = NewsId;
                try
                {
                    StrWebUrl = ConfigurationSettings.AppSettings["WebURL"];
                    Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages();
                    DataSet Ds = bll.GetNewsImagesList(-1, NewsId, false); //bll.GetTopScroll(4);//
                    this.GridView1.DataSource = Ds;                        // Dbs.BindGrid("document_info_Pic", "*", "where Articleid='" + this.Label_ArticleId.Text + "'", "");
                    this.GridView1.DataBind();
                    Session["FileList"] = Ds;

                    if (NewsId < 999999)
                    {
                        string strDespath    = Server.MapPath("~/upload/Temp/");
                        string strSourcepath = Server.MapPath("~/upload//img/");
                        for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                        {
                            string strFileName = Ds.Tables[0].Rows[i]["LinkUrl"].ToString();
                            CopyFile(strSourcepath + strFileName, strDespath + strFileName);
                        }
                    }
                    Ds = null;
                }
                catch { }
            }
        }
예제 #6
0
        protected void Button_Upload_Click(object sender, EventArgs e)
        {
            if (!this.FileUpload1.HasFile)
            {
                this.Label_Msg.Text += "请先上传一个图片";
                return;
            }
            string Filename = DateTime.Now.Ticks.ToString() + Path.GetExtension(FileUpload1.FileName).ToLower();
            if (!IsPic(Path.GetExtension(FileUpload1.FileName).ToLower()))
            {
                this.Label_Msg.Text += "图片格式不对!";
                return;
            }

            string strpath = Server.MapPath("~/upload/Temp/");
            try
            {
              this.FileUpload1.PostedFile.SaveAs(strpath + Filename);
      

              //  id,newsid,descrip,linkurl,issuedate

                LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"];
                Maticsoft.Model.NewsManage.NewsImages newsimages = new Maticsoft.Model.NewsManage.NewsImages();

                newsimages.NewsId = NewsId;
                newsimages.Descrip = this.FreeTextBox1.Text;
                newsimages.IssueDate = DateTime.Now;
                newsimages.LinkUrl = Filename;


                Maticsoft.BLL.NewsManage.NewsImages n = new Maticsoft.BLL.NewsManage.NewsImages();
                n.Add(newsimages);


                Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages();
                DataSet Ds = bll.GetNewsImagesList(-1, NewsId, false); //bll.GetTopScroll(4);//
                Session["FileList"] = Ds;
                this.GridView1.DataSource = Ds;// Dbs.BindGrid("document_info_pic", "*", "where Articleid='" + this.Label_ArticleId.Text + "'", "");
                this.GridView1.DataBind();
                this.Label_Msg.Text = "已经上传了 " + this.GridView1.Rows.Count.ToString() + "  个图片,您可以删除已上传图片,如需修改图片,请先该上传图片,再重新上传!";

            }
            catch
            {
                this.Label_Msg.Text = "图片上传失败!";
            }
        }
예제 #7
0
        protected void GridViewCommand(object sender, GridViewCommandEventArgs e)
        {
            int index = Convert.ToInt16(e.CommandArgument);
            string Sourcepath = Server.MapPath("../upload/Temp/");
            string Despath = Server.MapPath("../upload/img/");
            int picid = 0; //int.Parse(this.GridView1.Rows[index].Cells[0].Text.Trim());
            try
            {
                if (File.Exists(Sourcepath + this.GridView1.Rows[index].Cells[1].Text))
                    File.Delete(Sourcepath + this.GridView1.Rows[index].Cells[1].Text);
                if (File.Exists(Despath + this.GridView1.Rows[index].Cells[1].Text))
                    File.Delete(Despath + this.GridView1.Rows[index].Cells[1].Text);
               picid= int.Parse(this.GridView1.Rows[index].Cells[0].Text);
            }
            catch { }
        //    Dbs.DeleteData("document_info_pic", Conditioin);

            Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages();

            bll.Delete(picid);

            DataSet Ds = bll.GetNewsImagesList(-1, NewsId, false); //bll.GetTopScroll(4);//
            //this.GridView1.DataSource = Session["FileList"] = Ds;
            //Session["FileList"] = Ds;
            this.GridView1.DataSource = Ds;
           // Dbs.BindGrid("document_info_pic", "*", "where Articleid='" + this.Label_ArticleId.Text + "'", "");
            this.GridView1.DataBind();
            this.Label_Msg.Text = "已经上传了 " + this.GridView1.Rows.Count.ToString() + "  个图片,您可以删除已上传图片,如需修改图片,请先该上传图片,再重新上传!";

         this.Button1.Enabled = (this.GridView1.Rows.Count > 0);
       }
예제 #8
0
        protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int NewsID = (int)gridView.DataKeys[e.RowIndex].Value;
            string strpath = Server.MapPath("~/upload/Temp/");
            string strCopypath = Server.MapPath("~/upload/img/");
            string strCopypathaff = Server.MapPath("~/upload/affix/");
            //删除文章里面的图片
            Maticsoft .BLL .NewsManage .NewsImages bllimg=new Maticsoft.BLL.NewsManage.NewsImages ();
            DataSet ds = bllimg.GetNewsImagesList(-1, NewsID, false);
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                try
                {
                    if (File.Exists(strpath + ds.Tables[0].Rows[i]["LinkUrl"].ToString()))
                        File.Delete(strpath + ds.Tables[0].Rows[i]["LinkUrl"].ToString());
                    if (File.Exists(strCopypath + ds.Tables[0].Rows[i]["LinkUrl"].ToString()))
                        File.Delete(strCopypath + ds.Tables[0].Rows[i]["LinkUrl"].ToString());
                }
                catch { }
            }
            bllimg.DeletebyNewsId(NewsID);

            //删除文章里面的附件

            Maticsoft.BLL.NewsManage.NewsAffix bllaff = new Maticsoft.BLL.NewsManage.NewsAffix();
            DataSet ds1 = bllaff.GetNewsAffixList(-1, NewsID, false);
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                try
                {
                    if (File.Exists(strpath + ds1.Tables[0].Rows[i]["LinkUrl"].ToString()))
                        File.Delete(strpath + ds1.Tables[0].Rows[i]["LinkUrl"].ToString());
                    if (File.Exists(strCopypathaff + ds1.Tables[0].Rows[i]["LinkUrl"].ToString()))
                        File.Delete(strCopypathaff + ds1.Tables[0].Rows[i]["LinkUrl"].ToString());
                }
                catch { }
            }
            bllaff.DeletebyNewsId(NewsID); 

            bll.Delete(NewsID);
            BindData();
        }