Ejemplo n.º 1
0
        public int InsertInfo(MMS_PurchaseReturnContent info)
        {
            string msg = dao.ValidateRepeat(info);

            if (msg == "")
            {
                return(dao.InsertInfo(info));
            }
            else
            {
                throw new Exception(msg);
            }
        }
Ejemplo n.º 2
0
 public bool AuditPurchaseReturn(int id, bool isAudit, string operatorCode)
 {
     using (TransactionScope ts = new TransactionScope()) //开启DTC事务
     {
         TPurchaseReturn           tPur    = dao.GetPurchaseReturn(id);
         MMS_PurchaseReturnContent content = tPur.Content;
         if (content.AuditFlag == true)
         {
             throw new Exception("该单据已经审核" + content.PurchaseBillCode);
         }
         foreach (TPurchaseReturnDetail tPurDetail in tPur.Detail)
         {
             MMS_Store storeParam = new MMS_Store();
             storeParam.Warehouse   = tPur.Content.WareHouse;
             storeParam.ProductCode = tPurDetail.DetDetail.ProductCode;
             MMS_Store sto = null;
             sto = daoStore.GetStore(storeParam);
             if (sto == null) //库存中没有该商品
             {
                 throw new Exception("库存中没有该商品,不能退货" + tPurDetail.DetDetail.ProductCode);
             }
             else
             {
                 if (tPurDetail.DetDetail.Quantity > sto.Quantity)
                 {
                     throw new Exception("库存数据不足,不能退货" + tPurDetail.DetDetail.ProductCode);
                 }
                 sto.Quantity -= tPurDetail.DetDetail.Quantity;
                 sto.Amount   -= tPurDetail.DetDetail.Quantity * tPurDetail.DetDetail.Price;
                 if (sto.Quantity > 0)
                 {
                     sto.Price = sto.Amount / sto.Quantity;
                 }
                 daoStore.UpdateInfo(sto);
             }
         }
         content.AuditFlag   = isAudit;
         content.Operator    = operatorCode;
         content.OperateDate = DateTime.Now;
         dao.UpdateInfo(content);
         ts.Complete();
     }
     return(true);
 }
Ejemplo n.º 3
0
 public bool UpdateInfo(MMS_PurchaseReturnContent info)
 {
     return(dao.UpdateInfo(info));
 }
Ejemplo n.º 4
0
 public int InsertInfo(MMS_PurchaseReturnContent info)
 {
     dc.MMS_PurchaseReturnContent.InsertOnSubmit(info);
     dc.SubmitChanges();
     return(info.ID);
 }