예제 #1
0
        private void DataInit()
        {
            AdminBookTableAdapter ta_adminbook = new AdminBookTableAdapter();

            Corporation corporation             = (Corporation)Session["corporation"];
            CorVisitRecordTableAdapter ta_visit = new CorVisitRecordTableAdapter();
            DataTable dt_visit = ta_visit.GetCorVisitRecordByCorId(corporation.id, 1);

            rep_historylist.DataSource = dt_visit;
            rep_historylist.DataBind();
        }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["bookName"] != null)
     {
         string bookName = Request.QueryString["bookName"].ToString();
         adminbook.name = bookName;
         AdminBookTableAdapter ta_adminbook = new AdminBookTableAdapter();
         DataTable             dt_adminbook = ta_adminbook.GetAdminBookAllByName(bookName);
         adminbook.author   = dt_adminbook.Rows[0]["author"].ToString();
         adminbook.keyword  = dt_adminbook.Rows[0]["keyword"].ToString();
         adminbook.score    = Convert.ToInt32(dt_adminbook.Rows[0]["score"].ToString());
         adminbook.star     = Convert.ToInt32(dt_adminbook.Rows[0]["star"].ToString());
         adminbook.booktype = dt_adminbook.Rows[0]["booktype"].ToString();
     }
 }
예제 #3
0
        private void AddTree(int Pid, TreeNode PNode)
        {
            AdminBooktypeTableAdapter ta_fatype = new AdminBooktypeTableAdapter();
            AdminBookTableAdapter     ta_book   = new AdminBookTableAdapter();
            DataTable dt_fa   = ta_fatype.GetAdminMenuBooktype();
            DataTable dt_book = ta_book.GetMenuBook();

            dt_fa.Merge(dt_book);
            if (dt_fa.Rows.Count > 0)
            {
                DataView dv = new DataView(dt_fa);
                //过滤ParentID,得到当前的所有子节点 ParentID为父节点ID
                dv.RowFilter = "[parent_id] = " + Pid;
                //循环递归
                foreach (DataRowView Row in dv)
                {
                    //声明节点
                    TreeNode Node = new TreeNode();
                    //绑定超级链接
                    //Node.NavigateUrl = String.Format("javascript:show('{0}')", Row["name"].ToString());
                    //开始递归
                    if (PNode == null)
                    {
                        //添加根节点
                        Node.Text  = Row["name"].ToString();
                        Node.Value = Row["id"].ToString();
                        name       = Node.Text;
                        tree.Nodes.Add(Node);
                        Node.Expanded = false;                            //节点状态收缩
                        AddTree(Int32.Parse(Row["id"].ToString()), Node); //再次递归
                    }
                    else
                    {
                        //添加当前节点的子节点
                        Node.Text  = Row["name"].ToString();
                        Node.Value = Row["id"].ToString();
                        name       = Node.Text;
                        PNode.ChildNodes.Add(Node);
                        Node.Expanded = false;                            //节点状态收缩
                        AddTree(Int32.Parse(Row["id"].ToString()), Node); //再次递归
                    }
                }
            }
        }
예제 #4
0
        protected void Select_Change(Object sender, EventArgs e)
        {
            lbl_selectednode.Text = this.tree.SelectedNode.Text;
            url = url + lbl_selectednode.Text;

            Corporation corporation = (Corporation)Session["corporation"];

            if (lbl_selectednode.Text != null)
            {
                Boolean b1 = lbl_selectednode.Text.EndsWith(".doc");
                Boolean b2 = lbl_selectednode.Text.EndsWith(".pdf");
                Boolean b3 = lbl_selectednode.Text.EndsWith(".txt");
                Boolean b4 = lbl_selectednode.Text.EndsWith(".ppt");
                Boolean b5 = lbl_selectednode.Text.EndsWith(".dwg");

                if (b5)
                {
                    selectbook.Visible = false;
                    content.Visible    = false;
                    addinfo.Visible    = true;
                    btn_view.Visible   = true;

                    string bookName = lbl_selectednode.Text;
                    adminbook.name = bookName;
                    AdminBookTableAdapter ta_adminbook = new AdminBookTableAdapter();
                    DataTable             dt_adminbook = ta_adminbook.GetAdminBookAllByName(bookName);
                    adminbook.id       = Convert.ToInt32(dt_adminbook.Rows[0]["id"]);
                    adminbook.author   = dt_adminbook.Rows[0]["author"].ToString();
                    adminbook.keyword  = dt_adminbook.Rows[0]["keyword"].ToString();
                    adminbook.score    = Convert.ToInt32(dt_adminbook.Rows[0]["score"].ToString());
                    adminbook.star     = Convert.ToInt32(dt_adminbook.Rows[0]["star"].ToString());
                    adminbook.booktype = dt_adminbook.Rows[0]["booktype"].ToString();
                    lab_tip.Text       = "";

                    //添加历史阅读记录
                    CorVisitRecordTableAdapter ta_record = new CorVisitRecordTableAdapter();
                    ta_record.InsertCorVisitRecord(DateTime.Now, 1, null, corporation.id, adminbook.id);

                    FileURL = lbl_selectednode.Text;
                }
                else
                {
                    if (b1 || b2 || b3 || b4)
                    {
                        //在此控制两个div是否显示
                        selectbook.Visible = false;
                        content.Visible    = true;
                        addinfo.Visible    = true;
                        btn_view.Visible   = false;

                        string bookName = lbl_selectednode.Text;
                        adminbook.name = bookName;
                        AdminBookTableAdapter ta_adminbook = new AdminBookTableAdapter();
                        DataTable             dt_adminbook = ta_adminbook.GetAdminBookAllByName(bookName);
                        adminbook.id       = Convert.ToInt32(dt_adminbook.Rows[0]["id"]);
                        adminbook.author   = dt_adminbook.Rows[0]["author"].ToString();
                        adminbook.keyword  = dt_adminbook.Rows[0]["keyword"].ToString();
                        adminbook.score    = Convert.ToInt32(dt_adminbook.Rows[0]["score"].ToString());
                        adminbook.star     = Convert.ToInt32(dt_adminbook.Rows[0]["star"].ToString());
                        adminbook.booktype = dt_adminbook.Rows[0]["booktype"].ToString();
                        lab_tip.Text       = "";

                        //添加历史阅读记录
                        CorVisitRecordTableAdapter ta_record = new CorVisitRecordTableAdapter();
                        ta_record.InsertCorVisitRecord(DateTime.Now, 1, null, corporation.id, adminbook.id);

                        //实现阅读书籍功能
                        string addpath = HttpContext.Current.Server.MapPath("~/swf\\") + bookName.Substring(0, bookName.LastIndexOf(".")) + ".swf";
                        if (!File.Exists(addpath))
                        {
                            string cbook_path;

                            cbook_path = "~/corporation/upload/" + corporation.name + "\\";
                            string fileName      = lbl_selectednode.Text.ToString();
                            string fileExtention = fileName.Substring(fileName.LastIndexOf(".") + 1);
                            string pdfFileName;
                            //判断文件名
                            bool     fileOK            = false;
                            String[] allowedExtensions =
                            { "doc", "ppt", "xls", "docx", "html" }; //允许上传的文件格式
                            for (int i = 0; i < allowedExtensions.Length; i++)
                            {
                                if (fileExtention == allowedExtensions[i])
                                {
                                    fileOK = true;
                                    break;
                                }
                            }
                            if (fileOK == true)
                            {
                                string filePath = HttpContext.Current.Server.MapPath("~/attachment\\") + fileName;
                                //上传选中文件到attachment文件夹
                                string admin_bookpath = HttpContext.Current.Server.MapPath(cbook_path) + fileName;
                                if (!File.Exists(filePath))
                                {
                                    FileInfo adminway = new FileInfo(admin_bookpath);
                                    adminway.CopyTo(filePath);
                                }
                                //将office文件转换成PDF,保存到PDF文件夹下
                                pdfFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + ".pdf";
                                string fileOutPath = HttpContext.Current.Server.MapPath("~/pdf\\") + pdfFileName;
                                ExportPdf(filePath, fileOutPath);
                            }

                            else
                            {
                                string filePath = HttpContext.Current.Server.MapPath("~/pdf\\") + fileName;

                                string admin_bookpath = HttpContext.Current.Server.MapPath(cbook_path) + fileName;
                                if (!File.Exists(filePath))
                                {
                                    FileInfo adminway = new FileInfo(admin_bookpath);
                                    adminway.CopyTo(filePath);
                                }

                                pdfFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + ".pdf";
                            }
                            //切记,使用pdf2swf.exe 打开的文件名之间不能有空格,否则会失败
                            string cmdStr      = HttpContext.Current.Server.MapPath("~/SWFTools/pdf2swf.exe");
                            string savePath    = HttpContext.Current.Server.MapPath("~/pdf/");
                            string saveSWFPath = HttpContext.Current.Server.MapPath("~/SWF/");
                            //将PDF文件转换成SWF格式文件
                            //要转换的pdf文件路径
                            string sourcePath = @"""" + savePath + pdfFileName + @"""";

                            //转换之后swf文件存放的目标路径
                            string targetPath = @"""" + saveSWFPath + pdfFileName.Substring(0, pdfFileName.LastIndexOf(".")) + ".swf" + @"""";
                            //@"""" 四个双引号得到一个双引号,如果你所存放的文件所在文件夹名有空格的话,要在文件名的路径前后加上双引号,才能够成功
                            // -t 源文件的路径
                            // -s 参数化(也就是为pdf2swf.exe 执行添加一些窗外的参数(可省略))
                            string argsStr = "  -t " + sourcePath + " -s flashversion=9 -o " + targetPath;

                            //执行pdf到swf的转换
                            ExcutedCmd(cmdStr, argsStr);

                            FileURL = fileName.Substring(0, fileName.LastIndexOf(".")) + ".swf";
                        }

                        //这种方法大大的提高了页面的加载效率
                        else
                        {
                            FileURL = bookName.Substring(0, bookName.LastIndexOf(".")) + ".swf";
                        }
                    }
                    else
                    {
                        //本应该在这里进行如果是选中的是目录的话,我们就进行将目录下的书进行显示这一功能,但是我们在
                        //page_load那里已经实现了
                    }
                }
            }
            else
            {
                lab_tip.Text = "未选中书籍";
            }
        }
예제 #5
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            if (this.tree.SelectedNode == null)
            {
                lab_tip.Text = "<script>alert('没有选中目录项'); window.location.href='addbook.aspx'</script>";
            }
            else
            {
                Boolean b1 = lbl_selectednode.Text.EndsWith(".doc");
                Boolean b2 = lbl_selectednode.Text.EndsWith(".pdf");
                Boolean b3 = lbl_selectednode.Text.EndsWith(".txt");
                Boolean b4 = lbl_selectednode.Text.EndsWith(".ppt");
                Boolean b5 = lbl_selectednode.Text.EndsWith(".dwg");

                if (b1 || b2 || b3 || b4 || b5)
                {
                    lab_tip.Text = "<script>alert('不能在书籍下面添加书籍'); window.location.href='addbook.aspx'</script>";
                }
                else
                {
                    AdminBookTableAdapter ta_adminbook = new AdminBookTableAdapter();
                    AdminBook             book         = new AdminBook();
                    book.name     = txt_name.Text;
                    book.author   = txt_author.Text;
                    book.keyword  = txt_keyword.Text;
                    book.score    = Convert.ToInt32(txt_score.Text);
                    book.star     = Convert.ToInt32(ddl_star.SelectedItem.Value);
                    book.filetype = ddl_type.SelectedItem.Value;
                    book.name     = book.name + "." + book.filetype;
                    if (file_book.HasFile)
                    {
                        string filename = file_book.FileName.ToLower();
                        file_book.SaveAs(Server.MapPath("~/admin/upload/bookfile/") + filename);
                        book.url = "admin/upload/bookfile/" + filename;

                        /*if (filename.EndsWith(".doc"))
                         * {
                         *  file_book.SaveAs(Server.MapPath("~/upload/bookfile/") + filename + ".doc" );
                         *  book.Bookway = "/upload/bookfile/" + filename + ".doc";
                         * }
                         * if (filename.EndsWith(".pdf"))
                         * {
                         *  file_book.SaveAs(Server.MapPath("~/upload/bookfile/") + filename + ".pdf");
                         *  book.Bookway = "/upload/bookfile/" + filename + ".pdf";
                         * }
                         * if (filename.EndsWith(".epub"))
                         * {
                         *  file_book.SaveAs(Server.MapPath("~/upload/bookfile/") + book.Id.ToString() + ".epub");
                         *  book.Bookway = "/upload/bookfile/" + book.Id.ToString() + ".epub";
                         * }*/
                    }
                    ta_adminbook.InsertAdminBook(book.name, book.url, book.star, book.author, book.keyword, book.score, book.filetype);
                    DataTable           dt_adminBook = ta_adminbook.GetAdminBookByName(book.name);
                    int                 book_id      = Convert.ToInt32(dt_adminBook.Rows[0]["id"]);
                    int                 booktype_id  = Convert.ToInt32(this.tree.SelectedNode.Value);
                    AdminBTTableAdapter ta_adminBT   = new AdminBTTableAdapter();
                    ta_adminBT.InsertAdminBT(book_id, booktype_id);
                    lab_tip.Text = "<script>alert('添加成功'); window.location.href='addbook.aspx'</script>";
                }
            }
        }
예제 #6
0
        protected void rep_adminlist_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName.Equals("read"))
            {
                AdminBookTableAdapter ta_book = new AdminBookTableAdapter();
                string book_name     = ta_book.GetABookById(Convert.ToInt32(e.CommandArgument)).Rows[0]["name"].ToString();
                string fileName      = book_name;
                string fileExtention = fileName.Substring(fileName.LastIndexOf(".") + 1);
                string pdfFileName;
                //判断文件名
                bool     fileOK            = false;
                String[] allowedExtensions =
                { "doc", "ppt", "xls", "docx", "html" }; //允许上传的文件格式
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtention == allowedExtensions[i])
                    {
                        fileOK = true;
                        break;
                    }
                }
                if (fileOK == true)
                {
                    string filePath = HttpContext.Current.Server.MapPath("~/attachment\\") + fileName;
                    //上传选中文件到attachment文件夹
                    string admin_bookpath = HttpContext.Current.Server.MapPath("~/admin/upload/bookfile\\") + fileName;
                    if (!File.Exists(filePath))
                    {
                        FileInfo adminway = new FileInfo(admin_bookpath);
                        adminway.CopyTo(filePath);
                    }
                    //将office文件转换成PDF,保存到PDF文件夹下
                    pdfFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + ".pdf";
                    string fileOutPath = HttpContext.Current.Server.MapPath("~/pdf\\") + pdfFileName;
                    ExportPdf(filePath, fileOutPath);
                }

                else
                {
                    string filePath = HttpContext.Current.Server.MapPath("~/pdf\\") + fileName;

                    string admin_bookpath = HttpContext.Current.Server.MapPath("~/admin/upload/bookfile\\") + fileName;
                    if (!File.Exists(filePath))
                    {
                        FileInfo adminway = new FileInfo(admin_bookpath);
                        adminway.CopyTo(filePath);
                    }

                    pdfFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + ".pdf";
                }
                //切记,使用pdf2swf.exe 打开的文件名之间不能有空格,否则会失败
                string cmdStr      = HttpContext.Current.Server.MapPath("~/SWFTools/pdf2swf.exe");
                string savePath    = HttpContext.Current.Server.MapPath("~/pdf/");
                string saveSWFPath = HttpContext.Current.Server.MapPath("~/SWF/");
                //将PDF文件转换成SWF格式文件
                //要转换的pdf文件路径
                string sourcePath = @"""" + savePath + pdfFileName + @"""";

                //转换之后swf文件存放的目标路径
                string targetPath = @"""" + saveSWFPath + pdfFileName.Substring(0, pdfFileName.LastIndexOf(".")) + ".swf" + @"""";
                //@"""" 四个双引号得到一个双引号,如果你所存放的文件所在文件夹名有空格的话,要在文件名的路径前后加上双引号,才能够成功
                // -t 源文件的路径
                // -s 参数化(也就是为pdf2swf.exe 执行添加一些窗外的参数(可省略))
                string argsStr = "  -t " + sourcePath + " -s flashversion=9 -o " + targetPath;

                //执行pdf到swf的转换
                ExcutedCmd(cmdStr, argsStr);

                Response.Redirect("../viewer.aspx?id=" + HttpUtility.HtmlEncode(fileName.Substring(0, fileName.LastIndexOf(".")) + ".swf"));
            }
        }
예제 #7
0
        protected void btn_confirm_click(object sender, EventArgs e)
        {
            Connect connect = new Connect();
            string  sql;

            //为了将bookpath完整的表现出来,目前差一个后缀
            string[] book  = new string[200];
            string[] cbook = new string[200];

            Corporation corporation            = (Corporation)Session["corporation"];
            int         corporationid          = corporation.id;
            CorpoBooktypeTableAdapter ta_corpo = new CorpoBooktypeTableAdapter();
            DataTable dt_corpo = ta_corpo.GetCBookTypeByTwo(Convert.ToInt32(rbl_menu.SelectedItem.Value), corporationid);

            if (dt_corpo.Rows.Count > 0)
            {
                //避免目录的重复购买
                Response.Write("<script language='javascript'>alert('您已经购买过此目录,不能继续进行购买');</script>");
            }
            else
            {
                if (Convert.ToInt32(lbl_allprice.Text) > 0)
                {
                    string name;
                    int    price;
                    if (rbl_menu.SelectedItem != null)
                    {
                        name = rbl_menu.SelectedItem.Text.ToString();
                        AdminBooktypeTableAdapter ta_book = new AdminBooktypeTableAdapter();
                        DataTable dt_book = ta_book.GetAdminBooktypeByName(name);
                        price = Convert.ToInt32(dt_book.Rows[0]["price"]);
                        int buycount = Convert.ToInt32(txtBuycount.Value);
                        int allprice = price * buycount;
                        lbl_allprice.Text = allprice.ToString();
                        int day       = buycount;
                        int book_type = Convert.ToInt32(rbl_menu.SelectedItem.Value);

                        //通过insertbill数据来表明账单已经产生
                        BillTableAdapter ta_bill = new BillTableAdapter();
                        ta_bill.InsertBill(DateTime.Now.ToString(), day, allprice, 1, corporationid);
                        DataTable dt_bill = ta_bill.GetCurrentBill();
                        //bill_id是在企业中显示他们买了哪些目录,以便显示出他们拥有的目录
                        int bill_id = Convert.ToInt32(dt_bill.Rows[0]["id"]);
                        sql = "insert into Billtype (bill_id,abooktype_id) values (" + bill_id + "," + book_type + ")";
                        connect.ExecuteSql(sql);

                        string book_path = "corporation/upload/" + corporation.name;
                        /*购买了目录,那么目录就会全部移植到cbooktype和cbook,cbt中*/

                        //开始进行booktype表的转移
                        a[i] = Convert.ToInt32(rbl_menu.SelectedItem.Value);
                        //递归来进行booktype的转移
                        MoveMenu(a[i]);
                        //得到a数组中保存的booktype的id,全部insert到子公司目录中
                        int j = 0;
                        while (j <= i)
                        {
                            sql = "insert into CorpoBooktype (abooktype_id,name,price,parent_id,corporation_id) select id,name,price,parent_id," + corporationid + " as corporation_id from AdminBooktype where id=" + a[j];
                            connect.ExecuteSql(sql);
                            j++;
                        }

                        //开始进行book表的转移
                        int k = 0;
                        int n = -1;
                        int q = 0;
                        while (k <= i)
                        {
                            AdminBookTableAdapter ta_admin = new AdminBookTableAdapter();
                            DataTable             dt_admin = ta_admin.GetBookByBooktypeId(a[k]);
                            if (dt_admin.Rows.Count > 0)
                            {
                                for (q = 0; q < dt_admin.Rows.Count; q++)
                                {
                                    ++n;
                                    book[n] = dt_admin.Rows[q]["url"].ToString();
                                    string[] split = book[n].Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                                    cbook[n] = book_path + "/" + split[3];
                                }
                            }
                            ++k;
                        }

                        k = 0;
                        while (k <= n)
                        {
                            sql = "insert into CorpoBook (abook_id,corporation_id,name,url,star,author,keyword,score,filetype) "
                                  + "select id," + corporationid + " as corporation_id,name,'" + cbook[k] + "' as book_path,star,author,keyword,score,filetype FROM AdminBook inner join AdminBT on AdminBT.abook_id = AdminBook.id "
                                  + " where AdminBook.url='" + book[k] + "'";
                            connect.ExecuteSql(sql);
                            ++k;
                        }

                        //开始进行bt表的转移
                        int m = 0;
                        while (m <= i)
                        {
                            sql = "insert into CorpoBT (cbook_id,cbooktype_id,corporation_id) select abook_id,abooktype_id," + corporationid + " as corporation_id from AdminBT where abooktype_id = "
                                  + a[m];
                            connect.ExecuteSql(sql);
                            m++;
                        }

                        Response.Write("<script language='javascript'>alert('购买成功,可进入订单列表查看');</script>");
                    }
                    else
                    {
                        Response.Write("<script language='javascript'>alert('未选定目录');</script>");
                    }
                }
            }
        }