コード例 #1
0
        private void btn_calcular_Click(object sender, EventArgs e)
        {
            try
            {
                txb_Letra.Text = "";
                ptb_Mil.Hide();
                ptb_quinientos.Hide();
                ptb_doscientos.Hide();
                ptb_cien.Hide();
                ptb_cincuenta.Hide();
                ptb_veinte.Hide();
                ptb_diez.Hide();
                ptb_cinco.Hide();
                ptb_uno.Hide();

                txb_cantMil.Hide();
                txb_cantQuinientos.Hide();
                txb_cantDoscientos.Hide();
                txb_cantCien.Hide();
                txb_cantCincuenta.Hide();
                txb_cantVeinte.Hide();
                txb_cantDiez.Hide();
                txb_cantCinco.Hide();
                txb_cantUno.Hide();

                x1.Hide();
                x2.Hide();
                x3.Hide();
                x4.Hide();
                x5.Hide();
                x6.Hide();
                x7.Hide();
                x8.Hide();
                x9.Hide();

                mas1.Hide();
                mas2.Hide();
                mas3.Hide();
                mas4.Hide();
                mas5.Hide();
                mas6.Hide();
                mas7.Hide();
                mas8.Hide();

                Ubicacion loc = new Ubicacion();


                if ((Convert.ToInt32(txb_Cantidad.Text)) <= 0)
                {
                    MessageBox.Show("Introdusca numeros mayores de 0");
                    txb_Cantidad.Text = "";
                }
                else
                {
                    Conversion conver = new Conversion();

                    txb_Letra.Text = conver.enletras(txb_Cantidad.Text);
                }


                int N;
                N = Convert.ToInt32(txb_Cantidad.Text);


                int c = 0;
                int Ncantidad;
                int Nmodulo;
                int x = 185;
                int y = 170;

                Ncantidad = N / 1000;
                Nmodulo   = N % 1000;

                if (Ncantidad > 0)
                {
                    ptb_Mil.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_Mil.Show();

                    txb_cantMil.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantMil.Show();

                    x1.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x1.Show();

                    txb_cantMil.Text = Ncantidad.ToString();
                    c++;
                }

                Ncantidad = Nmodulo / 500;
                Nmodulo   = Nmodulo % 500;

                if (Ncantidad > 0)
                {
                    mas1.Location = new Point(loc.EtiqMasX(c), loc.EtiqMasY(c));
                    mas1.Show();

                    x2.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x2.Show();

                    ptb_quinientos.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_quinientos.Show();
                    txb_cantQuinientos.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantQuinientos.Show();
                    txb_cantQuinientos.Text = Ncantidad.ToString();
                    c++;
                }

                Ncantidad = Nmodulo / 200;
                Nmodulo   = Nmodulo % 200;

                if (Ncantidad > 0)
                {
                    mas2.Location = new Point(loc.EtiqMasX(c), loc.EtiqMasY(c));
                    mas2.Show();

                    x3.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x3.Show();

                    ptb_doscientos.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_doscientos.Show();
                    txb_cantDoscientos.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantDoscientos.Show();
                    txb_cantDoscientos.Text = Ncantidad.ToString();
                    c++;
                }

                Ncantidad = Nmodulo / 100;
                Nmodulo   = Nmodulo % 100;

                if (Ncantidad > 0)
                {
                    mas3.Location = new Point(loc.EtiqMasX(c), loc.EtiqMasY(c));
                    mas3.Show();

                    x4.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x4.Show();

                    ptb_cien.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_cien.Show();
                    txb_cantCien.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantCien.Show();
                    txb_cantCien.Text = Ncantidad.ToString();
                    c++;
                }

                Ncantidad = Nmodulo / 50;
                Nmodulo   = Nmodulo % 50;

                if (Ncantidad > 0)
                {
                    mas4.Location = new Point(loc.EtiqMasX(c), loc.EtiqMasY(c));
                    mas4.Show();

                    x5.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x5.Show();

                    ptb_cincuenta.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_cincuenta.Show();
                    txb_cantCincuenta.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantCincuenta.Show();
                    txb_cantCincuenta.Text = Ncantidad.ToString();
                    c++;
                }

                Ncantidad = Nmodulo / 20;
                Nmodulo   = Nmodulo % 20;

                if (Ncantidad > 0)
                {
                    mas5.Location = new Point(loc.EtiqMasX(c), loc.EtiqMasY(c));
                    mas5.Show();

                    x6.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x6.Show();

                    ptb_veinte.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_veinte.Show();
                    txb_cantVeinte.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantVeinte.Show();
                    txb_cantVeinte.Text = Ncantidad.ToString();
                    c++;
                }

                Ncantidad = Nmodulo / 10;
                Nmodulo   = Nmodulo % 10;

                if (Ncantidad > 0)
                {
                    mas6.Location = new Point(loc.EtiqMasX(c), loc.EtiqMasY(c));
                    mas6.Show();

                    x7.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x7.Show();

                    ptb_diez.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_diez.Show();
                    txb_cantDiez.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantDiez.Show();
                    txb_cantDiez.Text = Ncantidad.ToString();
                    c++;
                }

                Ncantidad = Nmodulo / 5;
                Nmodulo   = Nmodulo % 5;

                if (Ncantidad > 0)
                {
                    mas7.Show();
                    mas7.Location = new Point(loc.EtiqMasX(c), loc.EtiqMasY(c));

                    x8.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x8.Show();

                    ptb_cinco.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_cinco.Show();
                    txb_cantCinco.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantCinco.Show();
                    txb_cantCinco.Text = Ncantidad.ToString();
                    c++;
                }
                Ncantidad = Nmodulo / 1;
                Nmodulo   = Nmodulo % 1;

                if (Ncantidad > 0)
                {
                    mas8.Show();
                    mas8.Location = new Point(loc.EtiqMasX(c), loc.EtiqMasY(c));

                    x9.Location = new Point(loc.EtiqPorX(c), loc.EtiqPorY(c));
                    x9.Show();

                    ptb_uno.Location = new Point(loc.DineroX(c), loc.DineroY(c));
                    ptb_uno.Show();
                    txb_cantUno.Location = new Point(loc.CajaCantX(c), loc.CajaCantY(c));
                    txb_cantUno.Show();
                    txb_cantUno.Text = Ncantidad.ToString();
                    c++;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Introdusca el numero en su formato numerico.");
            }
        }