private void CrearRegistracionButton_Click(object sender, EventArgs e)
        {
            if (DgvConfirmaciones.Rows.Count == 0)
            {
                MessageBox.Show("No hay confirmaciones de cobro", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var rta = MessageBox.Show("¿Está seguro de crear una registración por la confirmación seleccionada?",
                                      "Confrimación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (rta == DialogResult.No)
            {
                return;
            }


            var codConfirmacion = (int)DgvConfirmaciones.SelectedRows[0].Cells[0].Value;

            var fechaRegistracion = DateTime.Now;

            // InsertRegistracion(codConfirmacion, fechaRegistracion);

            // En la cuenta corriente del cliente, en el campo << DEBE >> pasará a restársele el valor de << IMPORTE RECIBIDO >>
            // mientras que en el campo << SALDO >> de la cuenta bancaria cuyo registro se accederá a través de
            // << COD.CUENTA BANCARIA >> se le sumará el campo << IMPORTE RECIBIDO >>

            object[] parameters =
            {
                codConfirmacion,
                fechaRegistracion.ToShortDateString()
            };

            ExecuteQuery.InsertInto(41, parameters);
            if (MessageException.message == "")
            {
                ExecuteQuery.UpdateOne(40, codConfirmacion, "relleno");
                if (MessageException.message == "")
                {
                    int codCuenta = (int)DgvConfirmaciones.SelectedRows[0].Cells[1].Value;
                    ExecuteQuery.UpdateOne(41, codConfirmacion, codCuenta);
                    if (MessageException.message == "")
                    {
                        var popup1 = new PopupNotifier()
                        {
                            Image        = Properties.Resources.sql_success1,
                            TitleText    = "Mensaje",
                            ContentText  = "La registración ha sido insertada con exito",
                            ContentFont  = new Font("Segoe UI Bold", 11F),
                            TitleFont    = new Font("Segoe UI Bold", 10F),
                            ImagePadding = new Padding(10)
                        };
                        popup1.Popup();
                        ListarConfirmaciones();
                        ListarRegistraciones();
                    }
                }
            }
        }
        private void BorrarConfirmacionButton_Click(object sender, EventArgs e)
        {
            if (DgvListadoConfirmaciones.Rows.Count == 0)
            {
                MessageBox.Show("No hay confirmaciones de cobro a borrar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var rta = MessageBox.Show("¿Está seguro de borrar la confirmación de cobro?", "Confirmación", MessageBoxButtons.YesNo,
                                      MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (rta == DialogResult.No)
            {
                return;
            }

            if (DgvListadoConfirmaciones.SelectedRows.Count == 0)
            {
                MessageBox.Show("Seleccione la confirmación de cobro a borrar");
                return;
            }


            // Lógica de borrado de facturas (??) -> Confirmacion de cobro

            int codConf = (int)DgvListadoConfirmaciones.SelectedRows[0].Cells[0].Value;

            int?existe = ExecuteQuery.SelectCode(600, codConf);

            if (existe > 0)
            {
                MessageBox.Show("El pago ya fue sumado a la cuenta corriente ingresada. No puede ser borrado");
                return;
            }

            if (existe == 0)
            {
                ExecuteQuery.DeleteFrom(4, codConf);
                if (MessageException.message == "")
                {
                    var popup1 = new PopupNotifier()
                    {
                        Image       = Properties.Resources.info100,
                        TitleText   = "Mensaje",
                        ContentText = "La confirmación ha sido borrada con exito",
                        ContentFont = new Font("Segoe UI Bold", 11F),
                        TitleFont   = new Font("Segoe UI Bold", 10F)
                    };
                    popup1.Popup();
                    ListarConfirmaciones();
                }
            }

            // CargarGrids();
        }
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     if (textBox1.Text == "")
     {
         ListarRegistraciones();
     }
     else
     {
         int codigo = 0;
         if (Int32.TryParse(textBox1.Text, out codigo))
         {
             ExecuteQuery.SelectOne(502, codigo);
         }
     }
 }
        private void CodCuentaBusquedaTextBox_TextChanged(object sender, EventArgs e)
        {
            int codigo = 0;

            if (CodCuentaBusquedaTextBox.Text != "")
            {
                if (Int32.TryParse(CodCuentaBusquedaTextBox.Text, out codigo))
                {
                    DgvListadoConfirmaciones.DataSource = ExecuteQuery.SelectOne(501, codigo);
                }
            }
            else
            {
                ListarConfirmaciones();
            }
        }
        private void GuardarDatosButton_Click(object sender, EventArgs e)
        {
            if (!ValidarCampos())
            {
                return;
            }

            var fechaDebitacion = FechaDebitacionPicker.Value;
            var importeRecibido = ImporteRecibidoNumeric.Value;

            // var cuenta bancaria = etc
            // TODO: determinar si lo ingresado en el TextBox de cuenta bancaria es código o número de cuenta
            // para mandarlo como parámetro
            // (Solucionado utilizando un datagrid)

            int codcuenta = (int)dgvCuentasEmpresa.SelectedRows[0].Cells[0].Value;

            object[] parameters =
            {
                codFactura,
                codcuenta,
                fechaDebitacion.ToShortDateString(),
                (int)importeRecibido
            };

            ExecuteQuery.InsertInto(40, parameters);
            // InsertConfirmación(codFactura, cuentaBancaria, fechaDebitacion, importeRecibido);
            if (MessageException.message == "")
            {
                var popup1 = new PopupNotifier()
                {
                    Image        = Properties.Resources.sql_success1,
                    TitleText    = "Mensaje",
                    ContentText  = "La confirmación ha sido insertada con exito",
                    ContentFont  = new Font("Segoe UI Bold", 11F),
                    TitleFont    = new Font("Segoe UI Bold", 10F),
                    ImagePadding = new Padding(10)
                };
                popup1.Popup();

                CancelarButton_Click(sender, e);

                //CargarGrids();
                ListarFacturas();
                ListarConfirmaciones();
            }
        }
 private void ListarFacturas()
 {
     DgvFacturas.DataSource = ExecuteQuery.SelectAll(403);
 }
 private void ListarCuentas()
 {
     dgvCuentasEmpresa.DataSource = ExecuteQuery.SelectAll(402);
 }
 private void ListarConfirmaciones()
 {
     DgvListadoConfirmaciones.DataSource = ExecuteQuery.SelectAll(400);
 }
 private void ListarRegistraciones()
 {
     DgvListadoRegistraciones.DataSource = ExecuteQuery.SelectAll(401);
 }