Exemple #1
0
        protected void Button2_Click1(object sender, EventArgs e)
        {
            bool fileVaild = false;

            if (this.FileUpload2.HasFile)
            {
                string   fileExtension = System.IO.Path.GetExtension(this.FileUpload2.FileName).ToLower();
                string[] restrict      = { ".gif", ".jpg", ".jpeg", ".png", ".txt" };
                for (int i = 0; i < restrict.Length; i++)
                {
                    if (fileExtension == restrict[i])
                    {
                        fileVaild = true;
                    }
                }

                if (fileVaild == true)
                {
                    try
                    {
                        this.Image2.ImageUrl = "~/UploadPic/" + FileUpload2.FileName;

                        string picpath = this.FileUpload2.PostedFile.FileName;
                        string path    = this.FileUpload3.PostedFile.FileName;



                        string etype = DropDownList1.SelectedValue.ToString();

                        UpEbook         lg = new UpEbook(this.EbookName.Text, this.Eauthor.Text, this.intrduce.Text, etype, path, picpath);
                        OperationResult bp = bll.Registfile(lg);

                        if (bp.ToString() == "exist")
                        {
                            this.ebooktishi.Text = "记录已存在";
                        }
                        else if (bp.ToString() == "success")
                        {
                            string          user = Session["user"].ToString();
                            string          text = user.ToString() + "上传电子书信息:" + this.EbookName.Text;
                            daysInfo        da   = new daysInfo(user, DateTime.Now.ToLocalTime().ToString(), text);
                            commentBll      bal  = new commentBll();
                            OperationResult ob   = bal.Registday(da);

                            this.FileUpload2.SaveAs(Server.MapPath("~/UploadPic/") + FileUpload2.FileName);
                            this.FileUpload3.SaveAs(Server.MapPath("~/Etext/") + FileUpload3.FileName);
                            this.ebooktishi.Text = "成功.";
                        }
                        else
                        {
                            this.ebooktishi.Text = "意外";
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }
                }
            }
        }
Exemple #2
0
        public int fileupEbook(UpEbook file)
        {
            string cmdText = "insert into T_Ebook(EbookName,author,type,introduce,pathID,viewTimes,path) values(@EbookName,@author,@type,@introduce,@pathID,@viewTimes,@path)";

            string[] paramList = { "@EbookName", "@author", "@type", "@introduce", "@pathID", "@viewTimes", "@path" };
            object[] valueList = { file.name, file.inthro, file.type, file.intrduce, file.bookID, 0, file.path };
            return(db.ExecuteNoneQuery(cmdText, paramList, valueList));
        }
Exemple #3
0
        /// <summary>
        /// 上传电子书
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public OperationResult Registfile(UpEbook file)
        {
            int mun = dao.fileupEbook(file);

            if (mun == 1)
            {
                return(OperationResult.success);
            }
            return(OperationResult.failure);
        }
Exemple #4
0
        public UpEbook selectebook(UpEbook user)
        {
            UpEbook tep = dao.Queryebook(user.name);

            if (tep != null)
            {
                return(tep);
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
        public UpEbook Queryebook(string name)
        {
            string cmdText = "select * from T_Ebook where EbookName = @EbookName";

            string[]      paramList = { "@EbookName" };
            object[]      valueList = { name };
            SqlDataReader reader    = db.ExecuteReader(cmdText, paramList, valueList);
            UpEbook       book      = new UpEbook();

            if (reader.Read())
            {
                book.name     = reader["EbookName"].ToString();
                book.inthro   = reader["author"].ToString();
                book.intrduce = reader["introduce"].ToString();
                book.type     = reader["type"].ToString();
                book.path     = reader["path"].ToString();
            }
            reader.Close();
            return(book);
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] != null)
            {
                logoninfo lg = new logoninfo(Session["user"].ToString());
                lg             = ball.selectname(lg);
                this.user.Text = lg.Name;
                this.loginli.Style["display"] = "none";
            }
            else
            {
                this.userli.Style["display"] = "none";
                this.textshuru.Visible       = false;
                this.Button4.Visible         = false;
            }


            this.name.Text = Session["name"].ToString();
            this.inth.Text = Session["type"].ToString();


            string cmdText = "select * from T_Comment where bookName =  @bookName";

            string[] paramList = { "@bookName" };
            object[] valueList = { this.name.Text };
            DataSet  da        = db.FillDataSet(cmdText, paramList, valueList);

            GridView1.DataSource   = da;
            GridView1.DataSourceID = "";
            GridView1.DataBind();



            if (Session["type"].ToString() == null)
            {
            }
            else if (Session["type"].ToString() == "e")
            {
                this.jieyue.Visible = false;
                string  name = Session["name"].ToString();
                UpEbook lg   = new UpEbook(name);
                lg = bll.selectebook(lg);
                if (lg.path != null)
                {
                    this.smname.Text   = lg.name.ToString();
                    this.name.Text     = lg.name.ToString();
                    this.inth.Text     = lg.inthro.ToString();
                    this.intrduce.Text = lg.intrduce.ToString();
                    this.smtype.Text   = lg.type.ToString();


                    this.Image1.ImageUrl = "~/UploadPic/" + lg.path.ToString() + " ";

                    Session["path"] = lg.path.ToString();
                }
                else
                {
                    this.Image1.ImageUrl = "~/image/pic1.jpg";
                }
            }
            else if (Session["type"].ToString() == "b")
            {
                string name = Session["name"].ToString();
                UpBook lg   = new UpBook(name);
                lg = bll.selectbook(lg);
                if (lg.path != null)
                {
                    this.smname.Text   = lg.name.ToString();
                    this.name.Text     = lg.name.ToString();
                    this.inth.Text     = lg.inthro.ToString();
                    this.intrduce.Text = lg.intrduce.ToString();
                    this.smtype.Text   = lg.type.ToString();

                    this.Image1.ImageUrl = "~/image/" + lg.path.ToString() + " ";
                }
                else
                {
                    this.Image1.ImageUrl = "~/image/pic1.jpg";
                }
            }
        }