public static CsString UpdateSql(string TableName) { CsString newStr = new CsString("UPDATE " + TableName + " SET "); return(newStr); }
public static bool AddSorce(int UserId, int Sroce, AppleReturnData _AppleReturnData, out int _ReturnSoce) { _ReturnSoce = 0; string MyConn = System.Configuration.ConfigurationManager.AppSettings["DBTreasure"]; // string MyConn = "server=103.105.58.140;uid=testdb;pwd=123abc;database=RYTreasureDB;Trusted_Connection=no"; SqlConnection MyConnection = new SqlConnection(MyConn); try { MyConnection.Open(); { string selStr = "select transaction_id from ReturnAppDetailInfo where transaction_id=" + _AppleReturnData.receipt.in_app[0].transaction_id; SqlCommand MyCommand = new SqlCommand(selStr, MyConnection); SqlDataReader _Reader = MyCommand.ExecuteReader(); if (_Reader.HasRows) { _Reader.Close(); return(false); } _Reader.Close(); } { string col = @" UserID, OrderID, PayAmount, Status, quantity, product_id, transaction_id, purchase_date, original_transaction_id, original_purchase_date, app_item_id, version_external_identifier, bid, bvrs"; CsString _Value = new CsString(""); _Value.Fill(UserId); _Value.Fill(_AppleReturnData.receipt.download_id); _Value.Fill(Sroce); _Value.Fill("0"); _Value.Fill(1); _Value.Fill(_AppleReturnData.receipt.in_app[0].product_id); _Value.Fill(_AppleReturnData.receipt.in_app[0].transaction_id); _Value.Fill(_AppleReturnData.receipt.in_app[0].purchase_date); _Value.Fill(_AppleReturnData.receipt.in_app[0].original_transaction_id); _Value.Fill(_AppleReturnData.receipt.in_app[0].original_purchase_date); _Value.Fill(_AppleReturnData.receipt.app_item_id); _Value.Fill(_AppleReturnData.receipt.version_external_identifier); _Value.Fill(_AppleReturnData.receipt.bundle_id); _Value.FillEx(123); CsString str = CsString.InstertSql("ReturnAppDetailInfo", col, _Value.ToString()); SqlCommand MyCommand = new SqlCommand(str.ToString(), MyConnection); MyCommand.ExecuteNonQuery(); } { string MyUpdate = "Update GameScoreInfo set Score=Score+" + Sroce.ToString() + " where UserID=" + UserId; SqlCommand MyCommand = new SqlCommand(MyUpdate, MyConnection); MyCommand.ExecuteNonQuery(); } { string selStr = "select Score from GameScoreInfo where UserID=" + UserId; SqlCommand MyCommand = new SqlCommand(selStr, MyConnection); SqlDataReader _Reader = MyCommand.ExecuteReader(); if (_Reader.Read()) { _ReturnSoce = (int)_Reader.GetInt64(0); _Reader.Close(); return(true); } _Reader.Close(); } MyConnection.Close(); return(true); } catch (Exception ex) { Console.WriteLine("{0} Exception caught.", ex); } return(false); }
public static CsString InstertSql(string TableName, string colum, string _value) { CsString newStr = new CsString("INSERT INTO " + TableName + " (" + colum + ") " + "VALUES(" + _value + ")"); return(newStr); }