Exemple #1
0
        //Borrar cliente seleccionado
        private void btnBorrarCliente_Click(object sender, EventArgs e)
        {
            try
            {
                Cliente C = ((ClienteVisto)(dgvClientes.SelectedRows[0].DataBoundItem)).Origen();

                A.BorrarCliente(C);

                if (A.Cliente.Count() == 0)
                {
                    dgvClientes.DataSource     = null;
                    dgvContenedores.DataSource = null;
                }
                else
                {
                    ActualizarDGV(dgvClientes, ClienteVisto.RetornaClientesVisto(A.Cliente));
                    ActualizarDGV(dgvContenedores, A.Contenedor);
                }
                LimpiarTxt();
            }
            catch (Exception)
            {
                MessageBox.Show("Seleccione un usuario de la lista para eliminarlo", "Sin seleccion");
            }
        }
Exemple #2
0
        //Crea cliente con los datos ingresados
        private void btnAgregarCliente_Click(object sender, EventArgs e)
        {
            try
            {
                Cliente C;

                //Dependiendo de la seleccion del combo, crea una persona o empresa
                if (cmbTipoCliente.SelectedItem.ToString() == "Persona")
                {
                    C = new Persona(txtLegajo.Text, txtNombre.Text, txtApellido.Text);
                }
                else
                {
                    C = new Empresa(txtLegajo.Text, txtRazonSocial.Text);
                }

                //Agregar Persona
                A.AgregarCliente(C);

                //Comprueba si se agrego el cliente, para proceder con actualizar dgv y normalizar interfaz
                if (A.Cliente.Contains(C))
                {
                    ActualizarDGV(dgvClientes, ClienteVisto.RetornaClientesVisto(A.Cliente));
                    NormalizarPanel();
                    LimpiarTxt();
                    dgvClientes.Enabled = true;
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #3
0
        //Modifica cliente con los datos ingresados
        private void btnModificarCliente_Click(object sender, EventArgs e)
        {
            try
            {
                //Obtiene el cliente seleccionado en la DGV
                Cliente C = ((ClienteVisto)(dgvClientes.SelectedRows[0].DataBoundItem)).Origen();

                //Crea un objeto Z y copia los valores a ingresar en C
                Cliente Z;
                if (C is Persona)
                {
                    Z = new Persona(txtLegajo.Text, txtNombre.Text, txtApellido.Text);
                }
                else
                {
                    Z = new Empresa(txtLegajo.Text, txtRazonSocial.Text);
                }

                //Comprueba si los valores a ingresar en Z cumplen formato
                if (A.ControlarNombreRazon(Z) != null)
                {
                    return;
                }

                //Si cumplen, agregar los nuevos valores al objeto
                if (C is Persona)
                {
                    C.Nombre   = txtNombre.Text;
                    C.Apellido = txtApellido.Text;
                }
                else
                {
                    C.RazonSocial = txtRazonSocial.Text;
                }

                //Comprueba si se agrego el cliente, para proceder con actualizar dgv y normalizar interfaz
                if (A.Cliente.Contains(C))
                {
                    ActualizarDGV(dgvClientes, ClienteVisto.RetornaClientesVisto(A.Cliente));
                    NormalizarPanel();
                    LimpiarTxt();
                }
            }
            catch (Exception)
            {
            }
        }