Example #1
0
        private void button1_Click(object sender, EventArgs e)//получаем информацию о валютах
        {
            RBKServise.DailyInfo di = new RBKServise.DailyInfo();

            System.DateTime DateFrom, DateTo;
            DateFrom = dateTimePicker1.Value;
            DateTo   = dateTimePicker2.Value;

            DataSet ds = (System.Data.DataSet)di.GetCursDynamic(DateFrom, DateTo, "R01235");

            ds.Tables[0].Columns[0].ColumnName = "Дата";
            ds.Tables[0].Columns[1].ColumnName = "Вн.код валюты";
            ds.Tables[0].Columns[2].ColumnName = "Номинал";
            ds.Tables[0].Columns[3].ColumnName = "Курс";



            dataGridView1.DataSource = ds.Tables[0];



            DataSet DSC = (System.Data.DataSet)di.EnumValutes(false);

            System.Data.DataTable tb1 = DSC.Tables["EnumValutes"];

            dataGridView2.DataSource = tb1;

            label4.Text = dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[3].Value.ToString();
        }
Example #2
0
        static List <Decimal> GetValutesList(RBKServise.DailyInfo info, String currencySystemCode, DateTime fromDate, DateTime toDate)
        {
            var dataSet = info.GetCursDynamic(fromDate, toDate, currencySystemCode);

            List <Decimal> valutesList = new List <decimal>();

            for (int i = 0; i < dataSet.Tables.Count; i++)
            {
                DataTable thisTable = dataSet.Tables[i];

                for (int j = 0; j < thisTable.Rows.Count; j++)
                {
                    DataRow row = thisTable.Rows[j];

                    valutesList.Add(Decimal.Parse(row[3].ToString()));
                }
            }

            return(valutesList);
        }
Example #3
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Enter the currency code (for example, usd, eur): ");
                String currencyCode = Console.ReadLine();

                var info = new RBKServise.DailyInfo();

                String currencySystemCode = "";
                String currencyName       = "";

                foreach (DataRow i in GetValutesTable(info))
                {
                    if (i.ItemArray[6].ToString().ToUpper() == currencyCode.ToString().ToUpper())
                    {
                        currencySystemCode = i.ItemArray[0].ToString().Trim();
                        currencyName       = i.ItemArray[1].ToString().Trim();

                        break;
                    }
                }


                if (String.IsNullOrEmpty(currencySystemCode))
                {
                    throw new ArgumentException();
                }


                var latestDateTime = info.GetLatestDateTime();

                var row = info.GetCursDynamic(latestDateTime, latestDateTime.AddDays(1), currencySystemCode).Tables[0].Rows[0];

                Console.WriteLine("{0} {1} равно {2} российских рублей", row[2], currencyName, row[3]);

                var row2 = row[3].ToString().Split(new char[] { ',', '.' });

                var morpher = new Morpher.WebService();
                morpher.CredentialsValue = new Morpher.Credentials()
                {
                    Username = Const.userName, Password = Const.password
                };

                Console.WriteLine("Status: {0}", morpher.GetAccountStatus());
                Console.WriteLine();

                var currency = morpher.Propis(UInt32.Parse(row[2].ToString()), currencyName.ToLower());
                var ruble    = morpher.Propis(UInt32.Parse(row2[0]), "рубль");
                var kopeck   = morpher.Propis(UInt32.Parse(row2[1]), "копейка");

                Console.WriteLine("{0} {1} {2} {3} равны {4} {5}", ruble.n.И, ruble.unit.И, kopeck.n.И, kopeck.unit.И, currency.n.Д, currency.unit.Д);
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Can't find this valute!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e);
            }
        }