Beispiel #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/Affix/");
            int    affixid    = 0; //int.Parse(this.GridView1.Rows[index].Cells[0].Text.Trim());


            try
            {
                if (File.Exists(Sourcepath + this.GridView1.Rows[index].Cells[2].Text))
                {
                    File.Delete(Sourcepath + this.GridView1.Rows[index].Cells[2].Text);
                }
                if (File.Exists(Despath + this.GridView1.Rows[index].Cells[2].Text))
                {
                    File.Delete(Despath + this.GridView1.Rows[index].Cells[2].Text);
                }

                affixid = int.Parse(this.GridView1.Rows[index].Cells[0].Text);
            }
            catch { }


            Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
            bll.Delete(affixid);

            DataSet Ds = bll.GetNewsAffixList(-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);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ArticleId"] == null)
            {
                NewsId = 999999;// Response.End();
                Session["NewsAffix_tempId"] = NewsId;
            }
            else
                NewsId = int.Parse(Request.QueryString["ArticleId"].ToString());
            if (!IsPostBack)
            {
                try
                {
                    //this.Label_ArticleId.Text = Request.QueryString["ArticleId"].ToString();

                    // Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News();
                    Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
                    DataSet Ds = bll.GetNewsAffixList(-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_Affix"] = Ds;
                }
                catch { }
            }

        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ArticleId"] == null)
            {
                NewsId = 999999;// Response.End();
                Session["NewsAffix_tempId"] = NewsId;
            }
            else
            {
                NewsId = int.Parse(Request.QueryString["ArticleId"].ToString());
            }
            if (!IsPostBack)
            {
                try
                {
                    //this.Label_ArticleId.Text = Request.QueryString["ArticleId"].ToString();

                    // Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News();
                    Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
                    DataSet Ds = bll.GetNewsAffixList(-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_Affix"] = Ds;
                }
                catch { }
            }
        }
Beispiel #4
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();
        }
Beispiel #5
0
 private StringBuilder ShowNewsAffix(int NewsId)
 {
     Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
     string strWhere = "newsid=" + NewsId.ToString();
     DataSet Ds = bll.GetList(strWhere);
     StringBuilder StrBNewsAffix = new StringBuilder();
     if (Ds != null && Ds.Tables[0].Rows.Count > 0)
     {
         StrBNewsAffix.Append(" 附件:<br />");
         for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
         {
             StrBNewsAffix.Append(" <img  src='Images/HasAffix.gif'/><a href='upload/affix/");
             StrBNewsAffix.Append(Ds.Tables[0].Rows[i][3].ToString() + "'  target='_blank'>");
             StrBNewsAffix.Append( Ds.Tables[0].Rows[i][2].ToString() + "</a><br />");
         }
     }
     return StrBNewsAffix;
 }
Beispiel #6
0
        protected void Button_addfix_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();
            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.NewsAffix NewsAffix = new Maticsoft.Model.NewsManage.NewsAffix();

                NewsAffix.NewsId    = NewsId;
                NewsAffix.Descrip   = this.TextBox_affixname.Text.Trim();
                NewsAffix.IssueDate = DateTime.Now;
                NewsAffix.LinkUrl   = Filename;


                Maticsoft.BLL.NewsManage.NewsAffix n = new Maticsoft.BLL.NewsManage.NewsAffix();
                n.Add(NewsAffix);

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

                DataSet Ds = bll.GetNewsAffixList(-1, NewsId, false); //bll.GetTopScroll(4);//
                Session["FileList_Affix"] = 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 = "文件上传失败!";
            }
        }
        protected void Button_addfix_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();
            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.NewsAffix NewsAffix = new Maticsoft.Model.NewsManage.NewsAffix();

                NewsAffix.NewsId = NewsId;
                NewsAffix.Descrip = this.TextBox_affixname.Text.Trim();
                NewsAffix.IssueDate = DateTime.Now;
                NewsAffix.LinkUrl = Filename;


                Maticsoft.BLL.NewsManage.NewsAffix n = new Maticsoft.BLL.NewsManage.NewsAffix();
                n.Add(NewsAffix);

                Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
             
                DataSet Ds = bll.GetNewsAffixList(-1, NewsId, false); //bll.GetTopScroll(4);//
                Session["FileList_Affix"] = 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 = "文件上传失败!";
            }
        }
        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["NewsAffix_tempId"] = NewsId;
                try
                {
                    //this.Label_ArticleId.Text = Request.QueryString["ArticleId"].ToString();

                    // Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News();
                    Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
                    DataSet Ds = bll.GetNewsAffixList(-1, NewsId, false); //bll.GetTopScroll(4);//
                    Session["FileList_Affix"] = Ds; 
                    this.GridView1.DataSource = Ds;// Dbs.BindGrid("document_info_Pic", "*", "where Articleid='" + this.Label_ArticleId.Text + "'", "");
                    this.GridView1.DataBind();

                    if (NewsId < 999999)
                    {
                        string strDespath = Server.MapPath("~/upload/Temp/");
                        string strSourcepath = Server.MapPath("~/upload/Affix/");
                        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 { }
            }

        }
        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["NewsAffix_tempId"] = NewsId;
                try
                {
                    //this.Label_ArticleId.Text = Request.QueryString["ArticleId"].ToString();

                    // Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News();
                    Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
                    DataSet Ds = bll.GetNewsAffixList(-1, NewsId, false); //bll.GetTopScroll(4);//
                    Session["FileList_Affix"] = Ds;
                    this.GridView1.DataSource = Ds;                       // Dbs.BindGrid("document_info_Pic", "*", "where Articleid='" + this.Label_ArticleId.Text + "'", "");
                    this.GridView1.DataBind();

                    if (NewsId < 999999)
                    {
                        string strDespath    = Server.MapPath("~/upload/Temp/");
                        string strSourcepath = Server.MapPath("~/upload/Affix/");
                        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 { }
            }
        }
Beispiel #10
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr       = "";
            int    newid        = int.Parse(lblNewsId.Text);
            string heading      = this.txtHeading.Text.Trim();
            string focus        = this.txtFocus.Text.Trim();
            string content      = this.FreeTextBox1.Text.Trim();
            string classid      = this.dropNewsClass.SelectedValue;
            string strissuedate = this.txtIssueDate.Text;
            //bool opened = this.radlistOpened.SelectedValue == "1" ? true : false;
            bool dormancy = !this.chkDormancy.Checked;

            if (heading == "")
            {
                strErr += "标题不能为空\\n";
            }
            if (content == "")
            {
                strErr += "内容不能为空\\n";
            }
            if ((this.dropNewsClass.Items.Count == 0) || (classid.Trim() == ""))
            {
                strErr += "没有可以选择的类别!\\n";
            }

            if (strErr != "")
            {
                LTP.Common.MessageBox.Show(this, strErr);
                return;
            }

            if (Session["UserInfo"] == null)
            {
                return;
            }
            DateTime issuedate = DateTime.Now;

            try
            {
                issuedate = Convert.ToDateTime(strissuedate);
            }
            catch { }
            LTP.Accounts.Bus.User           currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"];
            Maticsoft.Model.NewsManage.News news        = new Maticsoft.Model.NewsManage.News();
            news.NewsId    = newid;
            news.ClassId   = int.Parse(classid);
            news.Heading   = heading;
            news.Focus     = focus;
            news.Content   = content;
            news.IssueDate = issuedate;
            //    news.Frequency = 0;
            if (dormancy)
            {
                news.Dormancy = "True";
            }
            else
            {
                news.Dormancy = "False";
            }
            news.IssueDate = issuedate;// DateTime.Now;
            news.Priority  = 0;
            news.UserId    = currentUser.UserID;
            if (chkIsTop.Checked)
            {
                news.IsTop = 1;
            }
            else
            {
                news.IsTop = 0;
            }

            if (chkIsLimited.Checked)
            {
                news.IsLimited = 1;
            }
            else
            {
                news.IsLimited = 0;
            }

            Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News();
            n.Update(news);



            //处理新闻图片
            if (Session["NewsImages_tempId"] != null)
            {
                int NewsImages_tempId = (int)Session["NewsImages_tempId"];
                Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages();
                DataSet Dset = (DataSet)Session["FileList"]; //bll.GetNewsImagesList(-1, NewsImages_tempId, false);
                if (Dset != null && Dset.Tables[0].Rows.Count > 0)
                {
                    string Sourcepath = Server.MapPath("~/upload/Temp/");
                    string Despath    = Server.MapPath("~/upload/img/");
                    for (int i = 0; i < Dset.Tables[0].Rows.Count; i++)
                    {
                        try
                        {
                            string FileName = Dset.Tables[0].Rows[i]["linkurl"].ToString();
                            if (File.Exists(Sourcepath + FileName))
                            {
                                File.Copy(Sourcepath + FileName, Despath + FileName);
                            }
                            if (File.Exists(Sourcepath + FileName))
                            {
                                File.Delete(Sourcepath + FileName);
                            }
                        }
                        catch
                        {
                            //this.Label_Msg.Text = "文件复制出错:" + Ex.Message.ToString();
                        }
                    }
                    //修改图片
                    //  string strupdatestring = "newsid=" + newsid.ToString();
                    //   bll.Update(strupdatestring, NewsImages_tempId);
                }
            }


            //处理新闻附件
            if (Session["NewsAffix_tempId"] != null)
            {
                int NewsAffix_tempId = (int)Session["NewsAffix_tempId"];
                Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
                DataSet Dset = (DataSet)Session["FileList_Affix"]; //bll.GetNewsAffixList(-1, NewsAffix_tempId, false);
                if (Dset != null && Dset.Tables[0].Rows.Count > 0)
                {
                    string Sourcepath = Server.MapPath("~/upload/Temp/");
                    string Despath    = Server.MapPath("~/upload/affix");
                    for (int i = 0; i < Dset.Tables[0].Rows.Count; i++)
                    {
                        try
                        {
                            string FileName = Dset.Tables[0].Rows[i]["linkurl"].ToString();
                            if (File.Exists(Sourcepath + FileName))
                            {
                                File.Copy(Sourcepath + FileName, Despath + FileName);
                            }
                            if (File.Exists(Sourcepath + FileName))
                            {
                                File.Delete(Sourcepath + FileName);
                            }
                        }
                        catch
                        {
                            //this.Label_Msg.Text = "文件复制出错:" + Ex.Message.ToString();
                        }
                    }
                    //修改附件
                    //string strupdatestring = "newsid=" + newsid.ToString();
                    //bll.Update(strupdatestring, NewsAffix_tempId);
                }
            }

            Response.Redirect("show.aspx?id=" + newid);
        }
Beispiel #11
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";
            int newid = int.Parse(lblNewsId.Text);
            string heading = this.txtHeading.Text.Trim();
            string focus = this.txtFocus.Text.Trim();
            string content = this.ck_modify.Text.Trim();
            string classid = this.dropNewsClass.SelectedValue;
            string strissuedate = this.txtIssueDate.Text;
            //bool opened = this.radlistOpened.SelectedValue == "1" ? true : false;
            bool dormancy = !this.chkDormancy.Checked;

            if (heading == "")
            {
                strErr += "标题不能为空\\n";

            }
            if (content == "")
            {
                strErr += "内容不能为空\\n";

            }
            if ((this.dropNewsClass.Items.Count == 0) || (classid.Trim() == ""))
            {
                strErr += "没有可以选择的类别!\\n";
            }

            if (strErr != "")
            {
                LTP.Common.MessageBox.Show(this, strErr);
                return;
            }

            if (Session["UserInfo"] == null)
                return;
            DateTime issuedate = DateTime.Now;
            try
            {
                issuedate = Convert.ToDateTime(strissuedate);
            }
            catch { }
            LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"];
            Maticsoft.Model.NewsManage.News news = new Maticsoft.Model.NewsManage.News();
            news.NewsId = newid;
            news.ClassId = int.Parse(classid);
            news.Heading = heading;
            news.Focus = focus;
            news.Content = content;
            news.IssueDate = issuedate;
        //    news.Frequency = 0;
            if (dormancy)
            {
                news.Dormancy = "True";
            }
            else
            {
                news.Dormancy = "False";
            }
            news.IssueDate = issuedate;// DateTime.Now;
            news.Priority = 0;
            news.UserId = currentUser.UserID;
            if (chkIsTop.Checked)
            {
                news.IsTop = 1;
            }
            else
            {
                news.IsTop = 0;
            }

            if (chkIsLimited.Checked)
            {
                news.IsLimited = 1;
            }
            else
            {
                news.IsLimited = 0;
            }

            Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News();
            n.Update(news);



            //处理新闻图片
            if (Session["NewsImages_tempId"] != null)
            {
                int NewsImages_tempId = (int)Session["NewsImages_tempId"];
                Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages();
                DataSet Dset = (DataSet)Session["FileList"]; //bll.GetNewsImagesList(-1, NewsImages_tempId, false);
                if (Dset != null && Dset.Tables[0].Rows.Count > 0)
                {
                    string Sourcepath = Server.MapPath("~/upload/Temp/");
                    string Despath = Server.MapPath("~/upload/img/");
                    for (int i = 0; i < Dset.Tables[0].Rows.Count; i++)
                    {
                        try
                        {
                            string FileName = Dset.Tables[0].Rows[i]["linkurl"].ToString();
                            if (File.Exists(Sourcepath + FileName))
                                File.Copy(Sourcepath + FileName, Despath + FileName);
                            if (File.Exists(Sourcepath + FileName))
                                File.Delete(Sourcepath + FileName);
                        }
                        catch
                        {
                            //this.Label_Msg.Text = "文件复制出错:" + Ex.Message.ToString();
                        }
                    }
                    //修改图片
                  //  string strupdatestring = "newsid=" + newsid.ToString();
                 //   bll.Update(strupdatestring, NewsImages_tempId);
                }
            }


            //处理新闻附件
            if (Session["NewsAffix_tempId"] != null)
            {
                int NewsAffix_tempId = (int)Session["NewsAffix_tempId"];
                Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
                DataSet Dset = (DataSet)Session["FileList_Affix"]; //bll.GetNewsAffixList(-1, NewsAffix_tempId, false);
                if (Dset != null && Dset.Tables[0].Rows.Count > 0)
                {
                    string Sourcepath = Server.MapPath("~/upload/Temp/");
                    string Despath = Server.MapPath("~/upload/affix/");
                    for (int i = 0; i < Dset.Tables[0].Rows.Count; i++)
                    {
                        try
                        {
                            string FileName = Dset.Tables[0].Rows[i]["linkurl"].ToString();
                            if (File.Exists(Sourcepath + FileName))
                                File.Copy(Sourcepath + FileName, Despath + FileName);
                            if (File.Exists(Sourcepath + FileName))
                                File.Delete(Sourcepath + FileName);
                        }
                        catch
                        {
                            //this.Label_Msg.Text = "文件复制出错:" + Ex.Message.ToString();
                        }
                    }
                    //修改附件
                    //string strupdatestring = "newsid=" + newsid.ToString();
                    //bll.Update(strupdatestring, NewsAffix_tempId);
                }
            }

            Response.Redirect("show.aspx?id=" + newid);
        }
        protected void GridViewCommand(object sender, GridViewCommandEventArgs e)
        {
            int index = Convert.ToInt16(e.CommandArgument);
            string Sourcepath = Server.MapPath("~/upload/Temp/");
            string Despath = Server.MapPath("~/upload/Affix/");
            int affixid = 0; //int.Parse(this.GridView1.Rows[index].Cells[0].Text.Trim());

         
            try
            {
                if (File.Exists(Sourcepath + this.GridView1.Rows[index].Cells[2].Text))
                    File.Delete(Sourcepath + this.GridView1.Rows[index].Cells[2].Text);
                if (File.Exists(Despath + this.GridView1.Rows[index].Cells[2].Text))
                    File.Delete(Despath + this.GridView1.Rows[index].Cells[2].Text);

                affixid = int.Parse(this.GridView1.Rows[index].Cells[0].Text);

            }
            catch { }


            Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix();
            bll.Delete(affixid);

            DataSet Ds = bll.GetNewsAffixList(-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);
        }
Beispiel #13
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();
        }