protected void Button6_Click(object sender, EventArgs e) { FileUploadInfo lbg = new FileUploadInfo(this.booklib.Text, this.libphone.Text); lbg = bll.selectlib(lbg); string type = DropDownList2.SelectedValue.ToString(); string picpath = this.FileUpload4.PostedFile.FileName; UpBook lg = new UpBook(this.bookName.Text, this.author.Text, this.intrduce.Text, type, this.maxcount.Text, this.usablecount.Text, lbg.path, picpath); OperationResult bp = bll.Registbook(lg); this.Image3.ImageUrl = "~/UploadPic/" + FileUpload4.FileName; if (bp.ToString() == "exist") { this.booktishi.Text = "记录已存在"; } else if (bp.ToString() == "success") { string user = Session["user"].ToString(); string text = user.ToString() + "上传图书信息:" + this.bookName.Text; daysInfo da = new daysInfo(user, DateTime.Now.ToLocalTime().ToString(), text); commentBll bal = new commentBll(); OperationResult ob = bal.Registday(da); this.booktishi.Text = "成功."; this.FileUpload4.SaveAs(Server.MapPath("~/UploadPic/") + FileUpload4.FileName); } else { this.booktishi.Text = "意外"; } }
public int fileupbook(UpBook file) { string cmdText = "insert into T_Book(bookName,author,introduce,type,maxCount,usableCount,libID,borrowTimes,isDelete,path) values(@EbookName,@author,@introduce,@type,@maxCount,@usableCount,@libID,@borrowTimes,@isDelete,@path)"; string[] paramList = { "@EbookName", "@author", "@introduce", "@maxCount", "@usableCount", "type", "@libID", "@borrowTimes", "@isDelete", "@path" }; object[] valueList = { file.name, file.inthro, file.intrduce, file.maxcount, file.usablecount, file.type, file.bookID, 0, 0, file.path }; return(db.ExecuteNoneQuery(cmdText, paramList, valueList)); }
/// <summary> /// 上传图书 /// </summary> /// <param name="user"></param> /// <returns></returns> public OperationResult Registbook(UpBook file) { int mun = dao.fileupbook(file); if (mun == 1) { return(OperationResult.success); } return(OperationResult.failure); }
/// <summary> /// 根据name查修 /// </summary> /// <returns></returns> public UpBook selectbook(UpBook user) { UpBook tep = dao.Querybook(user.name); if (tep != null) { return(tep); } else { return(null); } }
public UpBook Querybook(string name) { string cmdText = "select * from T_Book where bookName = @bookName"; string[] paramList = { "@bookName" }; object[] valueList = { name }; SqlDataReader reader = db.ExecuteReader(cmdText, paramList, valueList); UpBook book = new UpBook(); if (reader.Read()) { book.name = reader["bookName"].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); }
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"; } } }