public static List <ItemMovimientoDetalle> FetchList(int n_idemp, int n_anotra)
        {
            List <ItemMovimientoDetalle> m_listentidad = new List <ItemMovimientoDetalle>();

            using (MySqlConnection connection
                       = new MySqlConnection(
                             ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.CommandText = "con_movimientoitemdetalle_listar";
                    command.Parameters.Add(new MySqlParameter("@n_idemp", n_idemp));
                    command.Parameters.Add(new MySqlParameter("@n_anotra", n_anotra));
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ItemMovimientoDetalle m_entidad = SetObject(reader);
                            m_listentidad.Add(m_entidad);
                        }
                    }
                }
            }
            return(m_listentidad);
        }
        public static ItemMovimientoDetalle Fetch(int id)
        {
            ItemMovimientoDetalle m_entidad = new ItemMovimientoDetalle();

            using (MySqlConnection connection
                       = new MySqlConnection(
                             ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.CommandText = "con_movimientoitemdetalle_traerregistro";
                    command.Parameters.Add(new MySqlParameter("@n_id", id));
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            m_entidad = SetObject(reader);
                        }
                    }
                }
            }
            return(m_entidad);
        }
Example #3
0
        public static ItemMovimiento TraerMovimientoPorFecha(int n_idemp
                                                             , int n_idite
                                                             , int n_idalm
                                                             , DateTime d_fchini
                                                             , DateTime d_fchfin)
        {
            ItemMovimiento m_entidad = new ItemMovimiento();

            using (MySqlConnection connection
                       = new MySqlConnection(
                             ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.CommandText = "con_costoprod_movimiento_item_porfecha";
                    command.Parameters.Add(new MySqlParameter("@n_idemp", n_idemp));
                    command.Parameters.Add(new MySqlParameter("@n_idite", n_idite));
                    command.Parameters.Add(new MySqlParameter("@n_idalm", n_idalm));
                    command.Parameters.Add(new MySqlParameter("@c_fchini", d_fchini.ToString("dd/MM/yyyy")));
                    command.Parameters.Add(new MySqlParameter("@c_fchfin", d_fchfin.ToString("dd/MM/yyyy")));
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            if (string.IsNullOrEmpty(m_entidad.c_codite))
                            {
                                m_entidad = SetObject(reader);
                            }
                            if (m_entidad.ItemMovimientoDetalles == null)
                            {
                                m_entidad.ItemMovimientoDetalles = new ObservableListSource <ItemMovimientoDetalle>();
                            }
                            m_entidad.ItemMovimientoDetalles.Add(ItemMovimientoDetalle.SetObject(reader));
                        }
                    }
                }
            }
            //Se cargan los valores iniciales
            KardexResumen kardexResumen = KardexResumen.TraerKardexResumenPorItemMovimiento(n_idemp
                                                                                            , n_idalm
                                                                                            , n_idite
                                                                                            , d_fchini
                                                                                            , d_fchfin);

            if (kardexResumen != null)
            {
                m_entidad.n_saldoini = kardexResumen.n_stkini;
                m_entidad.n_costoini = kardexResumen.n_costoini;
                if (kardexResumen.n_stkini == 0)
                {
                    m_entidad.n_costounipromini = 0;
                }
                else
                {
                    m_entidad.n_costounipromini = kardexResumen.n_costopromini / kardexResumen.n_stkini;
                }
            }
            else
            {
                m_entidad.n_saldoini        = 0;
                m_entidad.n_costoini        = 0;
                m_entidad.n_costounipromini = 0;
            }

            return(m_entidad);
        }