日期:2014-05-19  浏览次数:20860 次

并非所有的代码路径都返回值
public   DateTime   UpdateAndInsert(Guid   OverTimeHeadId,   int   OverTimeStatusId,   Guid   UserId,DateTime   CreateTimeId,Guid   guidId)
        {
                using   (TransactionScope   ts   =   new   TransactionScope())//两个一起执行
                {
                        string   strSql   =   "UPDATE   OverTimeHead   SET   OverTimeStatusId   =   '{1} '   WHERE   (OverTimeHeadId   =   '{0} ') ";

                        new   CommonData().ExeNonQuery(strSql);

                        strSql   =   "INSERT   INTO   OverTimeFlows   (   UserId,   OverTimeStatusId,OverTimeFlowsId,CreateDateTime)   VALUES   ( '{2} ', '{1} ', '{4} ', '{3} ') ";


                        new   CommonData().ExeNonQuery(strSql);

                        ts.Complete();
                }
        }

------解决方案--------------------
你声明的类命是要返回一个DateTime 啊


return ...
------解决方案--------------------
都没有return一个值呢!
------解决方案--------------------
你不要return 什么..干吗构造方法时声明了返回值..去掉..改void不就好了?
------解决方案--------------------
public void UpdateAndInsert(Guid OverTimeHeadId, int OverTimeStatusId, Guid UserId,DateTime CreateTimeId,Guid guidId)
{
using (TransactionScope ts = new TransactionScope())//两个一起执行
{
string strSql = "UPDATE OverTimeHead SET OverTimeStatusId = '{1} ' WHERE (OverTimeHeadId = '{0} ') ";

new CommonData().ExeNonQuery(strSql);

strSql = "INSERT INTO OverTimeFlows ( UserId, OverTimeStatusId,OverTimeFlowsId,CreateDateTime) VALUES ( '{2} ', '{1} ', '{4} ', '{3} ') ";


new CommonData().ExeNonQuery(strSql);

ts.Complete();
}
}
------解决方案--------------------
public DateTime UpdateAndInsert

这个函数要示有返回值 DateTime

这样声明就可以无返回值了:public void UpdateAndInsert