Exemple #1
0
        private void InfoForm_Load(object sender, EventArgs e)
        {
            try {
                using (var objProvider = new BankProvider()) {
                    List <Bank> objBanks = objProvider.GetAllBanks();
                    comboBox1.Items.AddRange(objBanks.ToArray());

                    CurrencyExchanger objExchanger = objProvider.GetExchangerById(iExchangerId);
                    comboBox1.SelectedIndex = comboBox1.Items.IndexOf(objExchanger.Bank);
                    textBox1.Text           = objExchanger.X.ToString();
                    textBox2.Text           = objExchanger.Y.ToString();
                    textBox3.Text           = objExchanger.Phone;
                    textBox4.Text           = objExchanger.Address;
                    textBox6.Text           = objExchanger.WorkTime;
                    textBox5.Text           = objExchanger.OpenDate.ToString();
                    if (objExchanger.Number != null)
                    {
                        numericUpDown1.Value = (decimal)objExchanger.Number;
                    }

                    //usd
                    label14.Text = objProvider.GetRateByBank("USD", objExchanger.Bank).Buy.ToString();
                    label15.Text = objProvider.GetRateByBank("USD", objExchanger.Bank).Sale.ToString();
                    //eur
                    label16.Text = objProvider.GetRateByBank("EUR", objExchanger.Bank).Buy.ToString();
                    label17.Text = objProvider.GetRateByBank("EUR", objExchanger.Bank).Sale.ToString();
                    //rur
                    label18.Text = objProvider.GetRateByBank("RUR", objExchanger.Bank).Buy.ToString();
                    label19.Text = objProvider.GetRateByBank("RUR", objExchanger.Bank).Sale.ToString();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
 /// <summary>
 /// filter exchangers by bank
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
 {
     try {
         DrawMarkers();
         using (var objProvider = new BankProvider()) {
             Bank objBank = objProvider.GetBankByName(comboBox2.SelectedItem.ToString());
             if (objBank == null)
             {
                 DrawMarkers();
             }
             else
             {
                 for (int iI = 0; iI < objMarkersOverlay.Markers.Count; ++iI)
                 {
                     var exchanger = objProvider.GetExchangerById((int)objMarkersOverlay.Markers[iI].Tag);
                     if (exchanger.Bank.Id != objBank.Id)
                     {
                         objMarkersOverlay.Markers.RemoveAt(iI);
                         --iI;
                     }
                 }
             }
         }
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try {
                using (var objProvider = new BankProvider()) {
                    Bank objBank = objProvider.GetBankByName(((Bank)comboBox1.Items[comboBox1.SelectedIndex]).Name);
                    CurrencyExchanger objExchanger = objProvider.GetExchangerById(iExchangerId);

                    objExchanger.Bank     = objBank;
                    objExchanger.Address  = textBox4.Text;
                    objExchanger.Number   = (int)numericUpDown1.Value;
                    objExchanger.Phone    = textBox3.Text;
                    objExchanger.WorkTime = textBox6.Text;
                    objExchanger.X        = Convert.ToDouble(textBox1.Text);
                    objExchanger.Y        = Convert.ToDouble(textBox2.Text);
                }
                Close();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #4
0
        /// <summary>
        /// update marker info
        /// </summary>
        private void UpdateMarkers()
        {
            try {
                using (var objProvider = new BankProvider()) {
                    foreach (var marker in objMarkersOverlay.Markers)
                    {
                        CurrencyExchanger objExchanger = objProvider.GetExchangerById((int)marker.Tag);

                        ExchangeRate objUsd = objProvider.GetRateByBank("USD", objExchanger.Bank);
                        ExchangeRate objEur = objProvider.GetRateByBank("EUR", objExchanger.Bank);
                        ExchangeRate objRur = objProvider.GetRateByBank("RUR", objExchanger.Bank);

                        marker.ToolTipText = String.Format(
                            "{0} office:{1}\nBuy\n" +
                            "USD:{2}\nEUR:{3}\nRUR:{4}\n" +
                            "Sell\n" +
                            "USD:{5}\nEUR:{6}\nRUR:{7}",
                            objExchanger.Bank.Name,
                            objExchanger.Number,
                            objUsd.Buy,
                            objEur.Buy,
                            objRur.Buy,
                            objUsd.Sale,
                            objEur.Sale,
                            objRur.Sale
                            );

                        var objPositon = new PointLatLng(objExchanger.X, objExchanger.Y);
                        if (marker.Position != objPositon)
                        {
                            marker.Position = objPositon;
                        }
                        gMapControl1.UpdateMarkerLocalPosition(marker);
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #5
0
        /// <summary>
        /// find nearest exhanger from current mouse position
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void findNearestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PointLatLng objPosition = GetCursorPosition();

            using (var objProvider = new BankProvider()) {
                List <CurrencyExchanger> objExchangers = new List <CurrencyExchanger>();
                foreach (var marker in objMarkersOverlay.Markers)
                {
                    CurrencyExchanger exchanger = objProvider.GetExchangerById((int)marker.Tag);
                    if (exchanger != null)
                    {
                        objExchangers.Add(exchanger);
                    }
                }
                CurrencyExchanger objNearestExchanger = objProvider.GetNearestExchanger(objPosition.Lat, objPosition.Lng, objExchangers);

                var objMarker = new GMarkerGoogle(new PointLatLng(objNearestExchanger.X, objNearestExchanger.Y), GMarkerGoogleType.blue);
                objMarker.Tag = objNearestExchanger.Id;
                gMapControl1.UpdateMarkerLocalPosition(objMarker);
                var markersOverlay = new GMapOverlay();
                markersOverlay.Markers.Add(objMarker);
                gMapControl1.Overlays.Add(markersOverlay);
            }
        }