Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrEmpty(textBox3.Text))
            {
                Cpropiedades c = new Cpropiedades();
                replayPr();
                if (hallarPr)
                {
                    replayCP();
                    if (hallarCP)
                    {
                        c.Nom          = textBox2.Text;
                        c.Apellido     = textBox3.Text;
                        cp[cont].Cant += 1;
                        c.Cant         = cp[cont].Cant;
                        cp.Add(c);
                        cp.RemoveAt(cont);
                        escribirCantidad();
                        hallarCP = false;
                        cont     = 0;
                    }
                    else
                    {
                        cont = 0;
                    }

                    hallarPr         = false;
                    Pr               = 0;
                    textBox4.Enabled = true;
                    textBox5.Enabled = true;
                }
                else
                {
                    dueños p = new dueños();
                    p.Id   = textBox1.Text;
                    p.Noms = textBox2.Text;
                    p.Ape  = textBox3.Text;
                    du.Add(p);
                    escDueños();
                    c.Nom      = textBox2.Text;
                    c.Apellido = textBox3.Text;
                    c.Cant     = cP;
                    cp.Add(c);
                    escribirCantidad();
                    textBox4.Enabled = true;
                    textBox5.Enabled = true;
                    Pr = 0;
                }
                textBox4.Focus();
                button2.Enabled = true;
                button1.Enabled = false;
            }
            else
            {
                MessageBox.Show("Debe llenar todos los campos");
            }
        }
Example #2
0
        void leerCantidad()
        {
            OpenFileDialog op       = new OpenFileDialog();
            string         fileName = "Precio.txt";
            FileStream     stream   = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            StreamReader   read     = new StreamReader(stream);

            while (read.Peek() > -1)
            {
                Cpropiedades c = new Cpropiedades();
                c.Nom      = read.ReadLine();
                c.Apellido = read.ReadLine();
                c.Cant     = Convert.ToInt32(read.ReadLine());
                cp.Add(c);
            }
            read.Close();
        }