private void button1_Click(object sender, EventArgs e)
        {
            BookBll bb   = new BookBll();
            string  info = textBox1.Text.Trim();

            if (info.Equals(""))
            {
                init();
                MessageBox.Show("请输入书籍的编号或书名!", "操作提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                object ob = bb.SelectBookState(info);
                if (ob == null)
                {
                    return;
                }
                else
                {
                    dataGridView1.ColumnHeadersVisible = true;
                    dataGridView1.AutoSizeColumnsMode  = DataGridViewAutoSizeColumnsMode.Fill;
                    dataGridView1.DataSource           = (DataTable)ob;
                }
            }
        }
Esempio n. 2
0
        public BookEntity GetuserTypeDetails()
        {
            BookEntity result = new BookEntity();
            BookBll    bk     = new BookBll();

            result.userlist = bk.GetuserTypeDetails().userlist;
            return(result);
        }
Esempio n. 3
0
        public ActionResult List()
        {
            BookBll     bll   = new BookBll();
            List <Book> books = bll.GetModelList("");

            ViewBag.books = books;
            return(View());
        }
Esempio n. 4
0
        private bool DealWithDeleteBook(dynamic bookValues)
        {
            int id = Convert.ToInt32(bookValues["id"]);

            BookBll bll = new BookBll();

            return(bll.Delete(id));
        }
Esempio n. 5
0
        public JsonResult GetBookList()
        {
            BookBll     bll   = new BookBll();
            List <Book> books = bll.GetModelList("");

            ViewBag.books = books;
            return(Json(books, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        public void SetUp()
        {
            _repository           = Substitute.For <IBookRepository>();
            _publishierRepository = Substitute.For <IPublishierRepository>();
            _bookPublishValidator = Substitute.For <IBookPublishValidator>();
            _publishBookBll       = Substitute.For <IPublishBookBll>();

            _bookBll = new BookBll(_repository, _publishierRepository, _bookPublishValidator, _publishBookBll);
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //列表页传输过来的id
            int     id  = Convert.ToInt32(Request["id"]);
            BookBll bll = new BookBll();
            //从数据库获取实体
            Book model = bll.GetBookModel(id);

            //首次加载,设置视图控件的值
            if (!IsPostBack)
            {
                txtBookName.Value           = model.Bookname;
                txtAuthor.Value             = model.Author;
                txtPublish.Value            = model.Publishing_hose;
                txtYear.Value               = model.YearString;
                txtPrice.Value              = model.Price.ToString();
                txtDecorate.Value           = model.Decorate;
                txtISBN.Value               = model.Number;
                txtAuthor_introduce.Value   = model.Author_introduce;
                txtBook_introduce.InnerText = model.Book_introduce;
                //图片路径获取,并赋值给input
                Imgurl           = model.Image;
                txtCatalog.Value = model.Catalogs;
            }
            else
            {
                //分别设置model实体属性的值
                model.Id               = id;
                model.Bookname         = txtBookName.Value;
                model.Author           = txtAuthor.Value;
                model.Publishing_hose  = txtPublish.Value;
                model.Publishing_year  = Convert.ToDateTime(txtYear.Value);
                model.Price            = Convert.ToDecimal(txtPrice.Value);
                model.Decorate         = txtDecorate.Value;
                model.Number           = txtISBN.Value;
                model.Author_introduce = txtAuthor_introduce.Value;
                model.Book_introduce   = txtBook_introduce.InnerText;
                model.Image            = Request["inputimg"];
                model.Catalogs         = txtCatalog.Value;
                //执行修改
                int result = bll.BookUpdate(model);
                if (result > 0)
                {
                    Response.Write("<script>alert('修改成功!');window.location.href='bookList.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('修改失败!')</script>");
                }
            }
        }
Esempio n. 8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            //context.Response.Write("Hello World");
            int action = Convert.ToInt32(context.Request["action"]);

            if (action == 1)
            {
                string      name   = context.Request["name"];
                BookBll     bll    = new BookBll();
                ValidateMsg v1     = new ValidateMsg();
                int         result = bll.BookExist(name);
                if (result > 0)
                {
                    v1.Success = true;
                    v1.OkMsg   = "用户名已存在!!!";
                }
                else
                {
                    v1.Success = false;
                    v1.OkMsg   = "输入正确!!!";
                }
                JavaScriptSerializer js = new JavaScriptSerializer();
                string str = js.Serialize(v1);
                context.Response.Write(str);
            }
            if (action == 2)
            {
                if (context.Request["num"] != "")
                {
                    int         name   = Convert.ToInt32(context.Request["num"]);
                    BookBll     bll    = new BookBll();
                    ValidateMsg v1     = new ValidateMsg();
                    int         result = bll.NumExist(name);
                    if (result > 0)
                    {
                        v1.Success = true;
                        v1.OkMsg   = "图书编号已存在!!!";
                    }
                    else
                    {
                        v1.Success = false;
                        v1.OkMsg   = "输入正确!!!";
                    }
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string str = js.Serialize(v1);
                    context.Response.Write(str);
                }
            }
        }
Esempio n. 9
0
        public ActionResult DeleteBook(int id)
        {
            BookBll bll = new BookBll();

            if (id > 0)
            {
                Book book = bll.GetModel(id);
                ViewBag.book = book;
            }
            else
            {
                ViewBag.book = null;
            }
            return(View());
        }
Esempio n. 10
0
        private bool DealWithEditBook(dynamic bookValues)
        {
            Book book = new Book()
            {
                id      = Convert.ToInt32(bookValues["id"]),
                name    = bookValues["name"],
                author  = bookValues["author"],
                publish = bookValues["publish"],
                price   = String.IsNullOrEmpty(bookValues["price"]) ? null : Convert.ToDecimal(bookValues["price"]),
                isbn    = bookValues["isbn"],
                cover   = bookValues["cover"],
            };

            BookBll bll = new BookBll();

            return(bll.Update(book));
        }
        private void button1_Click(object sender, EventArgs e)//删除
        {
            string collenum = label7.Text;
            string state    = label8.Text;
            string isbn     = label6.Text;
            string id       = label9.Text;

            if (collenum.Equals(""))
            {
                MessageBox.Show("请先查询出要删除的书籍!", "操作提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (collenum.Equals("0"))
            {
                MessageBox.Show("书库中已没有馆藏量!", "操作提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (state.Equals("使用中"))
            {
                MessageBox.Show("该书在使用中不可删除!", "操作提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                DialogResult dr;
                dr = MessageBox.Show("确定要删除吗?", "确认删除",
                                     MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                if (dr == DialogResult.OK)
                {
                    BookBll bb = new BookBll();
                    int     i  = bb.DeleteBookInfo(isbn, id, collenum);
                    if (i == 1)
                    {
                        MessageBox.Show("删除成功!", "操作提示",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        load_datagridview2(infozz);
                    }
                    else
                    {
                        MessageBox.Show("删除失败!", "操作提示",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Esempio n. 12
0
        //public JsonResult AddBook()
        //{
        //    return new JsonResult();
        //}
        #endregion

        #region 私有业务处理逻辑
        private bool DealWithAddBook(dynamic bookValues)
        {
            Book book = new Book()
            {
                name    = bookValues["name"],
                author  = bookValues["author"],
                publish = bookValues["publish"],
                price   = String.IsNullOrEmpty(bookValues["price"]) ? null : Convert.ToDecimal(bookValues["price"]),
                date    = DateTime.Now.ToString("yyy-MM-dd HH:mm:ss:f"),
                isbn    = bookValues["isbn"],
                cover   = bookValues["cover"],
            };

            BookBll bll = new BookBll();
            int     res = bll.Add(book);

            return(res > 0);
        }
 static void Main(string[] args)
 {
     using (var repo = new RepositoryDal())
     {
         var shelfbll = new ShelfBll(repo);
         var bookBll  = new BookBll(repo);
         var shelf    = new Shelf {
             Location = "some location"
         };
         var book = new Book()
         {
             Name = "some book"
         };
         shelfbll.AddShelf(shelf);
         book.ShelfId = shelf.Id;
         bookBll.AddBook(book);
     }
 }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BookBll bll   = new BookBll();
            Book    model = new Book();

            //如果提交
            if (IsPostBack)
            {
                if (txtISBN.Value.ToString() != "" && txtYear.Value.ToString() != "")
                {
                    model.Bookname         = txtBookName.Value;
                    model.Author           = txtAuthor.Value;
                    model.Publishing_hose  = txtPublish.Value;
                    model.Publishing_year  = Convert.ToDateTime(txtYear.Value);
                    model.Price            = Convert.ToDecimal(txtPrice.Value);
                    model.Decorate         = txtDecorate.Value;
                    model.Number           = txtISBN.Value;
                    model.Author_introduce = txtAuthor_introduce.Value;
                    model.Book_introduce   = txtBook_introduce.Value;
                    model.Image            = imgurl.Value;
                    model.Catalogs         = txtCatalog.Value;
                    model.KindId           = Convert.ToInt32(txtKind.Value);
                    //执行添加方法
                    int result = bll.BookAdd(model);
                    if (result > 0)
                    {
                        Response.Write("<script>alert('添加成功!');window.location.href='bookList.aspx'</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('添加失败!')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('请输入必填项!')</script>");
                }
            }
        }
Esempio n. 15
0
        private void button3_Click(object sender, EventArgs e)
        {
            string isbn = textBox1.Text;

            if (isbn.Equals(""))
            {
                MessageBox.Show("请输入书籍的ISBN号!", "操作提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                int i = int.Parse(textBox2.Text.Trim().ToString());
                if (i > 0)
                {
                    BookBll bb = new BookBll();

                    object obj = bb.SelectBookNameAndCollec(isbn);
                    if (obj == null)
                    {
                        return;
                    }
                    else
                    {
                        MySqlDataReader dr = (MySqlDataReader)obj;

                        string bookname      = null;
                        string collectionnum = null;
                        while (dr.Read())
                        {
                            collectionnum = dr[0].ToString();
                            bookname      = dr[1].ToString();
                        }
                        dr.Close();
                        if (bookname == null)
                        {
                            MessageBox.Show("没有查询到该书,如果该种书籍本馆还未登记过,请先添加该种书籍后,再进行单本添加操作!", "操作提示",
                                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            DialogResult drt;
                            drt = MessageBox.Show("确定要添加书名为<<" + bookname + ">>的书吗?添加数量为" + i + "本", "添加确认",
                                                  MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                            if (drt == DialogResult.OK)
                            {
                                int n = bb.AddSingleBook(isbn, i.ToString(), collectionnum);
                                if (n == 1)
                                {
                                    //添加成功

                                    MessageBox.Show("添加成功!", "操作提示",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                                else
                                {
                                    MessageBox.Show("添加失败!", "操作提示",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("数量不能为0!", "操作提示",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        public void load_datagridview(string info)
        {
            BookBll bb  = new BookBll();
            object  obj = bb.SelectBookANDBookinfo(info);

            if (obj == null)
            {
                init();
                return;
            }
            else
            {
                MySqlDataReader msdr = (MySqlDataReader)obj;
                DataTable       dt   = new DataTable();
                dt.Columns.Add(new DataColumn("ISBN", typeof(string)));
                dt.Columns.Add(new DataColumn("bookname", typeof(string)));
                dt.Columns.Add(new DataColumn("id", typeof(string)));
                dt.Columns.Add(new DataColumn("state", typeof(string)));
                dt.Columns.Add(new DataColumn("collectionnum", typeof(string)));
                DataRow dr = null;
                while (msdr.Read())
                {
                    dr             = dt.NewRow();
                    dr["ISBN"]     = msdr[0];
                    dr["bookname"] = msdr[1];
                    dr["id"]       = msdr[3];
                    if (msdr[4].Equals("A"))
                    {
                        dr["state"] = "未使用";
                    }
                    else if (msdr[4].ToString().Trim().Equals(""))
                    {
                        dr["state"] = "";
                    }
                    else
                    {
                        dr["state"] = "使用中";
                    }


                    dr["collectionnum"] = msdr[2];
                    dt.Rows.Add(dr);
                }
                msdr.Close();
                if (dr == null)
                {
                    init();
                    MessageBox.Show("您查询的内容不存在!", "操作提示",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    dataGridView1.ColumnHeadersVisible = true;
                    dataGridView1.AutoSizeColumnsMode  = DataGridViewAutoSizeColumnsMode.Fill;
                    dataGridView1.Columns[4].Visible   = false;//隐藏最后一列
                    dataGridView1.DataSource           = null;
                    dataGridView1.DataSource           = dt;
                    label1.Visible = true;
                    label2.Visible = true;
                    label3.Visible = true;
                    label5.DataBindings.Clear();
                    label5.DataBindings.Add("Text", dt, "bookname");
                    label6.DataBindings.Clear();
                    label6.DataBindings.Add("Text", dt, "ISBN");
                    label7.DataBindings.Clear();
                    label7.DataBindings.Add("Text", dt, "collectionnum");
                    label8.DataBindings.Clear();
                    label8.DataBindings.Add("Text", dt, "state");
                    label9.DataBindings.Clear();
                    label9.DataBindings.Add("Text", dt, "id");
                    label5.Visible = true;
                    label6.Visible = true;
                    label7.Visible = true;
                }
            }
        }