Exemple #1
0
 private void btn_borrarProducto_Click(object sender, RoutedEventArgs e)
 {
     if (datagridProducto.SelectedItem != null)
     {
         if (MsgPregunta("¿Seguro que quieres eliminar este producto?", "Eliminar"))
         {
             try
             {
                 string rutaImagen = Environment.CurrentDirectory + "\\imagenes\\productos\\" + prod.RutaImagen;
                 u.ProductoRepository.Delete(prod);
                 refreshDatagrids();
                 Load_Categorias();
             }
             catch (Exception er)
             {
                 Console.WriteLine(er);
                 AmRoMessageBox.ShowDialog("Error al intentar borrar");
             }
         }
     }
     else
     {
         AmRoMessageBox.ShowDialog("Selecciona un producto a borrar");
     }
 }
Exemple #2
0
        private void btn_borrarCategoria_Click(object sender, RoutedEventArgs e)
        {
            if (datagridCategorias.SelectedItem != null)
            {
                if (MsgPregunta("¿Seguro que quieres eliminar esta categoría?", "Eliminar"))
                {
                    try
                    {
                        string rutaImagen = Environment.CurrentDirectory + "\\imagenes\\categorias\\" + cat.RutaImagen;

                        u.CategoriaRepository.Delete(cat);
                        refreshDatagrids();
                        Load_Categorias();
                        refreshComboBoxCategorias();
                        borrarCamposCategorias();
                    }
                    catch (Exception er)
                    {
                        Console.WriteLine(er);
                        AmRoMessageBox.ShowDialog("Error al intentar borrar");
                    }
                }
            }
            else
            {
                AmRoMessageBox.ShowDialog("Selecciona una categoría a borrar");
            }
        }
Exemple #3
0
        private void btn_log_Click(object sender, RoutedEventArgs e)
        {
            //logear usuario
            Console.WriteLine("Pin: " + PasswordBox.Password);
            bool valida = u.UsuarioRepository.GetAll().Any(c => c.UsuarioId.ToString().Equals(idUsuario) && c.Pin.Equals(PasswordBox.Password));

            if (valida)
            {
                ActiveUsr = u.UsuarioRepository.Get().SingleOrDefault(c => c.UsuarioId.ToString().Equals(idUsuario));
                habilitarPaneles(ActiveUsr.TipoUsuario);
                tab_tpv.IsSelected = true;
                resetCaja();
                chip_usuarioVenta.Content = ActiveUsr.Nombre + " " + ActiveUsr.Apellidos;
                string rutaImagen = Environment.CurrentDirectory + "\\imagenes\\usuarios\\" + ActiveUsr.RutaImagen;
                if (File.Exists(rutaImagen))
                {
                    chip_usuarioVenta.IconForeground = Brushes.Transparent;
                    chip_usuarioVenta.Icon           = new ImageBrush(new BitmapImage(new Uri(rutaImagen, UriKind.Relative)));
                    chip_usuarioVenta.IconBackground = new ImageBrush(new BitmapImage(new Uri(rutaImagen, UriKind.Relative)));
                }
            }
            else
            {
                AmRoMessageBox.ShowDialog("Pin incorrecto");
            }
        }
Exemple #4
0
 private void btn_borrarUsuario_Click(object sender, RoutedEventArgs e)
 {
     if (datagridUsuarios.SelectedItem != null)
     {
         if ((Usuario)datagridUsuarios.SelectedItem != ActiveUsr)
         {
             if (MsgPregunta("¿Seguro que quieres eliminar este usuario?", "Eliminar"))
             {
                 try
                 {
                     u.UsuarioRepository.Delete(usr);
                     refreshDatagrids();
                     Load_Usuarios();
                     limpiarCamposUsuario();
                 }
                 catch (Exception er)
                 {
                     Console.WriteLine(er);
                     AmRoMessageBox.ShowDialog("Error al intentar borrar", "Error");
                 }
             }
         }
         else
         {
             AmRoMessageBox.ShowDialog("No puede borrar el usuario, está actualmente activo", "Error");
         }
     }
     else
     {
         AmRoMessageBox.ShowDialog("Selecciona un usuario a borrar", "Error");
     }
 }
Exemple #5
0
        private void btn_guardarProducto_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(imagen))
            {
                imagen = "default.jpg";
            }

            try
            {
                int     iva   = 0;
                decimal price = 0;
                int     stock = 0;
                prod.Nombre      = txt_nombreProducto.Text;
                prod.Descripcion = txt_descripcionProducto.Text;
                prod.RutaImagen  = imagen;
                Int32.TryParse(comboboxIVA.Text, out iva);
                Decimal.TryParse(txt_precioProducto.Text.Replace('.', ','), out price);
                Int32.TryParse(txt_StockInicial.Text, out stock);
                prod.Iva       = iva;
                prod.Precio    = price;
                prod.Stock     = stock;
                prod.Categoria = (Categoria)comboBox_CategoriasProducto.SelectedItem;
            }
            catch (Exception er) { Console.WriteLine(er); }

            if (validado(prod))
            {
                if (create)
                {
                    if (!u.ProductoRepository.GetAll().Any(c => c.Nombre.Equals(prod.Nombre)))
                    {
                        u.ProductoRepository.Create(prod);
                        AmRoMessageBox.ShowDialog("Guardado correctamente");
                        deshabilitarCamposProductos();
                        limiparCamposProductos();
                        img_Producto.Source = null;
                        Load_Categorias();
                        refreshDatagrids();
                    }
                    else
                    {
                        AmRoMessageBox.ShowDialog("Ya existe un producto con el mismo nombre");
                    }
                }
                else
                {
                    u.ProductoRepository.Update(prod);
                    AmRoMessageBox.ShowDialog("Guardado correctamente");
                    deshabilitarCamposProductos();
                    limiparCamposProductos();
                    img_Producto.Source = null;
                    Load_Categorias();
                    refreshDatagrids();
                }
            }
        }
Exemple #6
0
        private void btn_guardarCategoria_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(imagen))
            {
                imagen = "default.jpg";
            }
            try
            {
                cat.Nombre      = txtboxNombreCategoria.Text;
                cat.Descripcion = txtboxDescripcionCategoria.Text;
                cat.RutaImagen  = imagen;
            }
            catch (Exception)
            {
            }

            if (validado(cat))
            {
                if (create)
                {
                    if (!u.CategoriaRepository.GetAll().Any(c => c.Nombre.Equals(cat.Nombre)))
                    {
                        u.CategoriaRepository.Create(cat);

                        AmRoMessageBox.ShowDialog("Guardado correctamente");
                        deshabilitarCamposCategorias();
                        refreshComboBoxCategorias();
                        refreshDatagrids();
                        borrarCamposCategorias();
                        Load_Categorias();
                    }
                    else
                    {
                        AmRoMessageBox.ShowDialog("Ya existe una categoría con el mismo nombre");
                    }
                }
                else
                {
                    u.CategoriaRepository.Update(cat);

                    AmRoMessageBox.ShowDialog("Guardado correctamente");
                    deshabilitarCamposCategorias();
                    refreshComboBoxCategorias();
                    refreshDatagrids();
                    borrarCamposCategorias();
                    Load_Categorias();
                }
            }
        }
Exemple #7
0
        private void btn_guardarUsuario_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(imagen))
            {
                imagen = "default.jpg";
            }

            try
            {
                usr.Nombre      = txt_nombreUsuario.Text;
                usr.Apellidos   = txt_apellidosUsuario.Text;
                usr.RutaImagen  = imagen;
                usr.Login       = txt_loginUsuario.Text;
                usr.Pin         = txt_pinUsuario.Text;
                usr.Email       = txt_emailUsuario.Text;
                usr.TipoUsuario = comboBox_TipoUsuario.Text;
            }
            catch (Exception er) { Console.WriteLine(er); }

            if (validado(usr))
            {
                if (create)
                {
                    if (!u.UsuarioRepository.GetAll().Any(c => c.Login.Equals(usr.Login)))
                    {
                        u.UsuarioRepository.Create(usr);
                        AmRoMessageBox.ShowDialog("Guardado correctamente");
                        deshabilitarCamposUsuario();
                        limpiarCamposUsuario();
                        Load_Usuarios();
                        refreshDatagrids();
                    }
                    else
                    {
                        AmRoMessageBox.ShowDialog("Ya existe un usuario con el mismo Login");
                    }
                }
                else
                {
                    u.UsuarioRepository.Update(usr);
                    AmRoMessageBox.ShowDialog("Guardado correctamente");
                    deshabilitarCamposUsuario();
                    limpiarCamposUsuario();
                    Load_Usuarios();
                    refreshDatagrids();
                }
            }
        }
Exemple #8
0
        public bool MsgPregunta(string Mensaje, string Titulo)
        {
            var messageBox = new AmRoMessageBox
            {
                Background            = "#333333",
                TextColor             = "#ffffff",
                IconColor             = "#3399ff",
                RippleEffectColor     = "#000000",
                ClickEffectColor      = "#1F2023",
                ShowMessageWithEffect = true,
                EffectArea            = this,
                ParentWindow          = this
            };
            var result = messageBox.Show(Mensaje, Titulo, AmRoMessageBoxButton.OkCancel);

            return(result == AmRoMessageBoxResult.Ok);
        }
Exemple #9
0
        public MainWindow()
        {
            InitializeComponent();

            _messageBox = new AmRoMessageBox
            {
                Background            = "#333",
                TextColor             = "#fff",
                RippleEffectColor     = "#000",
                ClickEffectColor      = "#1F2023",
                ShowMessageWithEffect = true,
                EffectArea            = this,
                ParentWindow          = this,
                IconColor             = "#3399ff",
                CaptionFontSize       = 16,
                MessageFontSize       = 14
            };
        }
Exemple #10
0
 void New_Ticket()
 {
     if (tv.LineaVenta.Count > 0)
     {
         tv.LineaVenta.ToList().ForEach(i => i.Producto.Stock -= i.Unidades);
         tv.Usuario   = ActiveUsr;
         tv.FechaHora = DateTime.Now;
         u.TicketVentaRepository.Create(tv);
         ticket ventanaTicket = new ticket(tv);
         resetCaja();
         string rutaImagen = Environment.CurrentDirectory + "/imagenes/ticketBackground.jpg";
         ventanaTicket.Background = new ImageBrush(new BitmapImage(new Uri(rutaImagen, UriKind.Relative)));
         ventanaTicket.ShowDialog();
     }
     else
     {
         AmRoMessageBox.ShowDialog("No tienes lineas de venta");
     }
 }
Exemple #11
0
        private Boolean validado(Object obj)
        {
            ValidationContext validationContext = new ValidationContext(obj, null, null);
            List <System.ComponentModel.DataAnnotations.ValidationResult> errors = new List <System.ComponentModel.DataAnnotations.ValidationResult>();

            Validator.TryValidateObject(obj, validationContext, errors, true);
            if (errors.Count() > 0)
            {
                string mensageErrores = string.Empty;
                foreach (var error in errors)
                {
                    error.MemberNames.First();

                    mensageErrores += error.ErrorMessage + Environment.NewLine;
                }
                AmRoMessageBox.ShowDialog(mensageErrores, @"/!\ERROR/!\");
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #12
0
 private void BtnStaticMessageBox4_OnClick(object sender, RoutedEventArgs e)
 {
     AmRoMessageBox.ShowDialog("This is a sample message", "Sample Caption",
                               AmRoMessageBoxButton.OkCancel, AmRoMessageBoxIcon.Success);
 }
Exemple #13
0
 private void BtnStaticMessageBox3_OnClick(object sender, RoutedEventArgs e)
 {
     AmRoMessageBox.ShowDialog("This is a sample message", "Sample Caption", AmRoMessageBoxButton.YesNo);
 }
Exemple #14
0
 private void BtnStaticMessageBox1_OnClick(object sender, RoutedEventArgs e)
 {
     AmRoMessageBox.ShowDialog("This is a sample message");
 }