Exemplo n.º 1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            string name = nameInput.Text;

            ;           string state = stateInput.Text;
            var isNotNull            = false;

            if (name.Trim() == "")
            {
                MessageBox.Show("Введите наименование гитары");
                isNotNull = true;
            }
            else
            {
                isNotNull = false;
            }
            if (state.Trim() == "")
            {
                MessageBox.Show("Введите состояние гитары");
                isNotNull = true;
            }
            else
            {
                isNotNull = false;
            }

            if (isNotNull)
            {
                ProductGuitarInfo guitar1 = new ProductGuitarInfo(name, state);
                ReadWriteFile     file    = new ReadWriteFile();
                file.Write(guitar1.Name + "|" + guitar1.State, "Data");
                guitar = guitar1;
            }
        }
Exemplo n.º 2
0
        private void sendBtn_Click(object sender, EventArgs e)
        {
            string name = nameInput.Text.Trim();
            string tel  = telInput.Text.Trim();
            string dataInput;

            if (name.Length == 0 && tel.Length == 0)
            {
                MessageBox.Show("Введите корректные значения");
            }
            else
            {
                if (man.Checked)
                {
                    var man = new Men(name, tel);
                    list.Add(man);
                    dataInput = man.name + "|" + man.tel + "|" + man.dateTime + "|man";
                }
                else if (woman.Checked)
                {
                    var woman = new Women(name, tel);
                    list.Add(woman);
                    dataInput = woman.name + "|" + woman.tel + "|" + woman.dateTime + "|woman";
                }
                else
                {
                    MessageBox.Show("Выберите пол");
                    return;
                }

                // Обычный массив-----------------------------
                //var people = new People(name, tel);
                //list[people.getCount()] = people;
                //Array.Resize<object>(ref list, list.Length+1);
                //--------------------------------------------

                file.Write(dataInput);


                nameInput.Text = "";
                telInput.Text  = "";
            }
        }