Ejemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            int indice = cbxTipo.SelectedIndex;

            if (txtCalle.Text == "" || cbxTipo.Text == "" || cbxEstado.Text == "" || cbxBañoC.Text == "" || cbxCuarto.Text == "" || txtMTS2.Text == "" || txtCosto.Text == "" || txtPiso.Text == "" || cbxBañoM.Text == "" || txtNumero.Text == "" || txtColonia.Text == "")
            {
                MessageBox.Show("Verifique que los campos no esten vacios");
            }
            else
            {
                Random rdn = new Random();
                int    a   = rdn.Next(100, 1000);
                int    b   = rdn.Next(100, 1000);

                ID        = a.ToString() + "-" + b.ToString();
                que       = cbxTipo.Text;
                Estado    = cbxEstado.Text;
                bañoC     = cbxBañoC.Text;
                Costo     = txtCosto.Text;
                Metros    = txtMTS2.Text;
                cuarto    = cbxCuarto.Text;
                Direccion = txtCalle.Text;
                Pcasa     = txtPiso.Text;
                Numero    = txtNumero.Text;
                Colonia   = txtColonia.Text;
                bañoM     = cbxBañoM.Text;
                Imagen    = txtImagen.Text;
                if (indice == 0)
                {
                    y             = 4;
                    Ndepartamento = txtNDepartamento.Text;
                    Pdepartamento = textPDepartamento.Text;
                    String Venta = ID + ",false" + "," + que + "," + Costo + "," + Pdepartamento + "," + Ndepartamento + "," + Direccion + "," + Numero + "," + Colonia + "," + Estado + "," + Metros + "," + cuarto + "," + bañoC + "," + bañoM + "," + chbxCocina.Checked + "," + chbxSala.Checked + "," + chbxComedor.Checked + "," + chbxLavado.Checked + "," + Pcasa + "," + chbxCochera.Checked + "," + Ncupos + "," + Imagen;
                    MessageBox.Show(Venta);
                    Lista.Add(Venta);
                    result = TA.EscribirArchivo(Lista, y);
                    MessageBox.Show(result);
                    this.Close();
                }
                else
                {
                    y = 3; String Venta = ID + ",false" + "," + que + "," + Costo + "," + Direccion + "," + Numero + "," + Colonia + "," + Estado + "," + Metros + "," + cuarto + "," + bañoC + "," + bañoM + "," + chbxCocina.Checked + "," + chbxSala.Checked + "," + chbxComedor.Checked + "," + chbxLavado.Checked + "," + Pcasa + "," + chbxCochera.Checked + "," + Ncupos + "," + Imagen;
                    MessageBox.Show(Venta);
                    Lista.Add(Venta);
                    result = TA.EscribirArchivo(Lista, y);
                    MessageBox.Show(result);
                    this.Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void btnGuardar_Click_1(object sender, EventArgs e)
        {
            int indice = cbxTipo.SelectedIndex;

            if (txtCalle.Text == "" || cbxTipo.Text == "" || cbxEstado.Text == "" || cbxBañoC.Text == "" || cbxCuarto.Text == "" || txtMTS2.Text == "" || txtCosto.Text == "" || txtPiso.Text == "" || cbxBañoM.Text == "" || txtNumero.Text == "" || txtColonia.Text == "")
            {
                MessageBox.Show("no a llenado todos los campos");
            }
            else
            {
                que       = cbxTipo.Text;
                Estado    = cbxEstado.Text;
                bañoC     = cbxBañoC.Text;
                Costo     = txtCosto.Text;
                Metros    = txtMTS2.Text;
                cuarto    = cbxCuarto.Text;
                Direccion = txtCalle.Text;
                Pcasa     = txtPiso.Text;
                Numero    = txtNumero.Text;
                Colonia   = txtColonia.Text;
                bañoM     = cbxBañoM.Text;
                Imagen    = txtImagen.Text;
                Ncupos    = txtNcupos.Text;
                if (indice == 0)
                {
                    y             = 2;
                    Ndepartamento = txtNDepartamento.Text;
                    Pdepartamento = textPDepartamento.Text;
                    String Venta = ID + ",false" + "," + que + "," + Costo + "," + Pdepartamento + "," + Ndepartamento + "," + Direccion + "," + Numero + "," + Colonia + "," + Estado + "," + Metros + "," + cuarto + "," + bañoC + "," + bañoM + "," + chbxCocina.Checked + "," + chbxSala.Checked + "," + chbxComedor.Checked + "," + chbxLavado.Checked + "," + Pcasa + "," + chbxCochera.Checked + "," + Ncupos + "," + Imagen;
                    MessageBox.Show(Venta);
                    Lista.Add(Venta);
                    result = TA.EscribirArchivo(Lista, y);
                    MessageBox.Show(result);
                    this.Close();
                }
                else
                {
                    y = 1;
                    String Venta = ID + ",false" + "," + que + "," + Costo + "," + Direccion + "," + Numero + "," + Colonia + "," + Estado + "," + Metros + "," + cuarto + "," + bañoC + "," + bañoM + "," + chbxCocina.Checked + "," + chbxSala.Checked + "," + chbxComedor.Checked + "," + chbxLavado.Checked + "," + Pcasa + "," + chbxCochera.Checked + "," + Ncupos + "," + Imagen;
                    MessageBox.Show(Venta);
                    Lista.Add(Venta);
                    result = TA.EscribirArchivo(Lista, y);
                    MessageBox.Show(result);
                    this.Close();
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            InitializeComponent();
            MessageBox.Show("Datos cliente: " + usuario);
            //1 - RentaCasas, 2 - Renta Departamento, 3 - Venta Casas, 4 - Venta Departamento, 5 - NuevoRegistro
            ArrayList HistorialRegistros = new ArrayList();

            TrabajarArchivo TA = new TrabajarArchivo();

            HistorialRegistros = TA.LeerArchivo(movimiento);

            HistorialRegistros.Add(usuario);                                //Añadimos a la lista el nuevo registro

            respuesta = TA.EscribirArchivo(HistorialRegistros, movimiento); //Guardamos

            RealizarVenta rv = new RealizarVenta();                         //Objeto paara comunicar la clase de Realizar Venta

            rv.GuardarVenta(usuario, movimiento, idVR, archivoBuscar);      //usuario - es la informacion del cliente, movimiento - es el numero del archivo a leer, idVR - es el id de la localidad

            this.Close();
        }
Ejemplo n.º 4
0
        public void GuardarVenta(string usuario, int movimiento, string idVR, string archivoBuscar)
        {
            //string usuario = (nom + "," + sgn + "," + apell + "," + "," + correo + "," + cel + "," + tel + "," + pais + "," + estado + "," + archivo + "," + idVR);

            TrabajarArchivo TA = new TrabajarArchivo();

            //1 - RentaCasas, 2 - Renta Departamento, 3 - Venta Casas, 4 - Venta Departamento
            if (archivoBuscar == "1")
            {
                BuscarLocalidad = TA.LeerArchivo(1);
                string[,] RRC   = new string[BuscarLocalidad.Count, 20];

                //usuario - es la informacion del cliente, movimiento - es el numero del archivo a leer, idVR - es el id de la localidad

                for (int i = 0; i < BuscarLocalidad.Count; i++)
                {
                    romperRegistro = (String)BuscarLocalidad[i];
                    String[] datoRegistro = romperRegistro.Split(',');

                    for (int j = 0; j < datoRegistro.Length; j++)
                    {
                        RRC[i, j] = datoRegistro[j];
                    }
                }

                for (int i = 0; i < BuscarLocalidad.Count; i++)
                {
                    if (RRC[i, 0] == idVR)
                    {
                        if (RRC[i, 1] == "false")
                        {
                            RRC[i, 1] = "true";
                        }
                    }
                }

                respuesta = TA.EscribirArchivo(BuscarLocalidad, movimiento);
                MessageBox.Show("Compra realizada" + respuesta);
            }
            else if (archivoBuscar == "2")
            {
                BuscarLocalidad = TA.LeerArchivo(2);
                string[,] RRC   = new string[BuscarLocalidad.Count, 22];

                //usuario - es la informacion del cliente, movimiento - es el numero del archivo a leer, idVR - es el id de la localidad

                for (int i = 0; i < BuscarLocalidad.Count; i++)
                {
                    romperRegistro = (String)BuscarLocalidad[i];
                    String[] datoRegistro = romperRegistro.Split(',');

                    for (int j = 0; j < datoRegistro.Length; j++)
                    {
                        RRC[i, j] = datoRegistro[j];
                    }
                }

                for (int i = 0; i < BuscarLocalidad.Count; i++)
                {
                    if (RRC[i, 0] == idVR)
                    {
                        if (RRC[i, 1] == "false")
                        {
                            RRC[i, 1] = "true";
                        }
                    }
                }

                respuesta = TA.EscribirArchivo(BuscarLocalidad, movimiento);
                MessageBox.Show("Compra realizada" + respuesta);
            }
            else if (archivoBuscar == "3")
            {
                BuscarLocalidad = TA.LeerArchivo(3);
                string[,] RRC   = new string[BuscarLocalidad.Count, 20];

                //usuario - es la informacion del cliente, movimiento - es el numero del archivo a leer, idVR - es el id de la localidad

                for (int i = 0; i < BuscarLocalidad.Count; i++)
                {
                    romperRegistro = (String)BuscarLocalidad[i];
                    String[] datoRegistro = romperRegistro.Split(',');

                    for (int j = 0; j < datoRegistro.Length; j++)
                    {
                        RRC[i, j] = datoRegistro[j];
                    }
                }

                for (int i = 0; i < BuscarLocalidad.Count; i++)
                {
                    if (RRC[i, 0] == idVR)
                    {
                        if (RRC[i, 1] == "false")
                        {
                            RRC[i, 1] = "true";
                        }
                    }
                }

                respuesta = TA.EscribirArchivo(BuscarLocalidad, movimiento);
                MessageBox.Show("Compra realizada" + respuesta);
            }
            else if (archivoBuscar == "4")
            {
                BuscarLocalidad = TA.LeerArchivo(4);
                string[,] RRC   = new string[BuscarLocalidad.Count, 22];

                //usuario - es la informacion del cliente, movimiento - es el numero del archivo a leer, idVR - es el id de la localidad

                for (int i = 0; i < BuscarLocalidad.Count; i++)
                {
                    romperRegistro = (String)BuscarLocalidad[i];
                    String[] datoRegistro = romperRegistro.Split(',');

                    for (int j = 0; j < datoRegistro.Length; j++)
                    {
                        RRC[i, j] = datoRegistro[j];
                    }
                }

                for (int i = 0; i < BuscarLocalidad.Count; i++)
                {
                    if (RRC[i, 0] == idVR)
                    {
                        if (RRC[i, 1] == "false")
                        {
                            RRC[i, 1] = "true";
                        }
                    }
                }

                respuesta = TA.EscribirArchivo(BuscarLocalidad, movimiento);
                MessageBox.Show("Compra realizada: " + respuesta);
            }
        }