Exemplo n.º 1
0
        public bool UpdateSaleReturnDetail(MMS_SaleReturnDetail saleRetDet)
        {
            var query = from item in dc.MMS_SaleReturnContent
                        where item.ID == saleRetDet.ID
                        select item;

            BatchEvaluate.Eval(saleRetDet, query.First());
            dc.SubmitChanges();
            return(true);
        }
Exemplo n.º 2
0
 public bool AuditSaleReturn(int id, bool isAudit, string operatorCode)
 {
     using (TransactionScope ts = new TransactionScope()) //开启DTC事务
     {
         TSaleReturn           tsale   = dao.GetSaleReturn(id);
         MMS_SaleReturnContent content = tsale.Content;
         if (content.AuditFlag == true) //??存在缓存
         {
             throw new Exception("该单据已经审核" + content.SaleBillCode);
         }
         foreach (TSaleReturnDetail tSaleDetail in tsale.Detail)
         {
             MMS_Store storeParam = new MMS_Store();
             storeParam.Warehouse   = content.WareHouse;
             storeParam.ProductCode = tSaleDetail.DetDetail.ProductCode;
             MMS_Store sto = null;
             sto = daoStore.GetStore(storeParam);
             if (sto == null) //库存中没有该商品
             {
                 sto             = new MMS_Store();
                 sto.Warehouse   = tsale.Content.WareHouse;
                 sto.ProductCode = tSaleDetail.DetDetail.ProductCode;
                 sto.Quantity    = tSaleDetail.DetDetail.Quantity;
                 sto.Price       = tSaleDetail.DetDetail.Price;
                 sto.Amount      = sto.Quantity * sto.Price;
                 sto.Memo        = "";
                 daoStore.InsertInfo(sto);
             }
             else
             {
                 sto.Quantity += tSaleDetail.DetDetail.Quantity;
                 sto.Amount   += tSaleDetail.DetDetail.Quantity * sto.Price; //* tSaleDetail.DetDetail.Price;
                 if (sto.Quantity > 0)
                 {
                     sto.Price = sto.Amount / sto.Quantity;
                 }
                 daoStore.UpdateInfo(sto);
             }
             //更新销售退回成本价
             MMS_SaleReturnDetail saleRetDet = tSaleDetail.DetDetail;
             saleRetDet.Cost = sto.Price;
             dao.UpdateSaleReturnDetail(saleRetDet);
         }
         content.AuditFlag   = isAudit;
         content.Operator    = operatorCode;
         content.OperateDate = DateTime.Now;
         dao.UpdateInfo(content);
         ts.Complete();
     }
     return(true);
 }