首页上一页 1  下一页尾页 1 条记录 1/1页
        请教:我在学习调试《实战突击:ASP.NET项目开发案例整合》第21章企业级通用进销存软件 入库单确认时出现错误信息
                 	
                        发表在ASP.NET图书答疑
                        2012-03-05                                                
                    		
                                                                            	
                        
                        
                    
                    
                    	是否精华
                    	是
                    	否
                    
                    
                    
                            版块置顶:
                            是
                            否
                        
                    
                                           public bool AuditPurchase(int id, bool isAudit, string operatorCode)
{
using (TransactionScope ts = new TransactionScope())//开启DTC事务
{
TPurchase tPur = dao.GetPurchase(id); //取入库单组合实体
PurchaseContent content = tPur.Content; //取入库单主内容实体
if (content.AuditFlag == true) //如果入库单已审核
{
throw new Exception("该单据已经审核" + content.PurchaseBillCode);
}
foreach (TPurchaseDetail tPurDetail in tPur.Detail) //遍历入库单货品
{
Store storeParam = new Store();
storeParam.Warehouse = tPur.Content.WareHouse;
storeParam.ProductCode = tPurDetail.DetDetail.ProductCode;
Store sto = null;
//根据仓库、货品代码取库存表中该货品信息
sto = daoStore.GetStore(storeParam);
if (sto == null)//库存中没有该货品
{
sto = new Store(); //创建库存表实例
sto.Warehouse = tPur.Content.WareHouse;
sto.ProductCode = tPurDetail.DetDetail.ProductCode;
sto.Quantity = tPurDetail.DetDetail.Quantity;
sto.Price = tPurDetail.DetDetail.Price;
sto.Amount = sto.Quantity * sto.Price;
daoStore.InsertInfo(sto); //将该货品信息插入到库存表
sto.Memo = "";
}
else //库存中有该货品
{
sto.Quantity += tPurDetail.DetDetail.Quantity; //累加货品数量
//累加计算货品金额
sto.Amount += tPurDetail.DetDetail.Quantity * tPurDetail.DetDetail.Price;
if (sto.Quantity >0)
sto.Price = sto.Amount / sto.Quantity; //根据金额、数量计算单价
[font color=#FF0000]daoStore.UpdateInfo(sto); //更新库存表
[/font] }
}
content.AuditFlag = isAudit; //入库审核标志
content.Operator = operatorCode;
content.OperateDate = DateTime.Now;
dao.UpdateInfo(content); //更新入库单的审核标志
ts.Complete(); //提交事务
}
return true;
}
运行到“更新库存表”一行出错, 错误信息"没为当前数据上下文实例启用对象跟踪。"
运行的源代码我未修改,前面的功能菜单全部通过,就是试“入库单确认”卡住,试了两个星期,找了一些资料,调整了系统设置,还是通不过,出现几种错误信息(请看附件),是不是系统一些其他设置有问题?
        
                
        	
        
        
    {
using (TransactionScope ts = new TransactionScope())//开启DTC事务
{
TPurchase tPur = dao.GetPurchase(id); //取入库单组合实体
PurchaseContent content = tPur.Content; //取入库单主内容实体
if (content.AuditFlag == true) //如果入库单已审核
{
throw new Exception("该单据已经审核" + content.PurchaseBillCode);
}
foreach (TPurchaseDetail tPurDetail in tPur.Detail) //遍历入库单货品
{
Store storeParam = new Store();
storeParam.Warehouse = tPur.Content.WareHouse;
storeParam.ProductCode = tPurDetail.DetDetail.ProductCode;
Store sto = null;
//根据仓库、货品代码取库存表中该货品信息
sto = daoStore.GetStore(storeParam);
if (sto == null)//库存中没有该货品
{
sto = new Store(); //创建库存表实例
sto.Warehouse = tPur.Content.WareHouse;
sto.ProductCode = tPurDetail.DetDetail.ProductCode;
sto.Quantity = tPurDetail.DetDetail.Quantity;
sto.Price = tPurDetail.DetDetail.Price;
sto.Amount = sto.Quantity * sto.Price;
daoStore.InsertInfo(sto); //将该货品信息插入到库存表
sto.Memo = "";
}
else //库存中有该货品
{
sto.Quantity += tPurDetail.DetDetail.Quantity; //累加货品数量
//累加计算货品金额
sto.Amount += tPurDetail.DetDetail.Quantity * tPurDetail.DetDetail.Price;
if (sto.Quantity >0)
sto.Price = sto.Amount / sto.Quantity; //根据金额、数量计算单价
[font color=#FF0000]daoStore.UpdateInfo(sto); //更新库存表
[/font] }
}
content.AuditFlag = isAudit; //入库审核标志
content.Operator = operatorCode;
content.OperateDate = DateTime.Now;
dao.UpdateInfo(content); //更新入库单的审核标志
ts.Complete(); //提交事务
}
return true;
}
运行到“更新库存表”一行出错, 错误信息"没为当前数据上下文实例启用对象跟踪。"
运行的源代码我未修改,前面的功能菜单全部通过,就是试“入库单确认”卡住,试了两个星期,找了一些资料,调整了系统设置,还是通不过,出现几种错误信息(请看附件),是不是系统一些其他设置有问题?

 
	
                                                 VIP会员
VIP会员 购物车
购物车

 私信
                         私信 
                     发表新帖
发表新帖 立即签到
立即签到 
        		  
        		 
         		 关注
关注
                  回复
 回复 支持(
                	支持( 反对(
                    反对( 
                







 
                     
                     
					 
						 
						 
						 
						