コード例 #1
0
ファイル: SimpleSwap.cs プロジェクト: beducode/DiceBot-1
 bool GetQuote()
 {
     try
     {
         using (var response = Client.GetStringAsync("quote/" + cbFrom.Items[cbFrom.SelectedIndex].ToString() + "-" + cbTo.Items[cbTo.SelectedIndex].ToString() + "/" + nudSending.Value))
         {
             string responseData = response.Result;
             SSRate Rate         = json.JsonDeserialize <SSRate>(responseData);
             if (!Rate.status)
             {
                 MessageBox.Show("Failed to get quote! Please try again in a few minutes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 txtRate.Text = Rate.rate;
                 decimal amount = decimal.Parse(Rate.rate, System.Globalization.NumberFormatInfo.InvariantInfo) * (decimal)nudSending.Value;
                 txtReveice.Text = amount.ToString();
                 return(true);
             }
         }
     }
     catch
     {
         MessageBox.Show("Failed to get quote! Please try again in a few minutes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     return(false);
 }
コード例 #2
0
ファイル: SimpleSwap.cs プロジェクト: beducode/DiceBot-1
 bool GetRates()
 {
     try
     {
         using (var response = Client.GetStringAsync("rate/" + cbFrom.Items[cbFrom.SelectedIndex].ToString() + "-" + cbTo.Items[cbTo.SelectedIndex].ToString()))
         {
             string responseData = response.Result;
             SSRate Rate         = json.JsonDeserialize <SSRate>(responseData);
             if (!Rate.status)
             {
                 MessageBox.Show("Failed to get rates! Please try again in a few minutes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 txtRate.Text = Rate.rate;
                 return(true);
             }
         }
     }
     catch
     {
         MessageBox.Show("Failed to get rates! Please try again in a few minutes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     return(false);
 }