Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            String       Add = textBox1.Text;
            StorageAuto1 add = new StorageAuto1();

            Console.WriteLine("Enter the line you want to add: ");
            add.AppendAllText("dbase.txt", Add);
        }
Example #2
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            List <StorageAuto1> list = new List <StorageAuto1>();
            int          n           = 0;
            StreamReader f           = new StreamReader("dbase.txt");
            string       s;
            int          i = 0;
            int          j = 0;

            try
            {
                while ((s = f.ReadLine()) != null)
                {
                    list.Add(new StorageAuto1(s));
                    ++i;
                }
                n = i - 1;
                foreach (var element in list)
                {
                    j++;
                }
                f.Close();
            }
            catch (FileNotFoundException d)
            {
                Console.WriteLine(d.Message);
                Console.WriteLine("Check the correct name and path to the file!");
                return;
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("Very large file!");
                return;
            }
            catch (Exception d)
            {
                Console.WriteLine("Error: " + d.Message); return;
            }
            StorageAuto1[] group = new StorageAuto1[10];
            for (int ij = 0; ij < j; ij++)
            {
                group[ij] = list[ij];
            }
            Console.WriteLine("sort is Code:");
            Array.Sort(group, new StorageAuto1.SortByCode());
            foreach (StorageAuto1 elem in group)
            {
                elem.ToString();
            }
            foreach (var element in group)
            {
                Console.WriteLine(element);
            }
            MessageBox.Show("Vse good proyshlo");
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            String       Del = textBox1.Text;
            String       Add = textBox2.Text;
            StorageAuto1 del = new StorageAuto1();

            del.Delete("dbase.txt", Del.Length);
            Console.WriteLine("-------------redahuvannya-----------------------");
            StorageAuto1 add = new StorageAuto1();

            add.AppendAllText("dbase.txt", Add);
        }
Example #4
0
            int IComparer.Compare(object ob1, object ob2)
            {
                StorageAuto1 p1 = (StorageAuto1)ob1;
                StorageAuto1 p2 = (StorageAuto1)ob2;

                if (p1.Name.Length > p2.Name.Length)
                {
                    return(1);
                }
                if (p1.Name.Length < p2.Name.Length)
                {
                    return(-1);
                }
                return(0);
            }
Example #5
0
            int IComparer.Compare(object ob1, object ob2)
            {
                StorageAuto1 p1 = (StorageAuto1)ob1;
                StorageAuto1 p2 = (StorageAuto1)ob2;

                if (p1.Quantity > p2.Quantity)
                {
                    return(1);
                }
                if (p1.Quantity < p2.Quantity)
                {
                    return(-1);
                }
                return(0);
            }
Example #6
0
            int IComparer.Compare(object ob1, object ob2)
            {
                StorageAuto1 p1 = (StorageAuto1)ob1;
                StorageAuto1 p2 = (StorageAuto1)ob2;

                if (p1.Price > p2.Price)
                {
                    return(1);
                }
                if (p1.Price < p2.Price)
                {
                    return(-1);
                }
                return(0);
            }