Example #1
0
        public static ItemMovimiento Fetch(int id)
        {
            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_porfecha";
                    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 #2
0
        public static List <ItemMovimiento> TraerMovimientosPorTipo(int n_idemp, int n_anotra, int n_idmes, int n_idTipoItem)
        {
            List <ItemMovimiento> m_listentidad = new List <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_costoproduccionmovimiento_listar";
                    command.Parameters.Add(new MySqlParameter("@n_idemp", n_idemp));
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ItemMovimiento m_entidad = SetObject(reader);
                            m_listentidad.Add(m_entidad);
                        }
                    }
                }
            }
            return(m_listentidad);
        }
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);
        }