Exemple #1
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (txtCode.Text.Trim() == "")
     {
         MessageBoxEx.Show("请输入商品编码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     Dong.BLL.GoodsInfo   bGoods = new Dong.BLL.GoodsInfo();
     Dong.Model.GoodsInfo mGoods = new Dong.Model.GoodsInfo();
     mGoods = bGoods.GetModel(txtCode.Text.Trim());
     if (mGoods != null)
     {
         txtCategory.Text = mGoods.CategoryName;
         txtFactory.Text  = mGoods.Factory;
         txtName.Text     = mGoods.GoodsName;
         txtKC.Text       = mGoods.Counts.ToString();
         txtSJ.Text       = mGoods.Price0.ToString();
         txtJJ.Text       = mGoods.Price1.ToString();
         txtCB.Text       = mGoods.Price2.ToString();
         txtSuppier.Text  = mGoods.SupplierName;
         txtUnit.Text     = mGoods.UnitName;
     }
     else
     {
         MessageBoxEx.Show("对不起,该商品不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
        /// <summary>
        /// 进货单保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            Dong.BLL.InGoods     bInGoods   = new Dong.BLL.InGoods();
            Dong.Model.InGoods   mInGoods   = new Dong.Model.InGoods();
            Dong.BLL.GoodsInfo   bGoodsInfo = new Dong.BLL.GoodsInfo();
            Dong.Model.GoodsInfo mGoodsInfo = new Dong.Model.GoodsInfo();
            for (int i = 0; i < dGV.Rows.Count; i++)
            {
                //添加进货信息
                mGoodsInfo         = bGoodsInfo.GetModel(dGV.Rows[i].Cells[1].Value.ToString());
                mInGoods.PCode     = lblCode.Text;
                mInGoods.GoodsCode = dGV.Rows[i].Cells[1].Value.ToString();
                mInGoods.Price     = double.Parse(dGV.Rows[i].Cells[3].Value.ToString());
                mInGoods.Counts    = int.Parse(dGV.Rows[i].Cells[4].Value.ToString());
                mInGoods.IDate     = DateTime.Now.Date;
                mInGoods.Oper      = txtOper.Text;
                mInGoods.Supplier  = mGoodsInfo.Supplier;
                mInGoods.Remark    = "";
                bInGoods.Add(mInGoods);

                //修改商品信息
                //进货价格
                double oldPrice1 = (double)mGoodsInfo.Price1;
                mGoodsInfo.Price1 = double.Parse(dGV.Rows[i].Cells[3].Value.ToString());

                //数量
                mGoodsInfo.Counts = mGoodsInfo.Counts + int.Parse(dGV.Rows[i].Cells[4].Value.ToString());

                //成本价
                int    totalCount = (int)mGoodsInfo.Counts + int.Parse(dGV.Rows[i].Cells[4].Value.ToString());
                double totalPrice = (oldPrice1 * (int)mGoodsInfo.Counts) + (double.Parse(dGV.Rows[i].Cells[3].Value.ToString()) * int.Parse(dGV.Rows[i].Cells[4].Value.ToString()));
                double cbPrice    = totalPrice / totalCount;
                mGoodsInfo.Price2 = cbPrice;
                bGoodsInfo.Update(mGoodsInfo);
            }

            frmInput frm = (frmInput)this.Owner;

            frm.refreshData();
            this.Close();
        }
        protected void addGoods()
        {
            Dong.BLL.GoodsInfo   bGoods = new Dong.BLL.GoodsInfo();
            Dong.Model.GoodsInfo mGoods = new Dong.Model.GoodsInfo();
            mGoods = bGoods.GetModel(tbCode.Text.Trim());
            if (mGoods != null)
            {
                if (mGoods.Counts > 0)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dGV);

                    row.Cells[0].Value = mGoods.Code;
                    row.Cells[1].Value = mGoods.GoodsName;
                    row.Cells[2].Value = string.Format("{0:F2}", mGoods.Price0);
                    row.Cells[3].Value = "1";
                    row.Cells[4].Value = string.Format("{0:F2}", (mGoods.Price0 * int.Parse(row.Cells[3].Value.ToString())));
                    dGV.Rows.Add(row);
                    row.Selected = true;
                    tbCode.Text  = "";

                    //计算总钱数
                    sumCash();
                    lblGoodsName.Text = mGoods.GoodsName;
                    lblStock.Text     = mGoods.Counts.ToString();
                }
                else
                {
                    MessageBox.Show("对不起,此商品缺货!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("对不起,没有此商品!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //验证商品编号

            if (tbCode.Text.Trim() == "")
            {
                MessageBoxEx.Show("请输入商品商品!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbCode.Focus();
                return;
            }

            //验证商品名称
            if (tbName.Text.Trim() == "")
            {
                MessageBoxEx.Show("请输入商品名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbName.Focus();
                return;
            }
            if (tbFactory.Text.Trim() == "")
            {
                MessageBoxEx.Show("请输入商品生产厂家!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbFactory.Focus();
                return;
            }

            if (txtPrice0.Text.Trim() == "")
            {
                MessageBoxEx.Show("请输入零售价!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPrice0.Focus();
                return;
            }
            double price0;

            if (!double.TryParse(txtPrice0.Text, out price0))
            {
                MessageBoxEx.Show("零售价必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPrice0.Focus();
                return;
            }


            if (txtPrice1.Text.Trim() == "")
            {
                MessageBoxEx.Show("请输入进货价!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPrice1.Focus();
                return;
            }
            double price1;

            if (!double.TryParse(txtPrice1.Text, out price1))
            {
                MessageBoxEx.Show("进货价必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPrice1.Focus();
                return;
            }

            if (txtPrice2.Text.Trim() == "")
            {
                MessageBoxEx.Show("请输入成本价!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPrice2.Focus();
                return;
            }
            double price2;

            if (!double.TryParse(txtPrice2.Text, out price2))
            {
                MessageBoxEx.Show("成本价必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPrice2.Focus();
                return;
            }

            Dong.BLL.GoodsInfo   bll   = new Dong.BLL.GoodsInfo();
            Dong.Model.GoodsInfo model = new Dong.Model.GoodsInfo();
            model           = bll.GetModel(tbCode.Text);
            model.Id        = int.Parse(this.Tag.ToString());
            model.Code      = tbCode.Text;
            model.GoodsName = tbName.Text;
            if (ddlCategory.SelectedValue != null && !string.IsNullOrEmpty(ddlCategory.SelectedValue.ToString()))
            {
                model.Category     = Int32.Parse(ddlCategory.SelectedValue.ToString());
                model.CategoryName = ddlCategory.Text;
            }
            else
            {
                model.CategoryName = "";
            }
            if (ddlUnit.SelectedValue != null && !string.IsNullOrEmpty(ddlUnit.SelectedValue.ToString()))
            {
                model.Unit     = Int32.Parse(ddlUnit.SelectedValue.ToString());
                model.UnitName = ddlUnit.Text;
            }
            else
            {
                model.UnitName = "";
            }

            if (ddlSupper.SelectedValue != null && !string.IsNullOrEmpty(ddlSupper.SelectedValue.ToString()))
            {
                model.Supplier     = Int32.Parse(ddlSupper.SelectedValue.ToString());
                model.SupplierName = ddlSupper.Text;
            }
            else
            {
                model.SupplierName = "";
            }
            model.Factory = tbFactory.Text;
            model.Counts  = model.Counts;
            model.Price0  = price0;
            model.Price1  = price1;
            model.Price2  = price2;
            if (bll.Update(model))
            {
                MessageBoxEx.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmGoods frm = (frmGoods)this.Owner;
                frm.refreshData();
                this.Close();
            }
            else
            {
                MessageBoxEx.Show("修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }