Beispiel #1
0
        public static MovimientoDet Fetch(int id)
        {
            MovimientoDet m_entidad = new MovimientoDet();

            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 = "alm_movimientosdet_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);
        }
Beispiel #2
0
        public override void Delete()
        {
            using (MySqlConnection connection
                       = new MySqlConnection(
                             ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                connection.Open();
                using (MySqlTransaction transaction = connection.BeginTransaction())
                {
                    using (MySqlCommand command = connection.CreateCommand())
                    {
                        try
                        {
                            MovimientoDet.DeleteAll(n_id, connection, transaction);

                            command.Transaction = transaction;
                            command.CommandType = System.Data.CommandType.StoredProcedure;
                            command.CommandText = "alm_movimientos_eliminar";
                            command.Parameters.Add(new MySqlParameter("@n_id", n_id));
                            int rows = command.ExecuteNonQuery();
                            transaction.Commit();
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();
                            throw ex;
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public static ObservableListSource <MovimientoDet> FetchList(int n_idmov)
        {
            ObservableListSource <MovimientoDet> m_listentidad = new ObservableListSource <MovimientoDet>();

            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 = "alm_movimientosdet_listar";
                    command.Parameters.Add(new MySqlParameter("@n_idmov", n_idmov));
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            MovimientoDet m_entidad = SetObject(reader);
                            m_listentidad.Add(m_entidad);
                        }
                    }
                }
            }
            return(m_listentidad);
        }
Beispiel #4
0
        private void GrabarMovimiento(MySqlConnection connection, MySqlTransaction transaction, bool isNew)
        {
            if (!isNew)
            {
                Movimiento movimientoAnterior = Movimiento.FetchPorInventario(this.n_id);
                if (movimientoAnterior != null)
                {
                    movimientoAnterior.Delete(connection, transaction);
                }
            }

            Movimiento movimientoNuevo = new Movimiento();

            movimientoNuevo.d_fchdoc         = this.d_fchvig;
            movimientoNuevo.d_fching         = this.d_fchvig;
            movimientoNuevo.n_idemp          = this.n_idemp;
            movimientoNuevo.n_idtipmov       = 1;
            movimientoNuevo.n_idclipro       = 10293;
            movimientoNuevo.n_idtipdoc       = 49;
            movimientoNuevo.c_numser         = "0001";
            movimientoNuevo.c_numdoc         = TipoDocumento.UltimoNumero(this.n_idemp, 49, movimientoNuevo.c_numser);
            movimientoNuevo.n_idalm          = this.n_idalm;
            movimientoNuevo.n_anotra         = this.d_fchvig.Year;
            movimientoNuevo.n_idmes          = this.d_fchvig.Month;
            movimientoNuevo.n_idtipope       = 2;
            movimientoNuevo.n_tipite         = 2;
            movimientoNuevo.n_docrefidtipdoc = 97;
            movimientoNuevo.n_docrefiddocref = this.n_id;
            movimientoNuevo.c_docrefnumser   = this.c_numser;
            movimientoNuevo.c_docrefnumdoc   = this._c_numdoc;
            movimientoNuevo.n_perid          = 0;
            movimientoNuevo.n_prolog         = 1;

            movimientoNuevo.MovimientoDets = new ObservableListSource <MovimientoDet>();

            foreach (var hijo in InventarioInicialDets)
            {
                MovimientoDet movimientoDet = new MovimientoDet();
                movimientoDet.n_idite    = hijo.n_idite;
                movimientoDet.n_idpre    = hijo.n_idunimed;
                movimientoDet.n_can      = hijo.n_can;
                movimientoDet.c_numlot   = "SIN LOTE";
                movimientoDet.n_idtippro = 6;

                movimientoNuevo.MovimientoDets.Add(movimientoDet);
            }

            movimientoNuevo.Save();
        }