C# 代码如下 using (MySql.Data.MySqlClient.MySqlTransaction _tran = _tranutil.GetMySqlTransaction())
{
try
{
//更新主表确认标记与日期
_sql = String.Format("update A6004 set Stu1 = 'Y', Stu1Date = '{0}' where BillID = '{1}' and Stu1 = 'N'", DateTime.Now.ToString("yyyy-MM-dd HH:mm"), BillID.Trim().ToUpper()); _result = _other.ExecSQLQueryInt(_sql, _tran); //_result 返因 1 影响记录数为 1 正确 if (_result <= 0)
{
_tran.Rollback();
return false;
} //更新库存数量
_sql = String.Format("Update A6001, A6005, A6004 set A6001.Qty1 = A6001.Qty1 - A6005.Qty1 where A6004.BillID = '{0}' and A6004.BillID = A6005.BillID and A6005.ProcBarcode = A6001.ProcBarcode", BillID.Trim().ToUpper()); _result = _other.ExecSQLQueryInt(_sql, _tran); //_result 返回 1 影响记录数为 1 正确 if (_result <= 0)
{
_tran.Rollback();
return false;
} //检查是否有负库存,有则表示不够库存发发货
_sql = String.Format("select A6001.ProcBarcode from A6001, A6004, A6005 where A6004.BillID = '{0}' and A6004.BillID = A6005.BillID and A6005.ProcBarcode = A6001.ProcBarcode and A6001.Qty1 < 0", BillID.Trim().ToUpper()); _result = _other.ExecSQLQueryInt(_sql, _tran); //注意: 这就是问题所在 正确返回应是 0 但是现时返回值是 -1, SQL语句是正确 //测试 将条件 A6001.Qty1 < 0 修改为 A6001.Qty > 1 返回值一样是 -1。
//_sql = String.Format("select A6001.ProcBarcode from A6001, A6004, A6005 where A6004.BillID = '{0}' and A6004.BillID = A6005.BillID and A6005.ProcBarcode = A6001.ProcBarcode and A6001.Qty1 > 0", BillID.Trim().ToUpper()); if ((_result < 0 ) || (_result > 0))
{
_tran.Rollback();
return false;
}
}
catch
{
_tran.Rollback();
return false;
} _tran.Commit();
}
} 不知那位高手明白这是什么原因
{
try
{
//更新主表确认标记与日期
_sql = String.Format("update A6004 set Stu1 = 'Y', Stu1Date = '{0}' where BillID = '{1}' and Stu1 = 'N'", DateTime.Now.ToString("yyyy-MM-dd HH:mm"), BillID.Trim().ToUpper()); _result = _other.ExecSQLQueryInt(_sql, _tran); //_result 返因 1 影响记录数为 1 正确 if (_result <= 0)
{
_tran.Rollback();
return false;
} //更新库存数量
_sql = String.Format("Update A6001, A6005, A6004 set A6001.Qty1 = A6001.Qty1 - A6005.Qty1 where A6004.BillID = '{0}' and A6004.BillID = A6005.BillID and A6005.ProcBarcode = A6001.ProcBarcode", BillID.Trim().ToUpper()); _result = _other.ExecSQLQueryInt(_sql, _tran); //_result 返回 1 影响记录数为 1 正确 if (_result <= 0)
{
_tran.Rollback();
return false;
} //检查是否有负库存,有则表示不够库存发发货
_sql = String.Format("select A6001.ProcBarcode from A6001, A6004, A6005 where A6004.BillID = '{0}' and A6004.BillID = A6005.BillID and A6005.ProcBarcode = A6001.ProcBarcode and A6001.Qty1 < 0", BillID.Trim().ToUpper()); _result = _other.ExecSQLQueryInt(_sql, _tran); //注意: 这就是问题所在 正确返回应是 0 但是现时返回值是 -1, SQL语句是正确 //测试 将条件 A6001.Qty1 < 0 修改为 A6001.Qty > 1 返回值一样是 -1。
//_sql = String.Format("select A6001.ProcBarcode from A6001, A6004, A6005 where A6004.BillID = '{0}' and A6004.BillID = A6005.BillID and A6005.ProcBarcode = A6001.ProcBarcode and A6001.Qty1 > 0", BillID.Trim().ToUpper()); if ((_result < 0 ) || (_result > 0))
{
_tran.Rollback();
return false;
}
}
catch
{
_tran.Rollback();
return false;
} _tran.Commit();
}
} 不知那位高手明白这是什么原因
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货