Example #1
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (dgvDetalleNotaSalida.Rows.Count == 0)
            {
                MessageBox.Show("No hay un registro seleccionado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            int index             = dgvDetalleNotaSalida.CurrentRow.Index;                            // Identificando la fila actual del datagridview
            int idPresentacion    = Convert.ToInt32(dgvDetalleNotaSalida.Rows[index].Cells[0].Value); // obteniedo el idRegistro del datagridview
            DetalleNotaSalida aux = listDetalleNotaSalida.Find(x => x.idPresentacion == idPresentacion);

            currentPresentacion  = listPresentacion.Find(X => X.idPresentacion == idPresentacion);
            aux.cantidad         = toDouble(txtCantidad.Text);
            aux.cantidadUnitaria = toDouble(txtCantidad.Text);
            aux.total            = toDouble(txtCantidad.Text) * toDouble(currentPresentacion.precioCompra);

            detalleNotaSalidaBindingSource.DataSource = null;
            detalleNotaSalidaBindingSource.DataSource = listDetalleNotaSalida;
            cbxCodigoProducto.Refresh();
            btnAgregar.Enabled   = true;
            btnModificar.Enabled = false;
            btnEliminar.Enabled  = false;
            limpiarCamposProducto();
        }
Example #2
0
        private void dgvDetalleNotaSalida_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvDetalleNotaSalida.Rows.Count == 0)
            {
                MessageBox.Show("No hay un registro seleccionado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            indice = dgvDetalleNotaSalida.CurrentRow.Index;                                         // Identificando la fila actual del datagridview
            int idPresentacion = Convert.ToInt32(dgvDetalleNotaSalida.Rows[indice].Cells[0].Value);
            int idCombinacion  = Convert.ToInt32(dgvDetalleNotaSalida.Rows[indice].Cells[1].Value); // obteniedo el idRegistro del datagridview

            currentdetalleNotaSalida = buscarElemento(idPresentacion, idCombinacion);               // Buscando la registro especifico en la lista de registros

            cbxCodigoProducto.SelectedValue = currentdetalleNotaSalida.idProducto;
            cbxDescripcion.SelectedValue    = currentdetalleNotaSalida.idPresentacion;
            cbxVariacion.Text = currentdetalleNotaSalida.nombreCombinacion;
            txtCantidad.Text  = Convert.ToInt32(currentdetalleNotaSalida.cantidad).ToString();


            btnModificar.Enabled      = true;
            btnAgregar.Enabled        = false;
            btnEliminar.Enabled       = true;
            cbxDescripcion.Enabled    = false;
            cbxCodigoProducto.Enabled = false;
        }
Example #3
0
 private void btnAceptar_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in dgvNotaSalida.Rows)
     {
         DataGridViewCheckBoxCell checkBox = (row.Cells["chkbxseleccionDetalleNotaSalida"] as DataGridViewCheckBoxCell);
         bool estaSeleccionado             = Convert.ToBoolean(checkBox.EditedFormattedValue);
         if (estaSeleccionado)
         {
             DataGridViewTextBoxCell idPresentacion = (row.Cells["idPresentacion"] as DataGridViewTextBoxCell);
             DetalleNotaSalida       presentacion   = listNotaSalidaDestalle.Find(X => X.idPresentacion == Convert.ToInt32(idPresentacion.Value));
             listDestalleSubmit.Add(presentacion);
         }
     }
     this.Close();
 }
        private void dgvDetalleSalida_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvDetalleSalida.Rows.Count == 0)
            {
                MessageBox.Show("No hay un registro seleccionado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            int index             = dgvDetalleSalida.CurrentRow.Index;                            // Identificando la fila actual del datagridview
            int idPresentacion    = Convert.ToInt32(dgvDetalleSalida.Rows[index].Cells[1].Value); // obteniedo el idRegistro del datagridview
            DetalleNotaSalida aux = listDetalleNotaSalida.Find(x => x.idPresentacion == idPresentacion);

            lbinfo.Text         = aux.codigoProducto + " seleccionado";
            btnEliminar.Enabled = true;
        }
Example #5
0
        private void btnEliminar_Click_1(object sender, EventArgs e)
        {
            if (dgvDetalleNotaSalida.Rows.Count == 0)
            {
                MessageBox.Show("No hay un registro seleccionado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            int index             = dgvDetalleNotaSalida.CurrentRow.Index;                            // Identificando la fila actual del datagridview
            int idPresentacion    = Convert.ToInt32(dgvDetalleNotaSalida.Rows[index].Cells[0].Value); // obteniedo el idRegistro del datagridview
            DetalleNotaSalida aux = listDetalleNotaSalida.Find(x => x.idPresentacion == idPresentacion);

            btnAgregar.Enabled   = true;
            btnModificar.Enabled = false;
            btnEliminar.Enabled  = false;
            dgvDetalleNotaSalida.Rows.RemoveAt(index);
            listDetalleNotaSalida.Remove(aux);
            limpiarCamposProducto();
        }
Example #6
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            //validando campos
            if (txtCantidad.Text == "")
            {
                txtCantidad.Text = "0";
            }


            bool seleccionado = false;

            if (cbxCodigoProducto.SelectedValue != null)
            {
                seleccionado = true;
            }
            if (cbxDescripcion.SelectedValue != null)
            {
                seleccionado = true;
            }

            if (seleccionado)
            {
                if (listDetalleNotaSalida == null)
                {
                    listDetalleNotaSalida = new List <DetalleNotaSalida>();
                }
                DetalleNotaSalida detalleNota = new DetalleNotaSalida();

                currentPresentacion = listPresentacion.Find(x => x.idPresentacion == Convert.ToInt32(cbxDescripcion.SelectedValue));

                currentProducto = listProducto.Find(x => x.idProducto == Convert.ToInt32(cbxCodigoProducto.SelectedValue));

                DetalleNotaSalida find = listDetalleNotaSalida.Find(x => x.idPresentacion == Convert.ToInt32(cbxDescripcion.SelectedValue));
                if (find != null)
                {
                    MessageBox.Show("Este dato ya fue agregado", "presentacion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                currentProducto = listProducto.Find(x => x.idProducto == currentPresentacion.idProducto);
                // Creando la lista
                detalleNota.cantidad                 = toDouble(txtCantidad.Text.Trim());
                detalleNota.cantidadUnitaria         = toDouble(txtCantidad.Text.Trim());
                detalleNota.codigoProducto           = currentProducto.codigoProducto;
                detalleNota.descripcion              = cbxDescripcion.Text.Trim();
                detalleNota.idCombinacionAlternativa = Convert.ToInt32(cbxVariacion.SelectedValue);
                detalleNota.idNotaSalida             = 0;
                detalleNota.idDetalleNotaSalida      = 0;
                detalleNota.idPresentacion           = Convert.ToInt32(cbxDescripcion.SelectedValue);
                detalleNota.idProducto               = Convert.ToInt32(cbxCodigoProducto.SelectedValue);
                detalleNota.nombreCombinacion        = cbxVariacion.Text;
                detalleNota.nombreMarca              = currentProducto.nombreMarca;
                detalleNota.nombrePresentacion       = currentPresentacion.nombrePresentacion;
                detalleNota.estado                = currentPresentacion.estado;
                detalleNota.idDetalleVenta        = 0;
                detalleNota.ventaVarianteSinStock = currentProducto.ventaVarianteSinStock;
                detalleNota.idVenta               = 0;
                detalleNota.nro                = 1;
                detalleNota.precioEnvio        = 0;
                detalleNota.descuento          = 0;  // ver en detalle al guardar
                detalleNota.total              = toDouble(txtCantidad.Text.Trim()) * toDouble(currentPresentacion.precioCompra);
                detalleNota.alternativas       = ""; // falta ver este detalle
                detalleNota.idNotaSalida       = currentNotaSalida != null ? currentNotaSalida.idNotaSalida : 0;
                detalleNota.nombrePresentacion = currentPresentacion.nombrePresentacion;
                // agrgando un nuevo item a la lista
                listDetalleNotaSalida.Add(detalleNota);
                // Refrescando la tabla
                detalleNotaSalidaBindingSource.DataSource = null;
                detalleNotaSalidaBindingSource.DataSource = listDetalleNotaSalida;
                dgvDetalleNotaSalida.Refresh();
                // Calculo de totales y subtotales e impuestos

                limpiarCamposProducto();
            }
            else
            {
                MessageBox.Show("Error: elemento no seleccionado", "agregar Elemento", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #7
0
        public string CerrarPedido(string NumeroPedido, List <DetalleNotaSalida> Detalle)
        {
            //Nota de salida
            NotaSalida ns     = new NotaSalida();
            var        ultimo = db.NotaSalida.OrderByDescending(x => x.NumeroSalida).Take(1).FirstOrDefault();
            double     numero = 1;

            if (ultimo != null)
            {
                numero = double.Parse(ultimo.NumeroSalida.Replace("NS-", "")) + 1;
            }

            ns.NumeroSalida = "NS-" + double.Parse(numero.ToString()).ToString("#000000");
            ns.NumeroPedido = NumeroPedido;
            ns.FechaSalida  = DateTime.Now.ToShortDateString();
            //ns.idAlmacen = 1;
            var usuario = (LoginEntity)Session["Usuario"];

            if (usuario != null)
            {
                ns.UsuarioPicking = usuario.Usuario;
            }
            db.NotaSalida.Add(ns);

            //Detalle Nota de salida
            List <DetalleNotaSalida> detalleSalida = new List <DetalleNotaSalida>();
            DetalleNotaSalida        objDetalle;

            //Kardex
            Kardex objKardex;
            List <DetalleKardex> detalleKardex = new List <DetalleKardex>();
            DetalleKardex        dKardex;

            foreach (var item in Detalle)
            {
                //Detalle de la nota de salida
                objDetalle = new DetalleNotaSalida();
                objDetalle.NumeroSalida = ns.NumeroSalida;
                objDetalle.IdProducto   = item.IdProducto;
                objDetalle.Cantidad     = item.Cantidad;
                detalleSalida.Add(objDetalle);

                //Detalle del kardex
                objKardex = db.Kardex.FirstOrDefault(x => x.IdProducto == item.IdProducto); //&& x.IdAlmacen == IdAlmacen
                if (objKardex != null)
                {
                    dKardex = new DetalleKardex();
                    dKardex.NumeroKardex     = objKardex.NumeroKardex;
                    dKardex.NumeroDocumento  = NumeroPedido;
                    dKardex.TipodeMovimiento = 2;
                    dKardex.NumeroSalida     = ns.NumeroSalida;
                    dKardex.Fecha            = DateTime.Now;
                    dKardex.Cantidad         = item.Cantidad;
                    detalleKardex.Add(dKardex);
                }
            }

            //Detalle de Nota de Salida
            db.DetalleNotaSalida.AddRange(detalleSalida);

            //Kardex
            db.DetalleKardex.AddRange(detalleKardex);

            //Actualizamos el estado del pedido
            var pedido = db.Pedido.Find(NumeroPedido);

            if (pedido != null)
            {
                pedido.Estado = 3;                //Atendido
            }
            db.SaveChanges();

            return(ns.NumeroSalida);
        }