Beispiel #1
0
 private void txtNuevaCategoria_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)13)
     {
         if (txtNuevaCategoria.Text.Equals("") | txtNuevaCategoria.Text.Equals(" "))
         {
             MessageBox.Show("Categoria Vacia", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             clsCategorias      obj  = new clsCategorias();
             clsDatosInventario obj2 = new clsDatosInventario();
             obj.Nombre = txtNuevaCategoria.Text;
             obj2.AgregarCategoria(obj);
             MessageBox.Show("Se agrego categoria");
             txtNuevaCategoria.Text    = "";
             txtNuevaCategoria.Visible = false;
             lblNuevaCategoria.Visible = false;
             cmbCategoria.Items.Clear();
             clsDatosInventario o = new clsDatosInventario();
             var lista            = o.listaCategorias();
             for (int i = 0; i < lista.Count; i++)
             {
                 cmbCategoria.Items.Insert(i, lista[i].Nombre);
             }
         }
     }
 }
Beispiel #2
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            // CREA LOS OBJETOS
            clsInventario      objProducto        = new clsInventario();
            clsDatosInventario objDatosInventario = new clsDatosInventario();

            // LEE LOS DATOS DE LAS CAJAS Y LOS GUARDA EN EL OBJETO
            objProducto.Clave       = txtClave.Text;
            objProducto.Nombre      = txtNombre.Text;
            objProducto.Precio      = Convert.ToInt32(txtPrecio.Text);
            objProducto.Categoria   = objDatosInventario.getIdCategoria(cmbCategoria.Text);
            objProducto.Existencia  = Convert.ToInt32(txtExistencia.Text);
            objProducto.Descripcion = txtDescripcion.Text;
            objProducto.Idusuario   = objDatosInventario.getIdEmpleado(Program.nombre);
            objProducto.RutaImg     = rutaFinal;
            // MUESTRA MENSAJE DE CONFIRMACION
            objDatosInventario.ModificarProducto(objProducto);
            MessageBox.Show("Producto Modificado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btnGuardar.Visible   = true;
            btnModificar.Visible = false;
            txtClave.Text        = "";
            txtNombre.Text       = "";
            cmbCategoria.Text    = "";
            txtPrecio.Text       = "";
            txtExistencia.Text   = "";
            txtDescripcion.Text  = "";
            pbProducto.Image     = null;
            verProductos();
        }
Beispiel #3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                rutaFinal = @"C:\ImagenesProductos\" + Direccion.Substring(Direccion.LastIndexOf(@"\"));
                clsInventario      objProducto        = new clsInventario();
                clsDatosInventario objDatosInventario = new clsDatosInventario();
                //Se leen los datos de los txt
                objProducto.Clave       = txtClave.Text;
                objProducto.Nombre      = txtNombre.Text;
                objProducto.Precio      = Convert.ToInt32(txtPrecio.Text);
                objProducto.Categoria   = objDatosInventario.getIdCategoria(cmbCategoria.Text);
                objProducto.Existencia  = Convert.ToInt32(txtExistencia.Text);
                objProducto.Descripcion = txtDescripcion.Text;
                objProducto.Idusuario   = objDatosInventario.getIdEmpleado(Program.nombre);
                objProducto.RutaImg     = rutaFinal;
                // INSERTA AL PRODUCTO MEDIANTE EL MÉTODO
                objDatosInventario.AgregarProducto(objProducto);
                // MUESTRA MENSAJE DE CONFIRMACION
                MessageBox.Show("Agregado", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //creas carpeta que contendra las imagenes de los productos



                if (Directory.Exists(@"C:\ImagenesProductos"))
                {
                    //MessageBox.Show("Capeta ya existe");
                    mycomputer.FileSystem.MoveFile(Direccion, rutaFinal);
                }
                else
                {
                    // MessageBox.Show("No existe Carpeta Creando..............");
                    Directory.CreateDirectory(@"C:\ImagenesProductos\");
                    mycomputer.FileSystem.MoveFile(Direccion, rutaFinal);
                }


                txtClave.Text       = "";
                txtNombre.Text      = "";
                cmbCategoria.Text   = "";
                txtPrecio.Text      = "";
                txtExistencia.Text  = "";
                txtDescripcion.Text = "";
                pbProducto.Image    = null;
                verProductos();
            }
            catch (Exception ex) {
                MessageBox.Show("Campos Vacios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #4
0
        private void Inventario_Load(object sender, EventArgs e)
        {
            lblNuevaCategoria.Visible = false;
            txtNuevaCategoria.Visible = false;
            clsDatosInventario o = new clsDatosInventario();
            var lista            = o.listaCategorias();

            btnModificar.Visible = false;
            verProductos();
            dataGridView1.AllowUserToAddRows = false;

            rbnNombre.Checked = true;

            for (int i = 0; i < lista.Count; i++)
            {
                cmbCategoria.Items.Insert(i, lista[i].Nombre);
            }
        }
Beispiel #5
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == dataGridView1.Columns["Modificar"].Index && e.RowIndex >= 0)
            {
                btnGuardar.Visible   = false;
                btnModificar.Visible = true;
                clsInventario      objinv   = new clsInventario();
                clsDatosInventario objdatos = new clsDatosInventario();
                DataGridViewRow    fila     = dataGridView1.Rows[e.RowIndex];
                objinv.Clave = Convert.ToString(fila.Cells["Clave"].Value);
                objdatos.buscarProducto(ref objinv);


                txtClave.Text            = objinv.Clave;
                txtNombre.Text           = objinv.Nombre;
                txtPrecio.Text           = Convert.ToString(objinv.Precio);
                cmbCategoria.Text        = objdatos.getnombreCategoria(objinv.Categoria);
                txtExistencia.Text       = Convert.ToString(objinv.Existencia);
                txtDescripcion.Text      = objinv.Descripcion;
                pbProducto.ImageLocation = objinv.RutaImg;
            }
            else
            {
                // CREA LOS OBJETOS
                clsDatosInventario datos    = new clsDatosInventario();
                clsInventario      producto = new clsInventario();
                DialogResult       result   = MessageBox.Show("Seguro que deseas eliminar?", "Movistar.....", MessageBoxButtons.YesNoCancel);
                // REFRESCA LOS DATOS Y MUESTRA EL MENSAJE "ELIMINADO"
                if (result == DialogResult.Yes)
                {
                    DataGridViewRow fila = dataGridView1.Rows[e.RowIndex];
                    producto.Clave = Convert.ToString(fila.Cells["Clave"].Value);
                    datos.Eliminar(producto);

                    //verProductos();
                    MessageBox.Show("Producto Eliminado");
                    verProductos();
                }
            }
        }
Beispiel #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (txtRecibi.Text.Equals("") || VentaList.Items.Equals("") || txtTotal.Text.Equals("") || txtCambio.Text.Equals(""))
     {
         MessageBox.Show("Llene primero el campo de Recibo", "Datos ingresados incorrectos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         clsDatosInventario inventarioo  = new clsDatosInventario();
         clsDatosVenta      objDao       = new clsDatosVenta();
         clsVenta           objSolicitud = new clsVenta();
         clsDVenta          objDVenta    = new clsDVenta();
         objSolicitud.Folio     = Convert.ToInt32(lblFolio.Text);
         objSolicitud.IdUusario = inventarioo.getIdEmpleado(Program.nombre);
         objSolicitud.Fecha     = dtpFecha.Text;
         objSolicitud.Recibo    = Convert.ToInt32(txtRecibi.Text);
         objSolicitud.Cambio    = Convert.ToDouble(txtCambio.Text);
         objDao.AgregarProducto(objSolicitud);
         for (int i = 0; i < VentaList.Items.Count; i++)
         {
             objDVenta.Folio    = Convert.ToInt32(lblFolio.Text);
             objDVenta.Nombre   = VentaList.Items[i].SubItems[0].Text;
             objDVenta.Precio   = Convert.ToInt32(VentaList.Items[i].SubItems[2].Text);
             objDVenta.Cantidad = Convert.ToInt32(VentaList.Items[i].SubItems[1].Text);
             objDVenta.Total    = Convert.ToInt32(VentaList.Items[i].SubItems[3].Text);
             objDao.AgregarDVenta(objDVenta);
         }
         MessageBox.Show("Venta Realizada con Exito", "Venta", MessageBoxButtons.OK, MessageBoxIcon.Information);
         imprimir();
         VentaList.Clear();
         txtRecibi.Text = "";
         txtTotal.Text  = "";
         txtCambio.Text = "";
         lblFolio.Text  = v.folio().ToString();
         to             = 0;
         generaColumnas();
     }
 }
Beispiel #7
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (v.getyesorno(txtBuscarProducto.Text) > 0)
            {
                //ListViewItem list = VentaList.FindItemWithText(txtBuscarProducto.Text);
                //int suma =Convert.ToInt32(VentaList.Items[list.Index].SubItems[1].Text)+Convert.ToInt32(numericUpDown1.Value);
                //if (suma < v.cantidad(txtBuscarProducto.Text))
                //{
                clsDatosInventario inventarioo = new clsDatosInventario();
                string             varProducto = txtBuscarProducto.Text;
                int varPrecio   = v.getPrecio(txtBuscarProducto.Text);
                int varCantidad = Convert.ToInt32(numericUpDown1.Value);
                total = Convert.ToDouble(varPrecio * varCantidad);
                string[]     elementosFila = new string[5];
                ListViewItem elementoListView;

                if (VentaList.Items.Count == 0)
                {
                    if (varCantidad <= v.cantidad(varProducto))
                    {
                        elementosFila[0] = varProducto;
                        elementosFila[1] = Convert.ToString(varCantidad);
                        elementosFila[2] = Convert.ToString(varPrecio);
                        elementosFila[3] = Convert.ToString(total);
                        elementoListView = new ListViewItem(elementosFila);
                        if (Convert.ToUInt32(elementosFila[1]) <= v.cantidad(txtBuscarProducto.Text))
                        {
                            VentaList.Items.Add(elementoListView);
                        }

                        to            = to + Convert.ToInt32(total);
                        txtTotal.Text = Convert.ToString(to);

                        txtBuscarProducto.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("Se excedió del limite de producto en inventario", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtBuscarProducto.Text = "";
                    }
                }
                else
                {
                    ListViewItem item1 = VentaList.FindItemWithText(varProducto);
                    if (item1 != null)
                    {
                        //int resta = v.cantidad(txtBuscarProducto.Text) - Convert.ToInt32(VentaList.Items[item1.Index].SubItems[1].Text);
                        //MessageBox.Show(resta + "");
                        //if (resta > 0)
                        //{
                        //if (resta <= v.cantidad(txtBuscarProducto.Text) || resta >= v.cantidad(txtBuscarProducto.Text))
                        //{
                        h = Convert.ToInt32(VentaList.Items[item1.Index].SubItems[1].Text) + varCantidad;
                        if (h <= v.cantidad(varProducto))
                        {
                            VentaList.Items[item1.Index].SubItems[1].Text = Convert.ToString(h);
                            VentaList.Items[item1.Index].SubItems[3].Text = Convert.ToString(h * Convert.ToInt32(VentaList.Items[item1.Index].SubItems[2].Text));
                            to            = to + Convert.ToInt32(total);
                            txtTotal.Text = Convert.ToString(to);

                            txtBuscarProducto.Text = "";
                            i++;
                            //resta = 0;
                            //}

                            //}
                            //else
                            //{
                            //    MessageBox.Show("Se excedió del limite de producto en inventario", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            //}
                        }
                        else
                        {
                            MessageBox.Show("Se excedió del limite de producto en inventario", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtBuscarProducto.Text = "";
                        }
                    }
                    else
                    {
                        //h = Convert.ToInt32(VentaList.Items[item1.Index].SubItems[1].Text) + varCantidad;
                        if (varCantidad <= v.cantidad(varProducto))
                        {
                            elementosFila[0] = varProducto;
                            elementosFila[1] = Convert.ToString(varCantidad);
                            elementosFila[2] = Convert.ToString(varPrecio);
                            elementosFila[3] = Convert.ToString(total);
                            elementoListView = new ListViewItem(elementosFila);

                            VentaList.Items.Add(elementoListView);


                            to            = to + Convert.ToInt32(total);
                            txtTotal.Text = Convert.ToString(to);

                            txtBuscarProducto.Text = "";
                            i++;
                        }
                        else
                        {
                            MessageBox.Show("Se excedió del limite de producto en inventario", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtBuscarProducto.Text = "";
                        }
                    }
                }
                numericUpDown1.Value = 1;
                //}
                //else {
                //    MessageBox.Show("Se excedió del limite de producto en inventario", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
            }
            else
            {
                MessageBox.Show("No se encuntra el producto", "Información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtBuscarProducto.Text = "";
            }
        }