Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrEmpty(textBox3.Text))
            {
                Cant_propiedades c = new Cant_propiedades();
                repetidos_prop();
                if (encontrar_pro)
                {
                    repetidos_cant();
                    if (encontrar_cant)
                    {
                        c.Nombre   = textBox2.Text;
                        c.Apellido = textBox3.Text;
                        cant_p[cont_cant].Cantidad += 1;
                        c.Cantidad = cant_p[cont_cant].Cantidad;
                        cant_p.Add(c);
                        cant_p.RemoveAt(cont_cant);
                        escribir_cant();
                        encontrar_cant = false;
                        cont_cant      = 0;
                    }
                    else
                    {
                        cont_cant = 0;
                    }

                    encontrar_pro    = false;
                    cont_pro         = 0;
                    textBox4.Enabled = true;
                    textBox5.Enabled = true;
                }
                else
                {
                    Propietarios p = new Propietarios();
                    p.Dpi      = textBox1.Text;
                    p.Nombre   = textBox2.Text;
                    p.Apellido = textBox3.Text;
                    prop.Add(p);
                    escribir_propietarios();
                    c.Nombre   = textBox2.Text;
                    c.Apellido = textBox3.Text;
                    c.Cantidad = cont1;
                    cant_p.Add(c);
                    escribir_cant();
                    textBox4.Enabled = true;
                    textBox5.Enabled = true;
                    cont_pro         = 0;
                }
                textBox4.Focus();
                button2.Enabled = true;
                button1.Enabled = false;
            }
            else
            {
                MessageBox.Show("Debe llenar todos los campos");
            }
        }
Пример #2
0
        void leer_cant()
        {
            OpenFileDialog op       = new OpenFileDialog();
            string         fileName = "Cantidad.txt";
            FileStream     stream   = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            StreamReader   read     = new StreamReader(stream);

            while (read.Peek() > -1)
            {
                Cant_propiedades c = new Cant_propiedades();
                c.Nombre   = read.ReadLine();
                c.Apellido = read.ReadLine();
                c.Cantidad = Convert.ToInt32(read.ReadLine());
                cant_p.Add(c);
            }
            read.Close();
        }