示例#1
0
        protected void _onSolveClick(object sender, EventArgs e)
        {
            string      baseFrom     = insertBaseFrom.Text;
            string      numToConvert = insertNumber.Text;
            string      baseTo       = insertBaseTo.Text;
            CalculateIt calc         = new CalculateIt();

            calc.PassReq(numToConvert, baseFrom, baseTo);
        }
示例#2
0
        /// <summary>
        /// checks to see if parameter are entered and they are of the right values.
        /// </summary>
        /// <param name="numConvert">number to convert</param>
        /// <param name="baseFrom">the present base of number to convert</param>
        /// <param name="baseTo">base you want to convert to</param>
        public void PassReq(string numConvert, string baseFrom, string baseTo)
        {
            Flag       = 0;
            numConvert = numConvert.Trim();
            baseFrom   = baseFrom.Trim();
            baseTo     = baseTo.Trim();
            string logger = "";

            if (IsEmpty(numConvert))
            {
                MessageBox.Show("Number to convert box is empty. Fill it!", "Error");
                Flag++;
            }
            else
            {
                if (CheckBases(baseFrom, baseTo))
                {
                    if (Flag == 1)
                    {
                        //MessageBox.Show( "TRy aGaIn!! \n\n" +
                        //  "Please enter a valid number to Convert" );
                        Flag = 0;
                        //ConversionGui restart = new ConversionGui( true );
                        //restart.Restart();
                    }
                    else
                    {
                        numConvert = numConvert.ToUpper();

                        //additional error checking. Don't need now

                        /*
                         * for( char a = 'G'; a <= 'Z'; a++ )
                         * {
                         *      for( int i = 0; i < numConvert.Length; i++ )
                         *      {
                         *              if( numConvert[i] == a )
                         *              {
                         *                      Flag++;
                         *                      MessageBox.Show( a + " cannot be entered \n\n It is an invalid character.", "Error" );
                         *                      logger = "errorfound";
                         *              }
                         *      }
                         * } */

                        //checks to make sure all characters in the number entered are supported
                        for (int i = 0; i < numConvert.Length; i++)
                        {
                            if (!IsInteger(numConvert[i].ToString()))
                            {
                                if (!IsValidChar(numConvert[i]))
                                {
                                    Flag++;
                                    MessageBox.Show(numConvert + " cannot be entered.\n\nIt has an invalid character.\n\nEnter the" +
                                                    " the appropriate number, please", "Error");
                                    logger = "errorfound";
                                }
                            }
                        }
                        if (logger == "")
                        {
                            CalculateIt convert = new CalculateIt(numConvert, baseFrom, baseTo);
                        }
                    }
                }
            }
        }