Пример #1
0
        public Sertar CreateMDLValute()
        {
            Sertar valuteMDL = new Sertar();

            valuteMDL.NumCode  = 498;
            valuteMDL.CharCode = "MDL";
            valuteMDL.Nominal  = 1;
            valuteMDL.Name     = "Leu Moldovenesc";
            valuteMDL.Value    = 1.000m;

            return(valuteMDL);
        }
Пример #2
0
        public Sertar GetTargetValute()
        {
            var toValute = new Sertar();

            foreach (var valute in dulap.Sertare)
            {
                if (valute.CharCode == boxTo.SelectedItem.ToString())
                {
                    toValute = valute;
                }
            }
            return(toValute);
        }
Пример #3
0
        public Sertar GetSourceValute()
        {
            var fromValute = new Sertar();

            foreach (var valute in dulap.Sertare)
            {
                if (valute.CharCode == boxFrom.SelectedItem.ToString())
                {
                    fromValute = valute;
                }
            }
            // fromValute = dulap.Sertare[boxFrom.SelectedIndex];
            return(fromValute);
        }
Пример #4
0
        public decimal Convert(Sertar srcValute, Sertar targetValute)
        {
            decimal sumToConvert = decimal.Parse(txtFrom.Text);
            decimal mdlSum       = (sumToConvert * srcValute.Value) / srcValute.Nominal;
            decimal convertedSum;

            if ((boxFrom.SelectedItem.ToString() != "MDL") && ((boxTo.SelectedItem.ToString() != "MDL")))
            {
                convertedSum = (mdlSum * targetValute.Nominal) / targetValute.Value;
            }
            else if (boxFrom.SelectedItem.ToString() != "MDL")
            {
                convertedSum = mdlSum;
            }
            else
            {
                convertedSum = (sumToConvert * targetValute.Nominal) / targetValute.Value;
            }
            txtTo.Text = convertedSum.ToString("N4");
            return(convertedSum);
        }