Example #1
0
        private void actualizarCampos(string idProyecto)
        {
            Proyecto proyectoSeleccionado = oProyectoService.recuperarProyecto(idProyecto);

            if (proyectoSeleccionado != null)
            {
                txtId.Text = proyectoSeleccionado.Id_proyecto.ToString();
                cboProducto.SelectedValue    = proyectoSeleccionado.Producto.Id_producto;
                txtDescripcion.Text          = proyectoSeleccionado.Descripcion;
                txtVersion.Text              = proyectoSeleccionado.Version;
                txtAlcance.Text              = proyectoSeleccionado.Alcance;
                cboResponsable.SelectedValue = proyectoSeleccionado.Responsable.NombreUsuario;
            }
            else
            {
                limpiarCampos();
            }
        }
Example #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (validarCliente())
            {
                Factura        factura = new Factura();
                DetalleFactura detalle;
                for (int i = 0; i < dgvDetalles.Rows.Count; i++)
                {
                    detalle = new DetalleFactura();
                    detalle.Numero_orden = i + 1;
                    if ((bool)dgvDetalles.Rows[i].Cells["esProducto"].Value)
                    {
                        detalle.Producto = oProductoService.recuperarProducto(dgvDetalles.Rows[i].Cells["id"].Value.ToString());
                    }
                    else
                    {
                        detalle.Proyecto = oProyectoService.recuperarProyecto(dgvDetalles.Rows[i].Cells["id"].Value.ToString());
                    }
                    detalle.Precio   = Convert.ToDouble(dgvDetalles.Rows[i].Cells["precio"].Value);
                    detalle.Cantidad = Convert.ToInt32(dgvDetalles.Rows[i].Cells["cantidad"].Value);
                    factura.Detalles.Add(detalle);
                }

                factura.Cliente         = oClienteService.recuperarCliente(cboCliente.SelectedValue.ToString());
                factura.Fecha           = dtpFechaFactura.Value;
                factura.Usuario_creador = usuarioActual;
                factura.Total           = Convert.ToSingle(txtTotal.Text);
                string resultado = oFacturaService.CrearFactura(factura);
                if (resultado.Length > 0)
                {
                    MessageBox.Show("La factura se ha registrado con éxito. Número de factura:" + resultado, "Registrar factura", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dgvDetalles.Rows.Clear();
                }
                else
                {
                    MessageBox.Show("La factura no se ha podido registrar correctamente.", "Registrar factura", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            txtTotal.Clear();
        }