Пример #1
0
        public string Output()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var n in Names)
            {
                sb.Append(n);
                sb.Append(",");
            }

            if (Amount1 >= 0)
            {
                sb.Append("$" + Amount1.ToString());
            }
            else
            {
                sb.Append(" ");
            }
            sb.Append(",");

            if (Amount2 >= 0)
            {
                sb.Append("$" + Amount2.ToString());
            }
            else
            {
                sb.Append(" ");
            }
            sb.Append(",");

            sb.Append(Diff);
            sb.Append(System.Environment.NewLine);

            return(sb.ToString());
        }
Пример #2
0
        public static void TrafficAmount(int type, int amount)
        {
            string file    = Application.StartupPath + "\\traf.dat";
            int    Amount1 = 0;
            int    Amount2 = 0;

            if (File.Exists(file))
            {
                string[] lines = File.ReadAllLines(file);
                int.TryParse(lines[0].Trim(), out Amount1);
                int.TryParse(lines[1].Trim(), out Amount2);
            }
            if (type == 1)
            {
                Amount1 += amount;
            }
            else if (type == 2)
            {
                Amount2 += amount;
            }
            string[] arr = new[] { Amount1.ToString(), Amount2.ToString() };
            File.WriteAllLines(file, arr);
        }