Example #1
0
        public DataSet GoodsACList()
        {
            GoodsAC goodsac = new GoodsAC();
            string  sql     = "select * from View_GoodsAC";

            return(m_dbo.GetDataSet(sql));
        }
Example #2
0
        public DataSet GoodsACList(int Goodsid)
        {
            GoodsAC goodsac = new GoodsAC();
            string  sql     = string.Format("select * from View_GoodsAC where GoodsId={0}", Goodsid);

            return(m_dbo.GetDataSet(sql));
        }
Example #3
0
        /// <summary>
        /// 调拨入库,撤销入库
        /// </summary>
        /// <param name="TransferId"></param>
        /// <param name="storeId"></param>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public bool InBoundT(int TransferId, int storeId, int UserId)
        {
            Transfer t = new Transfer();

            t.Id = TransferId;
            t.Load();
            bool storevalid = false;

            if (t.InStoreId == storeId)
            {
                t.InStoreDate   = DateTime.Now;
                t.Status        = CommenClass.TransferStatus.调拨入库.ToString();
                t.InStoreUserId = UserId;
                t.Save();
                storevalid = true;
            }
            else if (t.OutStoreId == storeId)
            {
                t.UpdateDate   = DateTime.Now;
                t.Status       = CommenClass.TransferStatus.待出库.ToString();
                t.OutStoreDate = new DateTime(1900, 1, 1);
                t.Save();
                storevalid = true;
            }
            else
            {
                return(false);
            }
            if (storevalid)
            {
                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);
                    double     AC      = DBTool.GetDoubleFromRow(row, "AC", 0);
                    GoodsStore gs      = new GoodsStore();
                    gs.GoodsId = goodsId;
                    gs.StoreId = storeId;
                    gs.Load(storeId, goodsId);
                    //修改库存 成本和数量,如果是固定成本的 直接赋值
                    GoodsAC ga = new GoodsAC();
                    if (ga.Load(t.InBranchId, goodsId))
                    {
                        gs.AC = ga.Goods_AC;
                    }
                    else
                    {
                        if ((gs.Num + num) != 0)
                        {
                            gs.AC = (gs.AC * gs.Num + num * AC) / (gs.Num + num);
                        }
                        else
                        {
                            gs.AC = AC;
                        }
                    }
                    gs.Num        = gs.Num + num;
                    gs.UpdateTime = DateTime.Now;
                    gs.Save();
                    GoodsStoreDetail gsd = new GoodsStoreDetail();
                    gsd.GoodsId    = goodsId;
                    gsd.Id         = 0;
                    gsd.NewNum     = gs.Num;
                    gsd.Num        = num;
                    gsd.OldNum     = gs.Num - num;
                    gsd.Operate    = t.Status;
                    gsd.RelationId = TransferId;
                    gsd.StoreId    = storeId;
                    gsd.UpdateTime = DateTime.Now;
                    gsd.UserId     = UserId;
                    gsd.Save();
                }
            }
            return(true);
        }