//BOTONES

        private void cboTipoDNI_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (txtDni.Text != "" && cboTipoDNI.SelectedIndex != -1)
                {
                    if (cl.VerificarPersona(Convert.ToInt32(cboTipoDNI.SelectedValue), Convert.ToInt32(txtDni.Text)) > 0)
                    {
                        pr = null;
                        pr = cl.BuscarPersona(Convert.ToInt32(cboTipoDNI.SelectedValue), Convert.ToInt32(txtDni.Text));

                        limpiarVentana();

                        txtApellido.Text = pr.pApellido;
                        txtNombre.Text   = pr.pNombre;

                        RefreshEstadoCuenta(pr.pDNI, pr.pTipoDNI);
                        TotalEstadoCuenta();
                        cboOperacion.Enabled = true;
                    }
                    else
                    {
                        DialogResult opcion = MessageBox.Show("La persona no está registrada, ¿desea realizar el asiento de todas formas?", "Persona no ingresada", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (opcion == DialogResult.Yes)
                        {
                            limpiarVentana();
                            cboOperacion.Enabled = true;
                        }
                        else
                        {
                            limpiarVentana();
                            DeshabilitarAsientoDia();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Esempio n. 2
0
        //Buscar locador por apellido
        private void btnBuscarApellido_Click(object sender, EventArgs e)
        {
            dgvNuevaProp.Rows.Clear();

            try
            {
                if (txtDniBuscar.Text != "" && cboTipoBuscar.SelectedIndex != -1)
                {
                    if (cl.VerificarPersona(Convert.ToInt32(cboTipoBuscar.SelectedValue), Convert.ToInt32(txtDniBuscar.Text)) > 0)
                    {
                        locador = new Persona();
                        locador = cl.BuscarPersona(Convert.ToInt32(cboTipoBuscar.SelectedValue), Convert.ToInt32(txtDniBuscar.Text));

                        txtApellidoBuscar.Text = locador.pApellido;
                        txtNombreBuscar.Text   = locador.pNombre;


                        listaProp = pAd.CargarListaPropiedades(Convert.ToInt32(txtDniBuscar.Text), Convert.ToInt32(cboTipoBuscar.SelectedValue));
                        foreach (var item in listaProp)
                        {
                            dgvNuevaProp.Rows.Add(item.pId_propiedad, item.pCalle, item.pNumeroCalle, item.pPiso, item.pDpto);
                        }
                    }
                    else
                    {
                        limpiarCamposNuevaProp(1);

                        DialogResult opcion = MessageBox.Show("El registro no existe. ¿Desea cargar un nuevo Locador/a?", "¿Nuevo Locador/a?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (opcion == DialogResult.Yes)
                        {
                            Clientes c = new Clientes();
                            c.nuevaPropiedad = true;
                            c.habilitarCamposCliente();
                            c.nuevoCliente(Convert.ToInt32(cboTipoBuscar.SelectedValue), txtDniBuscar.Text, "");
                            abrirVentana <Clientes>(c);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Esempio n. 3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (validarCamposCliente())
            {
                dni           = pr.pDNI = Convert.ToInt32(txtDNI.Text);
                tipo          = pr.pTipoDNI = Convert.ToInt32(cboTipoDNI.SelectedValue);
                pr.pApellido  = txtApellido.Text;
                pr.pNombre    = txtNombre.Text;
                pr.pDireccion = txtDireccion.Text;
                pr.pAltura    = Convert.ToInt32(txtAltura.Text);
                if (txtPiso.Text == "")
                {
                    pr.pPiso = 0;
                }
                else
                {
                    pr.pPiso = Convert.ToInt32(txtPiso.Text);
                }
                if (txtDepto.Text == "")
                {
                    pr.pDepto = "";
                }
                else
                {
                    pr.pDepto = txtDepto.Text;
                }
                if (cboBarrio.SelectedIndex != -1)
                {
                    pr.pBarrio = Convert.ToInt32(cboBarrio.SelectedValue);
                }
                else
                {
                    MessageBox.Show("Debe ingresar un barrio");
                }

                pr.pciudad       = Convert.ToInt32(cboCiudad.SelectedValue);
                pr.pdepartamento = Convert.ToInt32(cboDepartamento.SelectedValue);
                pr.pProvincia    = Convert.ToInt32(cboProvincia.SelectedValue);
                pr.pMail         = txtMail.Text.Trim();

                //Si la persona No existe, INSERTAR
                if (cl.VerificarPersona(pr.pTipoDNI, pr.pDNI) == 0)
                {
                    cl.InsertarPersona(pr);                       //Primero se hace la inserción con los campos ingresados

                    pr.pTelefono = null;                          //Limpio la lista de teléfonos
                    pr.pTelefono = cl.buscarTelefonos(tipo, dni); //Se necesita buscar los teléfonos porque si no, no tienen el ID

                    if (locador == true)                          //Si se ingresa un nuevo Locador desde Nuevo Contrato
                    {
                        NuevoContrato nc = (NuevoContrato)this.ParentForm;
                        locador = false;            //Ponemos la bandera falso
                        abrirVentana <NuevoContrato>(nc);
                        nc.cargarCamposLocador(pr); //Cargamos los campos

                        this.Close();
                    }
                    else if (locatario == true)
                    {
                        NuevoContrato nc = (NuevoContrato)this.ParentForm;
                        locatario = false;
                        abrirVentana <NuevoContrato>(nc);
                        nc.cargarCamposLocatario(pr);

                        this.Close();
                    }
                    else if (garante == true)
                    {
                        NuevoContrato nc = (NuevoContrato)this.ParentForm;
                        garante = false;
                        abrirVentana <NuevoContrato>(nc);
                        nc.cargarCamposGarante(pr);

                        this.Close();
                    }
                    else if (comprobantes == true)
                    {
                        EstadoDeCuentas ec = (EstadoDeCuentas)this.ParentForm;
                        comprobantes = false;
                        abrirVentana <EstadoDeCuentas>(ec);
                        //FALTA CARGA DE DATOS EN LA VENTANA ESTADO DE CUENTAS

                        this.Close();
                    }
                    else if (nuevaPropiedad == true)
                    {
                        Propiedades prop = (Propiedades)this.ParentForm;
                        nuevaPropiedad = false;
                        abrirVentana <Propiedades>(prop);
                        prop.nuevoLocador(pr);

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Se ingresó correctamente el registro");
                        this.Close();
                    }
                }

                //Si la persona existe, ACTUALIZAR
                else
                {
                    cl.modificarPersona(pr);
                    foreach (var item in idTelefonoBorrar)
                    {
                        if (item != 0) //Si el valor es 0, es porque el teléfono se cargó y se borró en el momento por lo cual no está ingresado en BD y no hace falta borrarlo
                        {
                            cl.BorrarTelefono(item);
                        }
                    }
                    pr.pTelefono = null;                          //Limpio la lista de teléfonos
                    pr.pTelefono = cl.buscarTelefonos(tipo, dni); //Se necesita buscar los teléfonos porque si no, no tienen el ID

                    if (locador == true)
                    {
                        NuevoContrato nc = (NuevoContrato)this.ParentForm;

                        locador = false;
                        abrirVentana <NuevoContrato>(nc);
                        nc.cargarCamposLocador(pr);

                        this.Close();
                    }
                    else if (locatario == true)
                    {
                        NuevoContrato nc = (NuevoContrato)this.ParentForm;
                        locatario = false;
                        abrirVentana <NuevoContrato>(nc);
                        nc.cargarCamposLocatario(pr);

                        this.Close();
                    }
                    else if (garante == true)
                    {
                        NuevoContrato nc = (NuevoContrato)this.ParentForm;
                        garante = false;
                        abrirVentana <NuevoContrato>(nc);
                        nc.cargarCamposGarante(pr);

                        this.Close();
                    }
                    else if (comprobantes == true)
                    {
                        EstadoDeCuentas ec = (EstadoDeCuentas)this.ParentForm;
                        comprobantes = false;
                        abrirVentana <EstadoDeCuentas>(ec);

                        this.Close();
                        //FALTA CARGA DE DATOS EN LA VENTANA ESTADO DE CUENTAS
                    }
                    else
                    {
                        MessageBox.Show("Se modificó correctamente el registro");
                        this.Close();
                    }
                }
            }
        }