示例#1
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (dgvProductos.SelectedRows.Count > 0)
     {
         bool estado = MessageBox.Show("Esta seguro que desea borrar este producto?.", "Esta seguro?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes;
         if (estado)
         {
             foreach (DataGridViewRow item in this.dgvProductos.SelectedRows)
             {
                 dgvProductos.Rows.RemoveAt(item.Index);
                 count_fila--;
             }
         }
     }
     else
     {
         MessageTimer.Start();
         lblSuccess.Visible = false;
         lblError.Text      = "*Debe seleccionar un producto de la tabla.";
         lblError.Visible   = true;
     }
     cmbProductos.SelectedItem = null;
     cmbProductos.Text         = "";
     nudCantidad.Value         = 0;
 }
示例#2
0
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvProductos.SelectedRows.Count > 0)
         {
             ProductoLogica logica = new ProductoLogica();
             bool           estado = MessageBox.Show("Esta seguro que desea borrar este producto?.", "Esta seguro?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes;
             if (estado)
             {
                 int id = Convert.ToInt32(dgvProductos.CurrentRow.Cells[0].Value);
                 logica.Borrar(id);
             }
             dgvProductos.DataSource = logica.SeleccionarTodos();
             lblSuccess.Text         = "*Se eliminó satisfactoriamente.";
             lblSuccess.Visible      = true;
             MessageTimer.Start();
         }
         else
         {
             MessageBox.Show("Debe seleccionar un producto de la tabla.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         lblError.Text    = "*" + ex.Message;
         lblError.Visible = true;
         MessageTimer.Start();
     }
 }
示例#3
0
        public HawkwindSpeak()
        {
            Name = "Hawkwind";

            _Timer = new MessageTimer(this);
            _Timer.Start();
        }
示例#4
0
        public void Send()
        {
            var message = OutgoingMessages.Take(TokenSource.Token);

            MessageWaitHandle.WaitOne();
            TwitchClient.SendMessage(message.Msg);
            MessageWaitHandle.Reset();
            MessageTimer.Start();
        }
示例#5
0
        public override void OnMovement(Mobile m, Point3D oldLocation)
        {
            if (m.AccessLevel > AccessLevel.Player && m.Hidden)
            {
                return;
            }

            if (m is PlayerMobile && m.InRange(this, 10) && _Timer == null)
            {
                _Timer = new MessageTimer(this);
                _Timer.Start();
            }
        }
示例#6
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            int              id = 0;
            Producto         p;
            ProductoLogica   logica  = new ProductoLogica();
            InventarioLogica logica2 = new InventarioLogica();

            if (dgvProductos.Rows.Count > 0)
            {
                // se crea el encabezado de la salida de productos
                logica2.CrearSalidaProductos(usuario);
                foreach (DataGridViewRow item in dgvProductos.Rows)
                {
                    id          = Convert.ToInt32(item.Cells[0].Value.ToString());
                    p           = logica.SeleccionarPorId(id);
                    p.cantidad -= Convert.ToInt32(item.Cells[6].Value.ToString());
                    logica.Actualizar(p);
                    Inventario inventario = new Inventario();
                    inventario.producto = p;
                    inventario.cantidad = Convert.ToInt32(item.Cells[6].Value.ToString());

                    // se crea el detalle de la salida de productos
                    logica2.SalidaProductos(inventario);
                }

                dgvProductos.Rows.Clear();
                count_fila = 0;
                MessageTimer.Start();
                lblError.Visible   = false;
                lblSuccess.Text    = "*Se ha guardado la salida de productos.";
                lblSuccess.Visible = true;
            }
            else
            {
                MessageTimer.Start();
                lblSuccess.Visible = false;
                lblError.Text      = "*Debe agregar productos de salida.";
                lblError.Visible   = true;
            }
        }
示例#7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                RolLogica     logicaRoll    = new RolLogica();
                UsuarioLogica logicaUsuario = new UsuarioLogica();


                Usuario usuario = new Usuario();

                usuario.nombre     = txtNombre.Text;
                usuario.usuario    = txtUsuario.Text;
                usuario.contrasena = txtContrasena.Text;
                usuario.roll       = logicaRoll.SeleccionarPorId(cmbRoll.SelectedIndex);

                Usuario u = logicaUsuario.SeleccionarPorId(Convert.ToInt32(txtId.Text));

                if (u != null)
                {
                    usuario.id = Convert.ToInt32(txtId.Text);
                    logicaUsuario.Actualizar(usuario);
                }
                else
                {
                    logicaUsuario.Crear(usuario);
                }
                dgvUsuarios.DataSource          = logicaUsuario.SeleccionarTodos();
                dgvUsuarios.CurrentRow.Selected = false;
                MessageTimer.Start();
                lblSuccess.Text    = "*Guardado con éxito";
                lblSuccess.Visible = true;
            }
            catch (Exception ex)
            {
                lblError.Text    = "*" + ex.Message;
                lblError.Visible = true;
                MessageTimer.Start();
            }
        }
示例#8
0
 public void StartMessageWatching()
 {
     MessageTimer.Start();
 }
示例#9
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            bool existe   = false;
            int  num_fila = 0;

            ProductoLogica logica = new ProductoLogica();

            if (cmbProductos.SelectedItem == null)
            {
                lblSuccess.Visible = false;
                MessageTimer.Start();
                lblError.Text    = "*Debe seleccionar un producto.";
                lblError.Visible = true;
            }

            Producto p        = logica.SeleccionarPorId(((Producto)cmbProductos.SelectedItem).id);
            int      cantidad = Convert.ToInt32(nudCantidad.Value);

            if (count_fila == 0)
            {
                dgvProductos.Rows.Add(p.id, p.nombre, p.marca, p.pesoUnidad, p.precio, p.cantidad, cantidad);
                int cantidadFinal = Convert.ToInt32(dgvProductos.Rows[count_fila].Cells[5].Value) + cantidad;
                dgvProductos.Rows[count_fila].Cells[7].Value = cantidadFinal;
                count_fila++;
                MessageTimer.Start();
                lblError.Visible   = false;
                lblSuccess.Text    = "*Agregado con éxito.";
                lblSuccess.Visible = true;
            }
            else
            {
                foreach (DataGridViewRow item in dgvProductos.Rows)
                {
                    if (item.Cells[0].Value.ToString() == (cmbProductos.SelectedIndex + 1).ToString())
                    {
                        existe   = true;
                        num_fila = item.Index;
                    }
                }

                if (existe)
                {
                    MessageTimer.Start();
                    lblSuccess.Visible = false;
                    lblError.Text      = "*Éste producto ya se encuentra agregado.";
                    lblError.Visible   = true;
                }
                else
                {
                    dgvProductos.Rows.Add(p.id, p.nombre, p.marca, p.pesoUnidad, p.precio, p.cantidad, cantidad);
                    int cantidadFinal = Convert.ToInt32(dgvProductos.Rows[count_fila].Cells[5].Value) + cantidad;
                    dgvProductos.Rows[count_fila].Cells[7].Value = cantidadFinal;
                    count_fila++;
                    MessageTimer.Start();
                    lblError.Visible   = false;
                    lblSuccess.Text    = "*Agregado con éxito.";
                    lblSuccess.Visible = true;
                }
            }

            cmbProductos.SelectedItem        = null;
            cmbProductos.Text                = "";
            nudCantidad.Value                = 0;
            dgvProductos.CurrentRow.Selected = false;
        }
示例#10
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //---------------------------------------\\
                // ACTUALIZAR O CREAR ROLES O CATEGORÍAS \\
                //---------------------------------------\\

                ////// ROLES //////
                if (cmbTipo.SelectedIndex == 2)
                {
                    RolLogica logicaRol = new RolLogica();
                    // Nuevo Rol
                    Rol rol = new Rol();
                    rol.nombre = txtNombre.Text;

                    // Actualizar o Crear Rol
                    Rol r = logicaRol.SeleccionarPorId(Convert.ToInt32(txtId.Text));
                    if (r != null)
                    {
                        rol.id = Convert.ToInt32(txtId.Text);
                        logicaRol.Actualizar(rol);
                        dgvRoles.DataSource = logicaRol.SeleccionarTodos();
                    }
                    else
                    {
                        logicaRol.Crear(rol);
                        dgvRoles.DataSource = logicaRol.SeleccionarTodos();
                    }
                }
                else
                {
                    ////// CATEGORÍAS //////
                    if (cmbTipo.SelectedIndex == 1)
                    {
                        CategoriaLogica logicaCategoria = new CategoriaLogica();
                        // Nueva Categoría
                        Categoria categoria = new Categoria();
                        categoria.nombre = txtNombre.Text;

                        // Actualizar o Crear Categoría
                        Categoria c = logicaCategoria.SeleccionarPorId(Convert.ToInt32(txtId.Text));


                        if (c != null)
                        {
                            categoria.id = Convert.ToInt32(txtId.Text);
                            logicaCategoria.Actualizar(categoria);
                            dgvCategorias.DataSource = logicaCategoria.SeleccionarTodos();
                        }
                        else
                        {
                            logicaCategoria.Crear(categoria);
                            dgvCategorias.DataSource = logicaCategoria.SeleccionarTodos();
                        }
                    }
                    else
                    {
                        MessageTimer.Start();
                        lblError.Text    = "*Debe seleccionar un tipo";
                        lblError.Visible = true;
                    }
                }

                cmbTipo.Enabled = true;
                MessageTimer.Start();
                lblSuccess.Text                   = "*Guardado con éxito";
                lblSuccess.Visible                = true;
                txtId.Text                        = "0";
                cmbTipo.Enabled                   = true;
                txtNombre.Text                    = "";
                cmbTipo.SelectedIndex             = 0;
                dgvRoles.CurrentRow.Selected      = false;
                dgvCategorias.CurrentRow.Selected = false;
            }
            catch (Exception ex)
            {
                lblError.Text    = "*" + ex.Message;
                lblError.Visible = true;
                MessageTimer.Start();
            }
        }
示例#11
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                CategoriaLogica logicaCategoria = new CategoriaLogica();
                ProductoLogica  logicaProducto  = new ProductoLogica();


                Producto producto = new Producto();

                producto.nombre = txtNombre.Text;
                producto.marca  = txtMarca.Text;

                string unidad = cmbMedida.SelectedIndex == 0 ? "Kg" :
                                cmbMedida.SelectedIndex == 1 ? "g" :
                                cmbMedida.SelectedIndex == 2 ? "mL" :
                                cmbMedida.SelectedIndex == 3 ? "L" :
                                cmbMedida.SelectedIndex == 4 ? "oz" : "Kg";

                int     cantidad    = 0;
                int     minCantidad = 0;
                decimal precio      = 0m;
                decimal peso        = 0m;

                if (!int.TryParse(txtMinCantidad.Text, out minCantidad) ||
                    !int.TryParse(txtCantidad.Text, out cantidad) ||
                    !decimal.TryParse(txtPrecio.Text, out precio) ||
                    !decimal.TryParse(txtPeso.Text, out peso))
                {
                    lblError.Text = "*Debe ser un valor numérico."; lblError.Visible = true;
                }

                producto.peso        = peso;
                producto.unidad      = unidad;
                producto.cantidad    = cantidad;
                producto.minCantidad = minCantidad;
                producto.precio      = precio;
                producto.categoria   = logicaCategoria.SeleccionarPorId(cmbArea.SelectedIndex);

                Producto p = logicaProducto.SeleccionarPorId(Convert.ToInt32(txtId.Text));

                if (p != null)
                {
                    producto.id = Convert.ToInt32(txtId.Text);
                    logicaProducto.Actualizar(producto);
                }
                else
                {
                    logicaProducto.Crear(producto);
                }


                dgvProductos.DataSource          = logicaProducto.SeleccionarTodos();
                dgvProductos.CurrentRow.Selected = false;
                MessageTimer.Start();
                lblSuccess.Text    = "*Guardado con éxito.";
                lblSuccess.Visible = true;
                btnLimpiar_Click(this, null);
            }
            catch (Exception ex)
            {
                lblError.Text    = "*" + ex.Message;
                lblError.Visible = true;
                MessageTimer.Start();
            }
        }