Exemple #1
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 #2
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 #3
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        = "";
                }
            }
        }