コード例 #1
0
ファイル: Operation.cs プロジェクト: jk464479460/target
        public void InsertGoodsInfo(Tb_GoodsInfo goodsInfo)
        {
            var cmd = new DataCommand("mySql", "InsertGoodsInfo");

            cmd.SetParameters("@GoodsId", $"{goodsInfo.GoodsId}");
            cmd.SetParameters("@SalePrice", goodsInfo.SalePrice);
            cmd.SetParameters("@Discount", $"{goodsInfo.Discount}");
            cmd.ExeSqlCmd();
        }
コード例 #2
0
ファイル: GoodsHanlder.cs プロジェクト: jk464479460/target
        //入库
        public ResultStockIn GoodsStockIn(QueryGoodsStockIn query)
        {
            var result = new ResultStockIn {
                Exception = new MyException()
            };

            using (var scop = new TransactionScope())
            {
                try
                {
                    var table = new Tb_Goods
                    {
                        Code           = query.Code,
                        LastUpDateTime = DateTime.Now,
                        Name           = query.GoodsName,
                        InnerPrice     = decimal.Parse(query.Price),
                        Numbers        = query.StockInCnt
                    };
                    //_goodsHandler.StockIn(table);
                    var db = new MySqlContext();
                    db.TbGoods.Add(table);
                    db.SaveChanges();
                    var findIt    = db.TbGoods.Where(x => x.Code.Equals(query.Code)).FirstOrDefault();
                    var tableInfo = new Tb_GoodsInfo()
                    {
                        GoodsId   = findIt.Id,
                        SalePrice = query.SalePrice,
                        Discount  = decimal.Parse(query.Discount)
                    };
                    _goodsHandler.InsertGoodsInfo(tableInfo);
                    //db.TbGoodsInfos.Add(tableInfo);

                    scop.Complete();
                    result.Exception.Success = true;
                }
                catch (Exception ex)
                {
                    result.Exception.Success = false;
                    result.Exception.Exmsg   = $"{ex.Message} {ex.StackTrace}";
                }
            }

            return(result);
        }