コード例 #1
0
        public void salidaAlmacen(double totalExistencia, List <Presentacion> presentaciones, Int32 lIdDocumento, Salida_almacen salida, string codigoAlmacen)
        {
            bool success = true;

            if (totalExistencia >= Convert.ToDouble(txtCantidad.Text))
            {
                int    cont                  = 0;
                double resultado             = 0;
                double cantidadSalidaContpaq = 0;
                foreach (var pExistente in presentaciones)
                {
                    cont++;
                    if (cont == 1)
                    {
                        resultado = Double.Parse(Convert.ToString(pExistente.existencia)) - Double.Parse(txtCantidad.Text);
                    }
                    else
                    {
                        resultado = Double.Parse(Convert.ToString(pExistente.existencia)) - resultado;
                    }
                    if (resultado < 0)
                    {
                        if (pExistente.existencia > 0)
                        {
                            success = movimientoAlmacen(pExistente, lIdDocumento, Double.Parse(Convert.ToString(pExistente.existencia)), codigoAlmacen);
                        }
                        resultado             = resultado * -1;
                        pExistente.existencia = 0;
                        cantidadSalidaContpaq = resultado;
                        pExistente.modificar(pExistente);
                    }
                    else
                    {
                        pExistente.existencia = resultado;

                        if (cont == 1)
                        {
                            success = movimientoAlmacen(pExistente, lIdDocumento, Double.Parse(txtCantidad.Text), codigoAlmacen);
                        }
                        else
                        {
                            success = movimientoAlmacen(pExistente, lIdDocumento, cantidadSalidaContpaq, codigoAlmacen);
                        }

                        pExistente.modificar(pExistente);
                        break;
                    }
                }

                if (success == true)
                {
                    salida.registrar(salida);
                    MessageBox.Show("SE REGISTRO LA SALIDA DE: " + salida.cantidad + " " + unidad.nombre + " \nDEL INSUMO: " + cbxInsumo.SelectedItem.ToString() + "\nPOR LA RAZÓN: " + salida.descripcion, "AVISO SHARK");
                }
            }
            else
            {
                MessageBox.Show("LA CANTIDAD QUE DESEA MARCAR COMO SALIDA ES MAYOR AL NÚMERO DE EXISTENCIA EN SU ALMACÉN");
            }
        }