Exemple #1
0
 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);
 }
Exemple #2
0
 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);
 }