예제 #1
0
 public IActionResult Index()
 {
     BLL.Book boek = new BLL.Book();
     dalService.Boek = boek;
     dalService.ReadAll();
     return(View(BLL.Book.List));
 }
        //查询按钮
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == null || textBox1.Text.Trim() == "")
            {
                MessageBox.Show("您还没有填写关键字");
                return;
            }
            BLL.Book bll = new BLL.Book();
            if (isAllField)
            {
                dataGridView1.DataSource = bll.queryByAll(textBox1.Text);
            }
            else
            {
                if (index == 0)
                {
                    strWhere = "b_id like '%" + textBox1.Text.Trim() + "%'";
                }
                else if (index == 1)
                {
                    strWhere = "b_name like '%" + textBox1.Text.Trim() + "%'";
                }
                else if (index == 2)
                {
                    strWhere = "b_author like '%" + textBox1.Text.Trim() + "%'";
                }
                else if (index == 3)
                {
                    strWhere = "b_publisher like '%" + textBox1.Text.Trim() + "%'";
                }

                dataGridView1.DataSource = bll.getRecordsByCondition(strWhere);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (!isIdFilled())
            {
                MessageBox.Show("您还没有填写ID");
                return;
            }


            Model.Book book = new Model.Book();
            book.Id         = textBox1.Text.Trim();
            book.Name       = textBox2.Text.Trim();
            book.Author     = textBox3.Text.Trim();
            book.Publisher  = textBox4.Text.Trim();
            book.Pubtime    = textBox5.Text.Trim();
            book.Pritime    = textBox6.Text.Trim();
            book.Edition    = textBox7.Text.Trim();
            book.Impression = textBox8.Text.Trim();
            book.Pages      = textBox9.Text.Trim();
            book.Words      = textBox10.Text.Trim();
            book.Format     = textBox11.Text.Trim();
            book.Paper      = textBox12.Text.Trim();
            book.Packaging  = textBox13.Text.Trim();
            book.Isbn       = textBox14.Text.Trim();

            book.Picture = picture;

            book.Price     = textBox15.Text.Trim();
            book.Sort      = textBox16.Text.Trim();
            book.Inventory = textBox17.Text.Trim();

            if (book.Picture == null)
            {
                Bitmap       bmp       = (Bitmap)pictureBox1.Image;
                MemoryStream memStream = new MemoryStream();
                bmp.Save(memStream, ImageFormat.Png);
                memStream.Seek(0, SeekOrigin.Begin); //及时定位流的开始位置
                book.Picture = new byte[memStream.Length];
                memStream.Read(book.Picture, 0, book.Picture.Length);
                memStream.Close();
            }

            if (MessageBox.Show("确定要修改吗?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
            {
                return;
            }

            BLL.Book bllBook = new BLL.Book();
            if (bllBook.update(book) == 1)
            {
                MessageBox.Show("修改成功");
            }
            else
            {
                MessageBox.Show("修改失败");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Model.Book book = new Model.Book();


            book.Name       = textBox2.Text.Trim();
            book.Author     = textBox3.Text.Trim();
            book.Publisher  = textBox4.Text.Trim();
            book.Pubtime    = textBox5.Text.Trim();
            book.Pritime    = textBox6.Text.Trim();
            book.Edition    = textBox7.Text.Trim();
            book.Impression = textBox8.Text.Trim();
            book.Pages      = textBox9.Text.Trim();
            book.Words      = textBox10.Text.Trim();
            book.Format     = textBox11.Text.Trim();
            book.Paper      = textBox12.Text.Trim();
            book.Packaging  = textBox13.Text.Trim();
            book.Isbn       = textBox14.Text.Trim();

            book.Picture = picture;

            book.Price     = textBox15.Text.Trim();
            book.Sort      = textBox16.Text.Trim();
            book.Inventory = textBox17.Text.Trim();

            if (book.Name == null || book.Name == "")
            {
                MessageBox.Show("书名不允许为空");
                return;
            }
            if (book.Picture == null)
            {
                Bitmap       bmp       = (Bitmap)pictureBox1.Image;
                MemoryStream memStream = new MemoryStream();
                bmp.Save(memStream, ImageFormat.Png);
                memStream.Seek(0, SeekOrigin.Begin); //及时定位流的开始位置
                book.Picture = new byte[memStream.Length];
                memStream.Read(book.Picture, 0, book.Picture.Length);
                memStream.Close();
            }

            BLL.Book bll = new BLL.Book();

            if (bll.insert(book) == 1)
            {
                MessageBox.Show("增加成功");
            }
            else
            {
                MessageBox.Show("增加失败");
            }
        }
예제 #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            string id = textBox1.Text.Trim();

            if (!isIdFilled())
            {
                MessageBox.Show("您还没有填写ID");
                return;
            }
            if (MessageBox.Show("确定要删除吗?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
            {
                return;
            }

            BLL.Book book = new BLL.Book();
            if (book.delete(id) == 1)
            {
                MessageBox.Show("删除成功");
            }
            else
            {
                MessageBox.Show("删除失败,请确认ID是否正确");
            }
        }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!isIdFilled())
            {
                MessageBox.Show("您还没有填写ID");
                return;
            }

            //先清空所有内容
            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is GroupBox)
                {
                    foreach (Control c in ctrl.Controls)
                    {
                        if (c is TextBox)
                        {
                            TextBox tb = (TextBox)c;
                            tb.Text = "";
                            Console.WriteLine("gld");
                        }
                    }
                }
            }
            pictureBox1.Image = null;



            string id = textBox1.Text.Trim();

            BLL.Book      book   = new BLL.Book();
            SqlDataReader reader = book.queryById(id);

            while (reader.Read())
            {
                textBox1.Text  = reader[0].ToString();
                textBox2.Text  = reader[1].ToString();
                textBox3.Text  = reader[2].ToString();
                textBox4.Text  = reader[3].ToString();
                textBox5.Text  = reader[4].ToString();
                textBox6.Text  = reader[5].ToString();
                textBox7.Text  = reader[6].ToString();
                textBox8.Text  = reader[7].ToString();
                textBox9.Text  = reader[8].ToString();
                textBox10.Text = reader[9].ToString();
                textBox11.Text = reader[10].ToString();
                textBox12.Text = reader[11].ToString();
                textBox13.Text = reader[12].ToString();
                textBox14.Text = reader[13].ToString();
                int bufferSize = 1024 * 100;
                picture = new byte[bufferSize];
                reader.GetBytes(14, 0, picture, 0, bufferSize);

                MemoryStream ms = new MemoryStream(picture);

                try
                {
                    Bitmap bmp = new Bitmap(ms);
                    pictureBox1.Image = bmp;
                }
                catch (Exception)
                {
                }


                textBox15.Text = reader[15].ToString();
                textBox16.Text = reader[16].ToString();
                textBox17.Text = reader[17].ToString();
            }
        }
예제 #7
0
        private void OnBookBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
        {
            _currentBook = uxBookBindingSource.Current as BLL.Book;

            if (_currentBook != null)
            {
                _currentBook.Validate();
            }
            //_Book.Validate();
            OnCurrentEntityChanged();
        }
예제 #8
0
        // GET: Home
        public ActionResult Index()
        {
            var list = new BLL.Book().GetAll();

            return(View(list));
        }