示例#1
0
        /// <summary>
        /// 调拨出库
        /// </summary>
        /// <param name="TransferId"></param>
        /// <param name="storeId"></param>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public bool OutBoundT(int TransferId, int storeId, int UserId)
        {
            if (!IsTransferCanOutBound(TransferId, storeId))
            {
                return(false);
            }
            //  修改订单状态

            string sql = string.Format(" update Transfer set Status='调拨出库',OutStoreDate='{0}' where Id={1} ", DateTime.Now.ToString(), TransferId);

            if (m_dbo.ExecuteNonQuery(sql))
            {
                GoodsStoreManager gsm = new GoodsStoreManager();
                DataSet           ds  = ReadTransferDetail(TransferId);
                //读取商品明细
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    //循环单个商品
                    int goodsId          = DBTool.GetIntFromRow(row, "GoodsId", 0);
                    int num              = DBTool.GetIntFromRow(row, "Num", 0);
                    int Id               = DBTool.GetIntFromRow(row, "Id", 0);
                    GoodsStoreDetail gsd = new GoodsStoreDetail();
                    gsd.GoodsId    = goodsId;
                    gsd.Num        = num;
                    gsd.Operate    = CommenClass.TransferStatus.调拨出库.ToString();
                    gsd.RelationId = TransferId;
                    gsd.StoreId    = storeId;
                    gsd.UserId     = UserId;
                    double AC = gsm.OutBoundGoods(gsd);
                    if (AC > 0)
                    {
                        Transferdetail tfd = new Transferdetail();
                        tfd.Id = Id;
                        tfd.Load();
                        tfd.AC = AC;
                        tfd.Save();
                    }
                }
            }
            return(true);
        }
示例#2
0
        private bool IsTransferCanOutBound(int TransferId, int StoreId)
        {
            GoodsStoreManager gsm = new GoodsStoreManager();
            //读取IsCalc=1 的商品汇总明细
            string sql = string.Format(@"select GoodsId,SUM(Num) as Num,(select SUM(Num)from view_GoodsStore where GoodsId=a.GoodsId and StoreId={0} group by GoodsId)  as  StoreNum from View_TransferDetail a where TransferId ={1} group by GoodsId  ", StoreId, TransferId);

            DataSet ds = m_dbo.GetDataSet(sql);

            //读取商品明细
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                //循环单个商品
                int num      = DBTool.GetIntFromRow(row, "Num", 0);
                int storeNum = DBTool.GetIntFromRow(row, "StoreNum", 0);
                if (storeNum < num)
                {
                    return(false);
                }
            }
            return(true);
        }