Ejemplo n.º 1
0
 private void Phone2_TextChanged(object sender, EventArgs e)
 {
     if (Phone2.TextLength == 3)
     {
         Phone3.Focus();
     }
 }
 public IActionResult Create(Phone3 phone)
 {
     return(Content(phone.Name));
 }
 public IActionResult GetPhone(Phone3 myPhone)
 {
     return(Content($"Name: {myPhone?.Name}  Price:{myPhone.Price}  Company: {myPhone.Manufacturer?.Name}"));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Get the GEDCOM 5.5 lines for the data in this object.
        /// Lines start at the given level
        /// </summary>
        /// <param name="sw">
        /// A <see cref="TextWriter"/>
        /// </param>
        /// <param name="level">
        /// A <see cref="int"/>
        /// </param>
        public void Output(TextWriter sw, int level)
        {
            sw.Write(Environment.NewLine);
            sw.Write(Util.IntToString(level));
            sw.Write(" ADDR");

            if (!string.IsNullOrEmpty(AddressLine))
            {
                sw.Write(" ");

                Util.SplitLineText(sw, AddressLine, level, 60, 3, true);
            }

            string levelStr     = null;
            string levelPlusOne = null;

            if (!string.IsNullOrEmpty(AddressLine1))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR1 ");
                if (line.Length <= 60)
                {
                    sw.Write(AddressLine1);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine1");
                }
            }

            if (!string.IsNullOrEmpty(AddressLine2))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR2 ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine2");
                }
            }

            if (!string.IsNullOrEmpty(AddressLine3))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR3 ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine3");
                }
            }

            if (!string.IsNullOrEmpty(City))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = City.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" CITY ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating City");
                }
            }

            if (!string.IsNullOrEmpty(State))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = State.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" STAE ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating State");
                }
            }

            if (!string.IsNullOrEmpty(PostCode))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = PostCode.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" POST ");
                if (line.Length <= 10)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 10));
                    System.Diagnostics.Debug.WriteLine("Truncating PostCode");
                }
            }

            if (!string.IsNullOrEmpty(Country))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = Country.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" CTRY ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Country");
                }
            }

            if (!string.IsNullOrEmpty(Phone1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone1");
                }
            }

            if (!string.IsNullOrEmpty(Phone2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone2");
                }
            }

            if (!string.IsNullOrEmpty(Phone3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone3");
                }
            }

            if (!string.IsNullOrEmpty(Fax1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax1");
                }
            }

            if (!string.IsNullOrEmpty(Fax2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax2");
                }
            }

            if (!string.IsNullOrEmpty(Fax3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax3");
                }
            }

            if (!string.IsNullOrEmpty(Email1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email1");
                }
            }

            if (!string.IsNullOrEmpty(Email2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email2");
                }
            }

            if (!string.IsNullOrEmpty(Email3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email3");
                }
            }

            if (!string.IsNullOrEmpty(Www1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www1");
                }
            }

            if (!string.IsNullOrEmpty(Www2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www2");
                }
            }

            if (!string.IsNullOrEmpty(Www3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www3");
                }
            }
        }