/// <summary>
        /// Entry point for Decoding Bar Code.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConvert_Click(object sender, EventArgs e)
        {
            switch (actionType)
            {
            //Encode Zip Code to Bar Code
            case EnumActionType.EncodeZipCode:
                if (txtBoxInput.Text.Length != 10)
                {
                    showErrorMessage(EnumErrorType.InvalidZipCodeInput);
                }
                else
                {
                    String barCode = BarCodeManager.encodeZipCode(txtBoxInput.Text);
                    txtBoxOutput.Text = barCode;
                }
                break;

            //Decode Bar Code to Zip Code
            case EnumActionType.DecodeBarCode:
                if (txtBoxInput.Text.Length != 52)
                {
                    showErrorMessage(EnumErrorType.InvalidBarCodeInput);
                }
                else
                {
                    String     zipCode = "";
                    EnumStatus status  = BarCodeManager.decodeBarCode(txtBoxInput.Text, out zipCode);
                    if (status == EnumStatus.Success)
                    {
                        string sVal  = zipCode;
                        string newst = Regex.Replace(sVal, ".{5}", "$0-");
                        txtBoxOutput.Text           = newst;
                        txtBoxOutput.SelectionStart = txtBoxOutput.Text.Length;
                    }
                    else
                    {
                        showErrorMessage((EnumErrorType)Enum.Parse(typeof(EnumErrorType), status.ToString()));
                    }
                }
                break;
            }
        }
Example #2
0
 public BarCodeTests()
 {
     _manager = new BarCodeManager();
 }
Example #3
0
 public BarCodeController(AppContext dbContext, BarCodeManager barcodeManager, ItemManager itemManager)
 {
     _context        = dbContext;
     _barcodeManager = barcodeManager;
     _itemManager    = itemManager;
 }