//
充点
public static int ChargePoint( decimal id, String table, decimal point, String ip)
{
decimal oldPoint = 0 ;
SqlConnection con = new SqlConnection(BasePage.GetConnectString());
String strSQL = null ;
con.Open();
SqlTransaction tran = con.BeginTransaction();
try
{
strSQL = String.Format( " select points from {0} where {0}ID={1} " , table, id);
// Debug.Log(strSQL);
oldPoint = (Decimal)SqlHelper.ExecuteScalar(tran, CommandType.Text, strSQL);
strSQL = String.Format( " update {0} set points={1},ip='{2}',time=GETDATE() where {0}ID={3} " , table, oldPoint + point, ip, id);
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, strSQL);
tran.Commit();
return 1 ;
}
catch (Exception ex)
{
tran.Rollback();
return 0 ;
}
finally
{
con.Close();
}
}
public static int ChargePoint( decimal id, String table, decimal point, String ip)
{
decimal oldPoint = 0 ;
SqlConnection con = new SqlConnection(BasePage.GetConnectString());
String strSQL = null ;
con.Open();
SqlTransaction tran = con.BeginTransaction();
try
{
strSQL = String.Format( " select points from {0} where {0}ID={1} " , table, id);
// Debug.Log(strSQL);
oldPoint = (Decimal)SqlHelper.ExecuteScalar(tran, CommandType.Text, strSQL);
strSQL = String.Format( " update {0} set points={1},ip='{2}',time=GETDATE() where {0}ID={3} " , table, oldPoint + point, ip, id);
SqlHelper.ExecuteNonQuery(tran, CommandType.Text, strSQL);
tran.Commit();
return 1 ;
}
catch (Exception ex)
{
tran.Rollback();
return 0 ;
}
finally
{
con.Close();
}
}