Exemple #1
0
        private void btn_JianSuo_Click(object sender, EventArgs e)
        {
            //检索条形码是否存在  如果存在则将数据显示出来
            DataTable dt = BooksBLL.SelectBooksTypeByBarCode(txt_tiaoxingma.Text);

            if (dt.Rows.Count == 1)
            {
                MessageBox.Show("当前书本已存在", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txt_goodsname.Text           = dt.Rows[0]["BooksName"].ToString();
                this.cbo_type.Text           = dt.Rows[0]["TypeName"].ToString();
                txt_jinjia.Text              = dt.Rows[0]["StorePrice"].ToString();
                txt_maijia.Text              = dt.Rows[0]["SalePrice"].ToString();
                txt_zhekou.Text              = dt.Rows[0]["Discount"].ToString();
                lbl_kucun.Text               = dt.Rows[0]["StockNum"].ToString();
                label8.Text                  = "当前库存数:";
                this.txt_goodsname.ReadOnly  = true;
                this.txt_jinjia.ReadOnly     = true;
                this.txt_maijia.ReadOnly     = true;
                this.txt_tiaoxingma.ReadOnly = true;
                this.txt_zhekou.ReadOnly     = true;
                this.cbo_type.Enabled        = false;
            }
            else
            {
                MessageBox.Show("书本不存在,请填写信息", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Exemple #2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (int.Parse(BooksBLL.GetBooksLikeName(BooksBLL.GetMinStockBooksName()).Rows[0][7].ToString()) < 6)
     {
         MessageBox.Show("《" + BooksBLL.GetMinStockBooksName() + "》" + " 库存不足6本!", "库存警告", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
 }
Exemple #3
0
 /// <summary>
 /// 删除书本
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void skinButton4_Click(object sender, EventArgs e)
 {
     try
     {
         //删除书本
         if (BooksBLL.DeleteBooks(id))
         {
             MessageBox.Show("删除成功", "温馨提示");
         }
         else
         {
             MessageBox.Show("请选择您要删除的书本", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("请联系管理员" + ex, "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         throw;
     }
     finally
     {
         //绑定数据源
         //初始化文本框数据
         this.dgv_goods.DataSource = BooksBLL.GetBooksandType();
         this.txt_goodsname.Text   = null;
         this.txt_jinjia.Text      = null;
         this.txt_kucun.Text       = null;
         this.txt_shoujia.Text     = null;
         this.txt_tiaoxingma.Text  = null;
         this.txt_zhekou.Text      = null;
     }
 }
Exemple #4
0
 private void showbooknum_Tick(object sender, EventArgs e)
 {
     if (int.Parse(BooksBLL.GetBooksLikeName(BooksBLL.GetMinStockBooksName()).Rows[0][7].ToString()) < 6)
     {
         //MessageBox.Show(BooksBLL.GetMinStockBooksName() + " 库存不足6本!", "库存警告", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         this.kucunwarn.Text = "《" + BooksBLL.GetMinStockBooksName() + "》" + " 库存不足6本!";
     }
     else
     {
         this.kucunwarn.Text = "";
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Books b = new Books();

            b.Code      = Convert.ToInt32(txtBookCode.Text);
            b.Author    = txtBookAuthor.Text;
            b.Publisher = txtBookPublisher.Text;
            b.Title     = txtBookTitle.Text;
            BooksBLL bbll = new BooksBLL();

            bbll.SaveBooks(false, b);
            lblMessage.Text = "Books Saved Successfully!";
        }
 private void txtBookCode_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (txtBookCode.Text.Trim() != string.Empty)
         {
             BooksBLL bll = new BooksBLL();
             bk = bll.GetBook().Where(b => b.Code.ToString() == txtBookCode.Text).Single <Books>();
             this.txtTitle.Text  = bk.Title;
             this.txtAuthor.Text = bk.Author;
             this.txtQty.Focus();
         }
     }
 }
Exemple #7
0
        int booktype; //保存当前书本类型
        private void WarehouseForm_Load(object sender, EventArgs e)
        {
            //显示所有书本
            //不允许自动创建列
            this.dgv_goods.AutoGenerateColumns = false;
            //绑定数据源
            this.dgv_goods.DataSource = BooksBLL.GetBooksandType();
            //初始最大化
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            //设置为可编辑状态
            // dgv_goods.BeginEdit(false);
            //查询类型
            DataTable dt = TypeBLL.selecttype();

            //遍历出所有类型
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                this.cbo_type.Items.Add(dt.Rows[i][1]);
            }
        }
Exemple #8
0
        /// <summary>
        /// 添加书本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void skinButton2_Click(object sender, EventArgs e)
        {
            //获取类型ID
            try
            {
                booktype = TypeBLL.GetTypeIDByTypeName(this.cbo_type.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("请先去添加书本类型", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            try
            {
                //添加书本
                if (this.txt_goodname.Text == "" || this.txt_jinjia.Text == "" || this.txt_kucun.Text == "" || this.txt_shoujia.Text == "" || this.txt_tiaoxingma.Text == "" || this.txt_zhekou.Text == "")
                {
                    MessageBox.Show("带*号不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                else if (TextBoxBll.Intextnull(this.txt_kucun.Text, 2))
                {
                    MessageBox.Show("库存必须为正整数", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else if (TextBoxBll.Intextnull(this.txt_zhekou.Text, 4))
                {
                    MessageBox.Show("折扣请输入0~1的数字", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                else if (BooksBLL.SelectBooksTypeByBarCode(this.txt_tiaoxingma.Text).Rows.Count > 0)
                {
                    MessageBox.Show("该条形码已存在", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                else if (TextBoxBll.Intextnull(this.txt_tiaoxingma.Text, 1))
                {
                    MessageBox.Show("条形码长度过长", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    Books gs = new Books();
                    gs.BooksName  = this.txt_goodname.Text;
                    gs.TypeID     = booktype;
                    gs.BarCode    = this.txt_tiaoxingma.Text;
                    gs.StorePrice = decimal.Parse(this.txt_jinjia.Text.ToString());
                    gs.SalePrice  = decimal.Parse(this.txt_shoujia.Text.ToString());
                    gs.Discount   = decimal.Parse(this.txt_zhekou.Text.ToString());
                    gs.StockNum   = int.Parse(this.txt_kucun.Text);
                    gs.StockDate  = DateTime.Parse(this.dtp_riqi.Text.ToString());
                    if (BooksBLL.InsertBooks(gs))
                    {
                        MessageBox.Show("添加成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        //绑定数据源
                        this.dgv_goods.DataSource = BooksBLL.GetBooksandType();
                        //初始化文本框数据
                        this.txt_goodsname.Text  = null;
                        this.txt_jinjia.Text     = null;
                        this.txt_kucun.Text      = null;
                        this.txt_shoujia.Text    = null;
                        this.txt_tiaoxingma.Text = null;
                        this.txt_zhekou.Text     = null;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("请正确填写信息", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Exemple #9
0
        /// <summary>
        /// 修改书本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void skinButton3_Click(object sender, EventArgs e)
        {
            if (id == 0)
            {
                return;
            }
            //获取类型ID
            booktype = TypeBLL.GetTypeIDByTypeName(this.cbo_type.Text);
            if (booktype == 0)
            {
                MessageBox.Show("请选择书本类型", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            try
            {
                if (error)
                {
                    //修改书本
                    string pattern = @"^[0]+(\.[0-9]{1,3})?$";
                    Match  m       = Regex.Match(this.txt_zhekou.Text, pattern); // 匹配正则表达式

                    if (this.txt_goodname.Text == "" || this.txt_jinjia.Text == "" || this.txt_kucun.Text == "" || this.txt_shoujia.Text == "" || this.txt_tiaoxingma.Text == "" || this.txt_zhekou.Text == "")
                    {
                        MessageBox.Show("带*号不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else if (float.Parse(txt_zhekou.Text) > 1 || float.Parse(txt_zhekou.Text) < 0)
                    {
                        MessageBox.Show("折扣必须输入0~1的数", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else if (this.txt_tiaoxingma.Text.Length >= 50)
                    {
                        MessageBox.Show("条形码长度过长", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else if (!m.Success && this.txt_zhekou.Text != "1" && this.txt_zhekou.Text != "1.0")
                    {
                        MessageBox.Show("折扣请输入0~1的数字", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        return;
                    }
                    else
                    {
                        if (int.Parse(this.txt_kucun.Text) >= 0)
                        {
                            Books gs = new Books();
                            gs.BooksName  = this.txt_goodname.Text;
                            gs.TypeID     = booktype;
                            gs.BarCode    = this.txt_tiaoxingma.Text;
                            gs.StorePrice = decimal.Parse(this.txt_jinjia.Text.ToString());
                            gs.SalePrice  = decimal.Parse(this.txt_shoujia.Text.ToString());
                            gs.Discount   = decimal.Parse(this.txt_zhekou.Text.ToString());
                            gs.StockNum   = int.Parse(this.txt_kucun.Text);
                            gs.StockDate  = DateTime.Parse(this.dtp_riqi.Text.ToString());
                            gs.BooksID    = id;
                            if (BooksBLL.UpdateBooks(gs))
                            {
                                MessageBox.Show("修改成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                flag = true;
                            }
                        }
                        else
                        {
                            MessageBox.Show("库存必须为正整数,请重新操作", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("书本信息填写失误", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("请联系管理员:" + ex.Message, "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            finally
            {
                if (flag)
                {
                    //绑定数据源
                    this.dgv_goods.DataSource = BooksBLL.GetBooksandType();
                }
            }
        }
Exemple #10
0
 /// <summary>
 /// 模糊查询书本
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_chaxun_Click(object sender, EventArgs e)
 {
     this.dgv_goods.DataSource = BooksBLL.GetBooksLikeName(txt_goodsname.Text);
 }
Exemple #11
0
        /// <summary>
        /// 导入书本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_daoru_Click(object sender, EventArgs e)
        {
            int  allNum = 0;    //统计书本总数
            bool b      = true; //用于判断书本是否存在
            //如果按的是“回车键”
            //获取条形码
            string barCode = this.txt_shangping.Text;

            if (true)
            {
                //购物列表中不存在该书本
                //根据输入的条形码,查询书本信息
                DataTable dt_books = BooksBLL.SelectBooksTypeByBarCode(barCode);
                //未查询到书本
                if (dt_books.Rows.Count == 0)
                {
                    MessageBox.Show("书本未找到,请检查条形码是否正确!", "温馨提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (dt_books.Rows[0]["StockNum"].ToString() == "0")
                {
                    MessageBox.Show("书本以售空,请及时补货", "温馨提示");
                    return;
                }

                bool flag = true;
                //书本是否存在于购物车 计算书本数量
                for (int i = 0; i < this.lv_sales.Items.Count; i++)
                {
                    //判断添加书本数量是否超过库存
                    if (dt_books.Rows[0]["BooksName"].ToString() == this.lv_sales.Items[i].SubItems[2].Text)
                    {
                        string goodsName = dt_books.Rows[0]["BooksName"].ToString();
                        int    stockNum  = BooksBLL.GetStockNumByBooksName(goodsName);;
                        if (stockNum == num)
                        {
                            MessageBox.Show("库存数不足", "温馨提示");
                            b    = false;
                            flag = false;
                            break;
                        }
                        else
                        {
                            if (flag)
                            {
                                this.lv_sales.Items[i].SubItems[6].Text = (int.Parse(this.lv_sales.Items[i].SubItems[6].Text) + 1).ToString();
                                num++;            //书本存在则数量加  1
                                b        = false; //如果书本存在则把布尔变量b--赋值为false
                                discount = double.Parse(dt_books.Rows[0]["Discount"].ToString());
                                price    = double.Parse(dt_books.Rows[0]["SalePrice"].ToString()) * discount;
                                //显示金额信息
                                this.lbl_money.Text = sum.ToString();
                            }
                        }
                    }
                    else
                    {
                        //初始化数量
                        num = 1;
                    }
                }
                if (b)
                {
                    //创建购物项
                    ListViewItem item = new ListViewItem(dt_books.Rows[0]["BarCode"].ToString());
                    item.SubItems.Add(dt_books.Rows[0]["BooksID"].ToString());
                    item.SubItems.Add(dt_books.Rows[0]["BooksName"].ToString());
                    item.SubItems.Add(dt_books.Rows[0]["TypeName"].ToString());
                    item.SubItems.Add(dt_books.Rows[0]["SalePrice"].ToString());
                    item.SubItems.Add(dt_books.Rows[0]["Discount"].ToString());
                    item.SubItems.Add(num.ToString());

                    //for (int i = 0; i < lv_sales.Items.Count; i++)
                    //{
                    //    //记录书本ID,结算时需要用到该值
                    //    id1[i] = int.Parse(dt_goods.Rows[0]["BooksID"].ToString());
                    //}
                    //添加至购物车列表
                    this.lv_sales.Items.Add(item);
                }
                //获取ListView(书本)中所有行并显示
                for (int i = 0; i < this.lv_sales.Items.Count; i++)
                {
                    allNum += int.Parse(this.lv_sales.Items[i].SubItems[6].Text);
                }
                DataTable dt = VipBll.SetVipByMobile(this.txt_vip.Text);
                if (flag)
                {
                    allGoodsNum    = allNum;
                    lbl_goods.Text = allNum.ToString();
                    discount       = double.Parse(dt_books.Rows[0]["Discount"].ToString());
                    price          = double.Parse(dt_books.Rows[0]["SalePrice"].ToString()) * discount;
                    //求和
                    sum += (price);                                                                       //得到真实总价

                    sum4 = sum;                                                                           //将现在的总价赋给临时变量,sum4来处理积分抵扣显示数据
                    if (checkBox1.Checked == true)                                                        //若选择抵扣
                    {
                        if (sum > int.Parse(dt.Rows[0][4].ToString()) * 0.1)                              //如果真实总价大于积分抵扣
                        {
                            sum4 -= int.Parse(dt.Rows[0][4].ToString()) * 0.1;                            //临时总价被抵扣
                            this.jifenxianshi.Text = "积分已抵扣" + int.Parse(dt.Rows[0][4].ToString()) * 0.1; //显示抵扣积分
                        }
                        if (sum <= int.Parse(dt.Rows[0][4].ToString()) * 0.1)                             //表示总价小于积分
                        {
                            sum4 = 0;
                            this.jifenxianshi.Text = "积分已抵扣" + sum; //显示抵扣积分
                            bijiao = false;                         //标记 总价小于积分
                        }
                    }
                    if (checkBox1.Checked == false)
                    {
                        sum4 = sum;                        //还原价格
                    }
                    this.lbl_money.Text = sum4.ToString(); //显示改变的价格
                }
            }
        }
Exemple #12
0
        int stocknum = 0; //库存
        /// <summary>
        /// 确定购买按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_jiezhang_Click(object sender, EventArgs e)
        {
            if (this.lv_sales.Items.Count == 0)
            {
                MessageBox.Show("当前无添加书本", "温馨提示");
                return;
            }
            else
            {
                //检索是否能否成功销售
                int error = 0;
                for (int i = 0; i < this.lv_sales.Items.Count; i++)
                {
                    stocknum = int.Parse(this.lv_sales.Items[i].SubItems[6].Text.ToString());
                    if (!BooksBLL.UpdateBooksStockNum(this.lv_sales.Items[i].SubItems[2].Text.ToString(), stocknum))
                    {
                        error++;
                    }
                }
                if (error > 0)
                {
                    MessageBox.Show("库存数可能不足", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    //存已买的书本的信息
                    string info = "单号:" + lbl_danhao.Text + "\r\n";
                    //将书本信息存入字符变量info
                    for (int i = 0; i < this.lv_sales.Items.Count; i++)
                    {
                        info += "书本名字:" + this.lv_sales.Items[i].SubItems[2].Text + "\r\n书本价格:" + this.lv_sales.Items[i].SubItems[4].Text + "\r\n书本折扣:" + this.lv_sales.Items[i].SubItems[5].Text + "\r\n书本数量:" + this.lv_sales.Items[i].SubItems[6].Text + "\r\n";
                    }
                    info += "总金额:" + lbl_money.Text + "\r\n";
                    info += "购物员:" + lbl_yuangong.Text;
                    //创建打印信息
                    for (int i = 0; i < this.lv_sales.Items.Count; i++)
                    {
                        if (stocknum >= 0)
                        {
                            using (StreamWriter st = new StreamWriter(@"D:\小票.txt", false, Encoding.UTF8))
                            {
                                if (!TextBoxBll.Intextnull(this.txt_shishou.Text, 2) || TextBoxBll.Intextnull(this.txt_shishou.Text, 1))
                                {
                                    if (this.txt_shishou.Text == "")
                                    {
                                        MessageBox.Show("请输入实收金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                        return;
                                    }
                                    else if (this.txt_shishou.Text != null && double.Parse(this.txt_shishou.Text.ToString()) >= double.Parse(this.lbl_money.Text.ToString()))
                                    {
                                        this.lbl_zhaoling.Text = (double.Parse(this.txt_shishou.Text.ToString()) - double.Parse(this.lbl_money.Text.ToString())).ToString();
                                        st.Write(info);
                                        st.Flush();
                                        messge = true;
                                    }
                                    else
                                    {
                                        MessageBox.Show("实收金额小于应付金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                        return;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("请正确输入预收金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                }
                            }
                        }
                    }
                }

                //结算成功
                if (messge)
                {
                    //将信息保存至销售表
                    int      Salesmanid = SalemanBll.SelectSalemanByName(this.lbl_yuangong.Text);
                    DateTime time       = DateTime.Parse(DateTime.Now.ToString("yyyy年MM月dd日"));
                    SaleBll.InsertSale(this.lbl_danhao.Text, time, sum, Salesmanid);
                    for (int j = 0; j < lv_sales.Items.Count; j++)
                    {
                        //将信息保存至销售详情表
                        SalesDetail sale = new SalesDetail()
                        {
                            BooksID     = BooksBLL.GetBooksIDbyBooksName(this.lv_sales.Items[j].SubItems[2].Text),
                            Quantity    = num,
                            SalesID     = SaleBll.GetSDIDByTime(this.lbl_danhao.Text),
                            AloneAmount = decimal.Parse(this.lv_sales.Items[j].SubItems[4].Text) * decimal.Parse(this.lv_sales.Items[j].SubItems[5].Text)
                        };
                        SalesDailBLL.InsertSaleDail(sale);
                    }
                    DataTable dt = VipBll.SetVipByMobile(this.txt_vip.Text);
                    if (isVIP)
                    {
                        if (bijiao == true)                                                                 //总价大于积分,默认为true
                        {
                            double sum2 = sum / 10;                                                         // 1:10积分产生
                            int    sum1 = (int)sum2;                                                        //积分取整
                            if (checkBox1.Checked == true)                                                  //若使用积分抵扣
                            {
                                sum = sum - double.Parse(dt.Rows[0][4].ToString()) * 0.1;                   //真实价格处理
                                VipBll.ClearjifenByPhone(this.txt_vip.Text);                                //积分已抵扣完,现将vip积分清空
                            }
                            VipBll.UpdatejifenByPhone(this.txt_vip.Text, int.Parse(sum1.ToString()));       //正常积分增加
                            this.jifenshu.Text = sum1.ToString();                                           //显示结账后的积分
                        }
                        if (bijiao == false)                                                                //总价小于积分抵扣。积分有剩
                        {
                            double sum2 = sum * 10;                                                         //花费的积分
                            int    sum5 = (int)(double.Parse(dt.Rows[0][4].ToString()) - sum2);             //抵扣后的积分
                            if (checkBox1.Checked == true)                                                  //若使用积分
                            {
                                sum = 0;                                                                    //真实价格处理
                                VipBll.DecreasejifenByPhone(this.txt_vip.Text, int.Parse(sum2.ToString())); //之前积分减去抵扣积分
                            }
                            VipBll.UpdatejifenByPhone(this.txt_vip.Text, int.Parse(sum.ToString()));        //正常积分增加,不过总价以为0,积分不会增加
                            this.jifenshu.Text = sum5.ToString();                                           //显示结账后的积分
                        }
                    }
                    MessageBox.Show("结算成功,祝您生活愉快", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    //信息初始化
                    this.lv_sales.Items.Clear();
                    this.lbl_goods.Text = "0";
                    liushuihao();
                    this.lbl_money.Text = "0.0000";
                    num = 1;
                    this.lbl_zhaoling.Text = "0.0";
                    this.txt_shishou.Text  = "";
                    this.jifenxianshi.Text = "";
                    error  = 0;
                    sum    = 0;
                    sum3   = 0;
                    sum4   = 0;
                    bijiao = true;
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// 添加书本
        /// </summary>
        public void 添加书本()
        {
            //执行命令
            if (this.txt_goodsname.Text == "")
            {
                MessageBox.Show("书名不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (this.txt_tiaoxingma.Text == "")
            {
                MessageBox.Show("书的条形码不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (this.txt_tiaoxingma.Text == "")
            {
                MessageBox.Show("书的条形码不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (TextBoxBll.Intextnull(this.txt_zhekou.Text, 4))
            {
                MessageBox.Show("折扣必须为0~1的小数", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (TextBoxBll.Intextnull(this.txt_goodsnum.Text, 2))
            {
                MessageBox.Show("书的数量错误", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (decimal.Parse(this.txt_jinjia.Text.ToString()) < 0 || this.txt_jinjia.Text == "")
            {
                MessageBox.Show("请正确填写书的进价", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (decimal.Parse(this.txt_maijia.Text.ToString()) < 0 || this.txt_maijia.Text == "")
            {
                MessageBox.Show("请正确填写书的售价", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (decimal.Parse(this.txt_zhekou.Text.ToString()) > 0 && decimal.Parse(this.txt_zhekou.Text.ToString()) < 1 || this.txt_zhekou.Text == "")
            {
                MessageBox.Show("请正确填写书的折扣", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }
            else if (int.Parse(this.txt_goodsnum.Text.ToString()) < 0)
            {
                MessageBox.Show("进货数量不正确", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            Books gs = new Books();

            gs.BooksName  = this.txt_goodsname.Text;
            gs.TypeID     = TypeBLL.GetTypeIDByTypeName(this.cbo_type.Text);
            gs.BarCode    = this.txt_tiaoxingma.Text;
            gs.StorePrice = decimal.Parse(this.txt_jinjia.Text.ToString());
            gs.SalePrice  = decimal.Parse(this.txt_maijia.Text.ToString());
            gs.Discount   = decimal.Parse(this.txt_zhekou.Text.ToString());
            gs.StockNum   = int.Parse(this.txt_goodsnum.Text);
            gs.StockDate  = DateTime.Parse(DateTime.Now.ToString("yyyy年MM月dd日HH:mm:ss"));
            DataTable dt = BooksBLL.SelectBooksTypeByBarCode(this.txt_tiaoxingma.Text);

            //进货
            if (dt.Rows.Count == 1)
            {
                try
                {
                    //进货
                    int newGoods = int.Parse(this.txt_goodsnum.Text);
                    int oldGoods = int.Parse(dt.Rows[0]["StockNum"].ToString());
                    BooksBLL.InsertbooksByBarCod(newGoods, oldGoods, this.txt_tiaoxingma.Text);
                    MessageBox.Show("进货成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    this.txt_goodsname.ReadOnly  = false;
                    this.txt_jinjia.ReadOnly     = false;
                    this.txt_maijia.ReadOnly     = false;
                    this.txt_tiaoxingma.ReadOnly = false;
                    this.txt_zhekou.ReadOnly     = false;
                    this.cbo_type.Enabled        = true;
                    //初始化数据
                    this.cbo_type.Text       = "";
                    this.txt_goodsname.Text  = "";
                    this.txt_goodsnum.Text   = "";
                    this.txt_jinjia.Text     = "";
                    this.txt_maijia.Text     = "";
                    this.txt_tiaoxingma.Text = "";
                    this.txt_zhekou.Text     = "";
                }
            }
            else
            {
                try
                {
                    //执行添加操作
                    if (BooksBLL.InsertBooks(gs))
                    {
                        MessageBox.Show("添加成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    //初始化数据
                    this.cbo_type.SelectedIndex = 0;
                    this.txt_goodsname.Text     = "";
                    this.txt_goodsnum.Text      = "";
                    this.txt_jinjia.Text        = "";
                    this.txt_maijia.Text        = "";
                    this.txt_tiaoxingma.Text    = "";
                    this.txt_zhekou.Text        = "";
                }
            }
        }