Exemple #1
0
        // we'll have a special case for display...
        /// <summary>
        /// determine the padding when interfacing with the USER INTERFACE elements.
        /// </summary>
        /// <param name="field"></param>
        /// <param name="value"></param>
        /// <param name="display"></param>
        /// <returns></returns>
        public static string padding_router(string field, string value, bool display = false)
        {
            string ot = "";

            // look for this getting triggered when trying to save the output.
            if (field.Contains("Amount") && value.Contains("."))
            {
                string dl = "";
                string cn = "";
                if (value.Contains("."))
                {
                    var a = value.Split('.');
                    cn = a[1];
                    dl = a[0];
                }
                if (dl.Contains("$"))
                {
                    dl = dl.Replace('$', '0'); // we'll simply replace the dollar signs with a zero- though it should get stripped in most cases.
                }
                value = dl + cn;               // I forgot to recombine this in the initial run. now it should be good to go.
                ot    = value;                 // this will be reset now.
#if DEBUG
                Console.WriteLine(ot);
#endif
            }

            switch (field)
            {
            case "E. Rec Type":
                goto case "APPEND_PAD_ZERO";
#if UPDATE_20190807
                    #else
                break;
                    #endif
            case "Trans. Code":
                goto  case "APPEND_PAD_ZERO";
#if UPDATE_20190807
#else
                break;
#endif
            case "Routing Num":
                goto case "APPEND_PAD_ZERO";
#if UPDATE_20190807
#else
                break;
#endif
            case "Check Digit":
                goto case "APPEND_PAD_ZERO";
#if UPDATE_20190807
#else
                break;
#endif
            case "Account Num":
                goto case "APPEND_PAD_SPCE";
#if UPDATE_20190807
#else
                break;
#endif
            case "Amount     ":
                goto case "PREPEND_PAD_ZERO";
#if UPDATE_20190807
#else
                break;
#endif
            case "ID Number  ":
                goto case "PREPEND_PAD_SPCE";
#if UPDATE_20190807
#else
                break;
#endif
            case "Rec. Name  ":
                goto case "APPEND_PAD_SPCE";
#if UPDATE_20190807
#else
                break;
#endif
            case "Disc. Data ":
                goto case "PREPEND_PAD_SPCE";
#if UPDATE_20190807
#else
                break;
#endif
            case "Addenda Ind":
                goto case "PREPEND_PAD_SPCE";
#if UPDATE_20190807
#else
                break;
#endif
            case "Trace Num. ":
                goto case "PREPEND_PAD_SPCE";
#if UPDATE_20190807
#else
                break;
#endif
            case "A. Rec Type":
                goto case "PREPEND_PAD_ZERO";
#if UPDATE_20190807
#else
                break;
#endif
            case "Adden. Type":
                goto case "PREPEND_PAD_ZERO";
#if UPDATE_20190807
#else
                break;
#endif
            case "Paymnt Info":
                goto case "PREPEND_PAD_SPCE";
#if UPDATE_20190807
#else
                break;
#endif
            case "Add Seq Num":
                goto case "PREPEND_PAD_ZERO";
#if UPDATE_20190807
#else
                break;
#endif
            case "Ent Seq Num":
                goto case "PREPEND_PAD_ZERO";
#if UPDATE_20190807
#else
                break;
#endif

            // Right Justify
            case "PREPEND_PAD_ZERO":
                ot = GLOBALS._trun(GLOBALS._pad(value, field_map[field].Item2, '0'), field_map[field].Item2);
                break;

            // Right Justify
            case "PREPEND_PAD_SPCE":
                ot = GLOBALS._trun(GLOBALS._pad(value, field_map[field].Item2), field_map[field].Item2);
                break;

            // Left Justify
            case "APPEND_PAD_ZERO":
                ot = GLOBALS.trun_(GLOBALS.pad_(value, field_map[field].Item2, '0'), field_map[field].Item2);
                break;

            // Left Justify
            case "APPEND_PAD_SPCE":
                ot = GLOBALS.trun_(GLOBALS.pad_(value, field_map[field].Item2), field_map[field].Item2);
                break;

            default:
                ot = field;
                break;
            }
            // for display purposes, we'll display the dollar amount in a more readable form.
            if (field == "Amount     " && display == true)
            {
                string cn = ot.Substring(ot.Length - 2, 2);

                string dl   = ot.Substring(0, ot.Length - 2);
                int    conv = 0;
                Int32.TryParse(dl, out conv); // we'll try setting it this way.
                dl = conv.ToString();
                ot = $"${dl}.{cn}";
            }


            return(ot);
        }