Esempio n. 1
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                bool    existeCliente = clientesBL.Existe(txtCUIT.Text);
                Cliente cliente;

                if (existeCliente)
                {
                    cliente = clientesBL.ObtenerPorCUIT(txtCUIT.Text);

                    SetearCliente(cliente);
                    clientesBL.Actualizar(cliente);

                    contexto.RegistrarEvento(Resources.ClientesForm_ClienteActualizado, cliente.Nombre);
                }
                else
                {
                    cliente = new Cliente();

                    SetearCliente(cliente);
                    clientesBL.Crear(cliente);

                    contexto.RegistrarEvento(Resources.ClientesForm_ClienteCreado, cliente.Nombre);
                }

                CargarClientes();
                LimpiarFormulario();
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 2
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                OrdenCompra       ordenCompra = ordenesCompraBL.Obtener(ordenCompraSeleccionada.ObtenerId());
                EstadoOrdenCompra nuevoEstado = EstadoOrdenCompra.Generada;

                if (ordenCompra.Estado == EstadoOrdenCompra.Generada)
                {
                    nuevoEstado = EstadoOrdenCompra.Aprobada;
                }
                else if (ordenCompra.Estado == EstadoOrdenCompra.Aprobada)
                {
                    nuevoEstado = EstadoOrdenCompra.Realizada;
                }

                ordenCompra.Estado = nuevoEstado;
                ordenesCompraBL.Actualizar(ordenCompra);

                contexto.RegistrarEvento(Resources.OrdenesCompraForm_OrdenCompraActualizada, ordenCompra.OrdenVenta.Cliente.Nombre);

                if (nuevoEstado == EstadoOrdenCompra.Realizada)
                {
                    CrearOrdenPago();
                }

                CargarOrdenesCompra();
                LimpiarFormulario();
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 3
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                bool     existeEmpleado = empleadosBL.Existe(txtCUIT.Text);
                Empleado empleado;

                if (existeEmpleado)
                {
                    empleado = empleadosBL.Obtener(txtCUIT.Text);

                    SetearEmpleado(empleado);
                    empleadosBL.Actualizar(empleado);

                    contexto.RegistrarEvento(Resources.EmpleadosForm_EmpleadoActualizado, empleado.Nombre);
                }
                else
                {
                    empleado = new Empleado();

                    SetearEmpleado(empleado);
                    empleadosBL.Crear(empleado);

                    contexto.RegistrarEvento(Resources.EmpleadosForm_EmpleadoCreado, empleado.Nombre);
                }

                CargarEmpleados();
                LimpiarFormulario();
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 4
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                bool      existeProveedor = proveedoresBL.Existe(txtCUIT.Text);
                Proveedor proveedor;

                if (existeProveedor)
                {
                    proveedor = proveedoresBL.ObtenerPorCUIT(txtCUIT.Text);

                    SetearProveedor(proveedor);
                    proveedoresBL.Actualizar(proveedor);

                    contexto.RegistrarEvento(Resources.ProveedoresForm_ProveedorActualizado, proveedor.Nombre);
                }
                else
                {
                    proveedor = new Proveedor();

                    SetearProveedor(proveedor);
                    proveedoresBL.Crear(proveedor);

                    contexto.RegistrarEvento(Resources.ProveedoresForm_ProveedorCreado, proveedor.Nombre);
                }

                CargarProveedores();
                LimpiarFormulario();
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 5
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                bool   existeReceta = recetasBL.Existe(txtNombre.Text);
                Receta receta;

                if (existeReceta)
                {
                    receta = recetasBL.Obtener(txtNombre.Text);

                    SetearReceta(receta);
                    recetasBL.Actualizar(receta);

                    contexto.RegistrarEvento(Resources.RecetasForm_RecetaActualizada, receta.Nombre);
                }
                else
                {
                    receta = new Receta();

                    SetearReceta(receta);
                    recetasBL.Crear(receta);

                    contexto.RegistrarEvento(Resources.RecetasForm_RecetaCreada, receta.Nombre);
                }

                CargarRecetas();
                LimpiarFormulario();
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 6
0
        void TsiBackup_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialogo = new SaveFileDialog
            {
                Filter = Resources.InicioForm_Datos_FiltroArchivos,
                Title  = Resources.InicioForm_Backup_Titulo
            };

            dialogo.ShowDialog();

            if (!string.IsNullOrEmpty(dialogo.FileName))
            {
                try
                {
                    if (contexto.Negocio.Backup(dialogo.FileName))
                    {
                        contexto.MostrarEvento(Resources.InicioForm_Backup_Realizado, dialogo.FileName);
                    }
                    else
                    {
                        contexto.RegistrarError(Resources.InicioForm_Backup_Error);
                    }
                }
                catch (Exception ex)
                {
                    contexto.RegistrarError(ex, Resources.InicioForm_Backup_Error);
                }
            }
        }
Esempio n. 7
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                bool    existeUsuario = usuariosBL.Existe(txtUsuario.Text);
                Usuario usuario;

                if (existeUsuario)
                {
                    usuario = usuariosBL.Obtener(txtUsuario.Text);

                    SetearUsuario(usuario, esActualizacion: true);
                    usuariosBL.Actualizar(usuario);

                    contexto.RegistrarEvento(Resources.UsuariosForm_UsuarioActualizado, usuario.Nombre);
                }
                else
                {
                    usuario = new Usuario();

                    SetearUsuario(usuario, esActualizacion: false);
                    usuariosBL.Crear(usuario);

                    contexto.RegistrarEvento(Resources.UsuariosForm_UsuarioCreado, usuario.Nombre);
                }

                CargarUsuarios();
                LimpiarFormulario();
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 8
0
        void BtnIngresar_Click(object sender, EventArgs e)
        {
            try
            {
                string  nombreUsuario = txtUsuario.Text;
                Usuario usuario       = usuariosBL.Obtener(nombreUsuario);

                if (!modoReset && usuario.CambiarPassword)
                {
                    lblNuevoPassword.Visible = true;
                    txtNuevoPassword.Visible = true;
                    txtNuevoPassword.Focus();
                    lblMensaje.Text = Resources.LoginForm_CambiarPassword;
                    modoReset       = true;

                    return;
                }

                string password;

                if (modoReset)
                {
                    string nuevoPassword = usuariosBL.CrearPasswordHash(txtNuevoPassword.Text);

                    usuario.Password        = nuevoPassword;
                    usuario.CambiarPassword = false;
                    usuariosBL.Actualizar(usuario);

                    password  = nuevoPassword;
                    modoReset = false;

                    contexto.RegistrarEvento(Resources.LoginForm_PasswordReseteado);
                }
                else
                {
                    password = usuariosBL.CrearPasswordHash(txtPassword.Text);
                }

                bool autenticado = usuariosBL.Autenticar(nombreUsuario, password);

                if (autenticado)
                {
                    contexto.RegistrarEvento(Resources.LoginForm_UsuarioAutenticado);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    contexto.RegistrarError(Resources.LoginForm_ErrorAutenticacion);
                }
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex, Resources.LoginForm_ErrorAutenticacion);
            }
        }
Esempio n. 9
0
        void CargarBitacora()
        {
            try
            {
                IEnumerable <Bitacora> bitacoras = bitacoraBL.Obtener();

                CargarBitacora(bitacoras);
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 10
0
        void CargarClientes()
        {
            try
            {
                IEnumerable <Cliente> clientes = clientesBL.ObtenerActivos();

                cboClientes.Items.Add("");

                foreach (Cliente cliente in clientes)
                {
                    cboClientes.Items.Add(cliente.Nombre);
                }
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 11
0
        void BtnCobrada_Click(object sender, EventArgs e)
        {
            try
            {
                Factura factura = facturasBL.Obtener(facturaSeleccionada.ObtenerId());

                factura.Cobrada = true;
                facturasBL.Actualizar(factura);

                CargarFacturas();
                LimpiarFormulario();

                contexto.RegistrarEvento(Resources.FacturasForm_FacturaCobrada, factura.OrdenVenta.Cliente.Nombre);
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 12
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                bool       existeOrdenVenta = false;
                OrdenVenta ordenVenta;

                if (ordenVentaSeleccionada != null)
                {
                    existeOrdenVenta = ordenesVentaBL.Existe(ordenVentaSeleccionada.ObtenerId());
                }

                if (existeOrdenVenta)
                {
                    ordenVenta = ordenesVentaBL.Obtener(ordenVentaSeleccionada.ObtenerId());
                    SetearOrdenVenta(ordenVenta);
                    ordenesVentaBL.Actualizar(ordenVenta);

                    contexto.RegistrarEvento(Resources.OrdenesVentaForm_OrdenVentaActualizada, ordenVenta.Cliente.Nombre);
                }
                else
                {
                    ordenVenta = Crear();
                    ordenesVentaBL.Crear(ordenVenta);

                    contexto.RegistrarEvento(Resources.OrdenesVentaForm_OrdenVentaCreada, ordenVenta.Cliente.Nombre);
                }

                if ((!existeOrdenVenta || !ordenVentaSeleccionada.Aprobada) && ordenVenta.Aprobada)
                {
                    CrearFactura();
                    CrearOrdenCompra();
                }

                CargarOrdenesVenta();
                LimpiarFormulario();
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 13
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                IEnumerable <ItemOrdenPagoPresentacion> itemsOrdenesPagoPresentacion = (IEnumerable <ItemOrdenPagoPresentacion>)grvItems.DataSource;
                OrdenPago ordenPago = ordenesPagoBL.Obtener(ordenPagoSeleccionada.ObtenerId());

                foreach (ItemOrdenPago item in ordenPago.Items)
                {
                    ItemOrdenPagoPresentacion itemOrdenPagoPresentacion = null;

                    foreach (ItemOrdenPagoPresentacion itemPresentacion in itemsOrdenesPagoPresentacion)
                    {
                        if (itemPresentacion.Ingrediente == item.ItemOrdenCompra.Ingrediente.Nombre)
                        {
                            itemOrdenPagoPresentacion = itemPresentacion;
                            break;
                        }
                    }

                    if (itemOrdenPagoPresentacion != null)
                    {
                        item.Precio = decimal.Parse(itemOrdenPagoPresentacion.Precio);
                    }
                }

                ordenPago.Pagada = chkPagada.Checked;
                ordenesPagoBL.Actualizar(ordenPago);

                CargarOrdenesPago();
                LimpiarFormulario();

                contexto.RegistrarEvento(Resources.OrdenesPagoForm_OrdenPagoActualizada, ordenPago.Proveedor.Nombre);
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 14
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Receta            receta            = recetasBL.Obtener(Receta.Nombre);
                IngredienteReceta ingredienteReceta = null;

                foreach (IngredienteReceta ingrediente in receta.Ingredientes)
                {
                    if (ingrediente.Ingrediente.Nombre == txtIngrediente.Text)
                    {
                        ingredienteReceta = ingrediente;
                        break;
                    }
                }

                if (ingredienteReceta == null)
                {
                    ingredienteReceta = new IngredienteReceta();

                    SetearIngrediente(ingredienteReceta);
                    receta.Ingredientes.Add(ingredienteReceta);
                }
                else
                {
                    SetearIngrediente(ingredienteReceta);
                }

                recetasBL.Actualizar(receta);
                CargarIngredientes();
                LimpiarFormulario();

                contexto.RegistrarEvento(Resources.IngredientesForm_RecetaActualizada, receta.Nombre);
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }
Esempio n. 15
0
        void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Ingrediente       ingrediente       = ingredientesBL.Obtener(lblIngrediente.Text);
                PrecioIngrediente precioIngrediente = preciosIngredientesBL.Obtener(ingrediente);

                precioIngrediente.Precio   = decimal.Parse(txtPrecio.Text);
                precioIngrediente.Cantidad = decimal.Parse(txtCantidad.Text);
                precioIngrediente.Unidad   = (UnidadMedida)Enum.Parse(typeof(UnidadMedida), cboUnidad.SelectedItem.ToString());

                preciosIngredientesBL.Actualizar(precioIngrediente);
                recetasBL.ActualizarRecetasSinPrecio();
                CargarPrecios();
                LimpiarFormulario();

                contexto.RegistrarEvento(Resources.PreciosForm_ListaActualizada, ingrediente.Nombre);
            }
            catch (Exception ex)
            {
                contexto.RegistrarError(ex);
            }
        }