public IngresosSPRegistrados()
        {
            InitializeComponent();
            lista       = new List <Ingresosp>();
            objigresosp = new Ingresosp();

            try
            {
                cbxLugar.DataSource = objlugar.Ver();

                cbxLugar.DisplayMember = "Nombre";

                cbxLugar.ValueMember = "Nombre";

                cbxLugar.SelectedItem = null;

                lista = objigresosp.Ver();

                dgvISP.DataSource = lista;
            }catch (Exception error)
            {
                MessageBox.Show("Error al intentar conectarse con la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            if (cbxIngresosp.SelectedItem == null)
            {
                MessageBox.Show("Es obligatorio seleccionar un LUGAR de ingreso.", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                if (string.IsNullOrEmpty(txtDPIngresosp.Text))
                {
                    MessageBox.Show("Es obligatorio llenar el campo DPI del cliente.", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (string.IsNullOrEmpty(txtEntregasp.Text))
                    {
                        MessageBox.Show("Es obligatorio llenar el campo QUIÉN ENTREGA.", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(txtPBsp.Text))
                        {
                            MessageBox.Show("Es obligatorio llenar el campo PESO BRUTO.", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(txtTarasp.Text))
                            {
                                MessageBox.Show("Es obligatorio llenar el campo TARA.", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(lblPesoNeto.Text))
                                {
                                    MessageBox.Show("Debe hacer clic en el botón PESO NETO.", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                                else
                                {
                                    int pb = int.Parse(txtPBsp.Text);
                                    int pn = pb - int.Parse(txtTarasp.Text);

                                    if (pn != int.Parse(lblPesoNeto.Text))
                                    {
                                        MessageBox.Show("El peso neto no coincide con la diferencia entre el peso bruto y la tara.", "Alto", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                    }
                                    else
                                    {
                                        try
                                        {
                                            string dpi = txtDPIngresosp.Text;

                                            while (dpi.Contains(" "))
                                            {
                                                dpi = dpi.Replace(" ", "");
                                            }

                                            SqlConnection conect = new SqlConnection("server = MBETANCOURT; database = cafedb; integrated security = true");
                                            conect.Open();
                                            string        select  = "select * from cliente where dpi = '" + dpi + "';";
                                            SqlCommand    comando = new SqlCommand(select, conect);
                                            SqlDataReader buscar  = comando.ExecuteReader();

                                            string idLugar = cbxIngresosp.SelectedValue.ToString();

                                            if (buscar.Read())
                                            {
                                                Ingresosp objingreso = new Ingresosp(txtDPIngresosp.Text, idLugar, txtEntregasp.Text.ToUpper(), txtPBsp.Text, txtTarasp.Text, lblPesoNeto.Text, usuario);
                                                objingreso.Agregar();

                                                int actual   = int.Parse(objcliente.getAcumulado(txtDPIngresosp.Text));
                                                int agregado = int.Parse(lblPesoNeto.Text);
                                                int nuevo    = actual + agregado;

                                                objcliente.setAcumulado(nuevo.ToString(), txtDPIngresosp.Text);

                                                MessageBox.Show("Nuevo ingreso AGREGADO con éxito.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                cbxIngresosp.SelectedItem = null;
                                                txtDPIngresosp.Clear();
                                                txtEntregasp.Clear();
                                                txtPBsp.Clear();
                                                txtTarasp.Clear();
                                                lblPesoNeto.Text = null;
                                            }
                                            else
                                            {
                                                MessageBox.Show("El cliente ingresado no aparece registrado. \nPara continuar ingrese los datos del nuevo cliente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }

                                            conect.Close();
                                        }
                                        catch (Exception error)
                                        {
                                            MessageBox.Show("Error al intentar conectarse con la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }